1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
// Tests @target attribute for x86
// REQUIRES: target_X86
// RUN: %ldc -O -c -mcpu=i386 -mtriple=i386-linux-gnu -output-ll -of=%t.ll %s && FileCheck %s --check-prefix LLVM < %t.ll
// RUN: %ldc -O -c -mcpu=i386 -mtriple=i386-linux-gnu -output-s -of=%t.s %s && FileCheck %s --check-prefix ASM < %t.s
import ldc.attributes;
// LLVM-LABEL: define{{.*}} void @{{.*}}foo
// ASM-LABEL: _D15attr_target_x863fooFPfQcfZv:
void foo(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM-NOT: addps
}
// LLVM-LABEL: define{{.*}} void @{{.*}}foo_sse
// LLVM-SAME: #[[SSE:[0-9]+]]
// ASM-LABEL: _D15attr_target_x867foo_sseFPfQcfZv:
@(target("sse"))
void foo_sse(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM: addps
}
// Make sure that no-sse overrides sse (attribute sorting). Also tests multiple @target attribs.
// LLVM-LABEL: define{{.*}} void @{{.*}}foo_nosse
// LLVM-SAME: #[[NOSSE:[0-9]+]]
// ASM-LABEL: _D15attr_target_x869foo_nosseFPfQcfZv:
@(target("no-sse\n , \tsse "))
void foo_nosse(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM-NOT: addps
}
// LLVM-LABEL: define{{.*}} void @{{.*}}bar_nosse
// LLVM-SAME: #[[NOSSE]]
// ASM-LABEL: _D15attr_target_x869bar_nosseFPfQcfZv:
@(target("sse"))
@(target(" no-sse"))
void bar_nosse(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM-NOT: addps
}
// LLVM-LABEL: define{{.*}} void @{{.*}}haswell
// LLVM-SAME: #[[HSW:[0-9]+]]
// ASM-LABEL: _D15attr_target_x867haswellFPfQcfZv:
@(target("arch=haswell "))
void haswell(float *A, float* B, float K) {
for (int i = 0; i < 128; ++i)
A[i] *= B[i] + K;
// ASM: vaddps
}
// LLVM-DAG: attributes #[[SSE]] = {{.*}} "target-features"="+sse"
// LLVM-DAG: attributes #[[NOSSE]] = {{.*}} "target-features"="+sse,-sse"
// LLVM-DAG: attributes #[[HSW]] = {{.*}} "target-cpu"="haswell"
|