File: builtin-complex.c

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb11u2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,634,820 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (22 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// RUN: %clang_cc1 -triple x86_64-linux -w -S -o - -emit-llvm -DT=float %s | FileCheck %s --check-prefixes=CHECK,CHECK-FLOAT
// RUN: %clang_cc1 -triple x86_64-linux -w -S -o - -emit-llvm -DT=double %s | FileCheck %s --check-prefixes=CHECK,CHECK-DOUBLE
// RUN: %clang_cc1 -triple x86_64-linux -w -S -o - -emit-llvm -DT="long double" %s | FileCheck %s --check-prefixes=CHECK,CHECK-FP80
// RUN: %clang_cc1 -triple x86_64-linux -w -S -o - -emit-llvm -DT=__float128 %s | FileCheck %s --check-prefixes=CHECK,CHECK-FP128
// FIXME: If we start to support _Complex __fp16 or _Complex _Float16, add tests for them too.

// CHECK-FLOAT: @global ={{.*}} global { [[T:float]], [[T]] } { [[T]] 1.0{{.*}}, [[T]] 2.0{{.*}} }
// CHECK-DOUBLE: @global ={{.*}} global { [[T:double]], [[T]] } { [[T]] 1.0{{.*}}, [[T]] 2.0{{.*}} }
// CHECK-FP80: @global ={{.*}} global { [[T:x86_fp80]], [[T]] } { [[T]] 0xK3FFF8000000000000000, [[T]] 0xK40008000000000000000 }
// CHECK-FP128: @global ={{.*}} global { [[T:fp128]], [[T]] } { [[T]] 0xL00000000000000003FFF000000000000, [[T]] 0xL00000000000000004000000000000000 }
_Complex T global = __builtin_complex(1.0, 2.0);

// CHECK-LABEL: @test
_Complex T test(T a, T b) {
  return __builtin_complex(a, b);
  // CHECK: %[[A:.*]] = load [[T]], ptr %a.addr,
  // CHECK: %[[B:.*]] = load [[T]], ptr %b.addr,
  // CHECK: %[[RET_RE:.*]] = getelementptr inbounds { [[T]], [[T]] }, ptr %[[RET:[^,]*]], i32 0, i32 0
  // CHECK: %[[RET_IM:.*]] = getelementptr inbounds { [[T]], [[T]] }, ptr %[[RET]], i32 0, i32 1
  // CHECK: store [[T]] %[[A]], ptr %[[RET_RE]],
  // CHECK: store [[T]] %[[B]], ptr %[[RET_IM]],
}