Skip to content

Commit

Permalink
internal/stage2.d: Use processor extensions in @target (#46)
Browse files Browse the repository at this point in the history
If compiling with >=ldc-1.38.0 (so that
ldc-developers/ldc#4620 is merged) use
processor extensions in `@target` attribute instead of the cpu name.

Signed-off-by: Andrei Horodniceanu <[email protected]>
  • Loading branch information
the-horo committed May 20, 2024
1 parent 79cfb20 commit 4705ada
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/mir/ion/internal/stage2.d
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,13 @@ void stage2(

version (X86_Any)
{
// A backwards compatible @target ldc attribute.
// Needed because of https://github.com/libmir/mir-ion/pull/46
version(LDC)
private enum backwardsCompatibleTarget (string now, string old) =
target(__VERSION__ >= 2108 ? now : old);

version (LDC) @target("arch=westmere")
version (LDC) @backwardsCompatibleTarget!("sse4.2", "arch=westmere")
private void stage2_impl_westmere(
size_t n,
scope const(ubyte[64])* vector,
Expand Down Expand Up @@ -121,7 +126,7 @@ version (X86_Any)
while(--n);
}

version (LDC) @target("arch=sandybridge")
version (LDC) @backwardsCompatibleTarget!("avx", "arch=sandybridge")
private void stage2_impl_sandybridge(
size_t n,
scope const(ubyte[64])* vector,
Expand Down Expand Up @@ -158,7 +163,7 @@ version (X86_Any)
while(--n);
}

version (LDC) @target("arch=broadwell")
version (LDC) @backwardsCompatibleTarget!("avx2", "arch=broadwell")
private void stage2_impl_broadwell(
size_t n,
scope const(ubyte[64])* vector,
Expand Down Expand Up @@ -197,7 +202,7 @@ version (X86_Any)
}

version(none)
version (LDC) @target("arch=skylake-avx512")
version (LDC) @backwardsCompatibleTarget!("avx512bw", "arch=skylake-avx512")
private void stage2_impl_skylake_avx512(
size_t n,
scope const(ubyte[64])* vector,
Expand Down

0 comments on commit 4705ada

Please sign in to comment.