File: attr_target_overrides_mattr_x86.d

package info (click to toggle)
ldc 1%3A1.40.0-5
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 63,308 kB
  • sloc: cpp: 85,368; ansic: 21,877; makefile: 1,705; sh: 1,018; asm: 584; objc: 135; exp: 48; python: 12
file content (35 lines) | stat: -rw-r--r-- 1,408 bytes parent folder | download
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
// Test that @target attribute overrides command line -mattr

// REQUIRES: target_X86

// RUN: %ldc -O -c -mattr=sse -mcpu=i386 -mtriple=i386-linux-gnu -output-ll -of=%t.sse.ll %s && FileCheck %s --check-prefix LLVM-SSE < %t.sse.ll
// RUN: %ldc -O -c -mattr=-sse -mcpu=i386 -mtriple=i386-linux-gnu -output-ll -of=%t.nosse.ll %s && FileCheck %s --check-prefix LLVM-NOSSE < %t.nosse.ll

import ldc.attributes;

// LLVM-SSE-LABEL: define{{.*}} void @{{.*}}foo_nosse
// LLVM-SSE-SAME: #[[NOSSE:[0-9]+]]
// LLVM-NOSSE-LABEL: define{{.*}} void @{{.*}}foo_nosse
// LLVM-NOSSE-SAME: #[[NOSSE:[0-9]+]]
@target("no-sse")
void foo_nosse(float *A, float *B, float K) {
    for (int i = 0; i < 128; ++ i)
	A[i] *= B[i] + K;
}

// LLVM-SSE-LABEL: define{{.*}} void @{{.*}}foo_sse
// LLVM-SSE-SAME: #[[SSE:[0-9]+]]
// LLVM-NOSSE-LABEL: define{{.*}} void @{{.*}}foo_sse
// LLVM-NOSSE-SAME: #[[SSE:[0-9]+]]
@target("sse")
void foo_sse(float *A, float *B, float K) {
    for (int i = 0; i < 128; ++ i)
	A[i] *= B[i] + K;
}

// The -mattr feature should come before the @target one in the "target-features" below.

// LLVM-SSE-DAG: attributes #[[SSE]] = {{.*}} "target-features"="+sse,+sse"
// LLVM-SSE-DAG: attributes #[[NOSSE]] = {{.*}} "target-features"="+sse,-sse"
// LLVM-NOSSE-DAG: attributes #[[SSE]] = {{.*}} "target-features"="-sse,+sse"
// LLVM-NOSSE-DAG: attributes #[[NOSSE]] = {{.*}} "target-features"="-sse,-sse"