[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / aarch64-strictfp-builtins.c
blob285156311ac145d9cda9967c09595645b5a13341
1 // RUN: %clang_cc1 %s -emit-llvm -ffp-exception-behavior=maytrap -o - -triple arm64-none-linux-gnu | FileCheck %s
3 // Test that the constrained intrinsics are picking up the exception
4 // metadata from the AST instead of the global default from the command line.
6 #pragma float_control(except, on)
8 int printf(const char *, ...);
10 // CHECK-LABEL: @p(
11 // CHECK-NEXT: entry:
12 // CHECK-NEXT: [[STR_ADDR:%.*]] = alloca ptr, align 8
13 // CHECK-NEXT: [[X_ADDR:%.*]] = alloca i32, align 4
14 // CHECK-NEXT: store ptr [[STR:%.*]], ptr [[STR_ADDR]], align 8
15 // CHECK-NEXT: store i32 [[X:%.*]], ptr [[X_ADDR]], align 4
16 // CHECK-NEXT: [[TMP0:%.*]] = load ptr, ptr [[STR_ADDR]], align 8
17 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[X_ADDR]], align 4
18 // CHECK-NEXT: [[CALL:%.*]] = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef [[TMP0]], i32 noundef [[TMP1]]) [[ATTR4:#.*]]
19 // CHECK-NEXT: ret void
21 void p(char *str, int x) {
22 printf("%s: %d\n", str, x);
25 #define P(n,args) p(#n #args, __builtin_##n args)
27 // CHECK-LABEL: @test_long_double_isinf(
28 // CHECK-NEXT: entry:
29 // CHECK-NEXT: [[LD_ADDR:%.*]] = alloca fp128, align 16
30 // CHECK-NEXT: store fp128 [[D:%.*]], ptr [[LD_ADDR]], align 16
31 // CHECK-NEXT: [[TMP0:%.*]] = load fp128, ptr [[LD_ADDR]], align 16
32 // CHECK-NEXT: [[BITCAST:%.*]] = bitcast fp128 [[TMP0]] to i128
33 // CHECK-NEXT: [[SHL1:%.*]] = shl i128 [[BITCAST]], 1
34 // CHECK-NEXT: [[CMP:%.*]] = icmp eq i128 [[SHL1]], -10384593717069655257060992658440192
35 // CHECK-NEXT: [[RES:%.*]] = zext i1 [[CMP]] to i32
36 // CHECK-NEXT: call void @p(ptr noundef @.str.[[#STRID:1]], i32 noundef [[RES]]) [[ATTR4]]
37 // CHECK-NEXT: ret void
39 void test_long_double_isinf(long double ld) {
40 P(isinf, (ld));
42 return;
45 // CHECK-LABEL: @test_long_double_isfinite(
46 // CHECK-NEXT: entry:
47 // CHECK-NEXT: [[LD_ADDR:%.*]] = alloca fp128, align 16
48 // CHECK-NEXT: store fp128 [[D:%.*]], ptr [[LD_ADDR]], align 16
49 // CHECK-NEXT: [[TMP0:%.*]] = load fp128, ptr [[LD_ADDR]], align 16
50 // CHECK-NEXT: [[BITCAST:%.*]] = bitcast fp128 [[TMP0]] to i128
51 // CHECK-NEXT: [[SHL1:%.*]] = shl i128 [[BITCAST]], 1
52 // CHECK-NEXT: [[CMP:%.*]] = icmp ult i128 [[SHL1]], -10384593717069655257060992658440192
53 // CHECK-NEXT: [[RES:%.*]] = zext i1 [[CMP]] to i32
54 // CHECK-NEXT: call void @p(ptr noundef @.str.[[#STRID:STRID+1]], i32 noundef [[RES]]) [[ATTR4]]
55 // CHECK-NEXT: ret void
57 void test_long_double_isfinite(long double ld) {
58 P(isfinite, (ld));
60 return;
63 // CHECK-LABEL: @test_long_double_isnan(
64 // CHECK-NEXT: entry:
65 // CHECK-NEXT: [[LD_ADDR:%.*]] = alloca fp128, align 16
66 // CHECK-NEXT: store fp128 [[D:%.*]], ptr [[LD_ADDR]], align 16
67 // CHECK-NEXT: [[TMP0:%.*]] = load fp128, ptr [[LD_ADDR]], align 16
68 // CHECK-NEXT: [[BITCAST:%.*]] = bitcast fp128 [[TMP0]] to i128
69 // CHECK-NEXT: [[ABS:%.*]] = and i128 [[BITCAST]], 170141183460469231731687303715884105727
70 // CHECK-NEXT: [[TMP1:%.*]] = sub i128 170135991163610696904058773219554885632, [[ABS]]
71 // CHECK-NEXT: [[ISNAN:%.*]] = lshr i128 [[TMP1]], 127
72 // CHECK-NEXT: [[RES:%.*]] = trunc i128 [[ISNAN]] to i32
73 // CHECK-NEXT: call void @p(ptr noundef @.str.[[#STRID:STRID+1]], i32 noundef [[RES]])
74 // CHECK-NEXT: ret void
76 void test_long_double_isnan(long double ld) {
77 P(isnan, (ld));
79 return;