summaryrefslogtreecommitdiff
path: root/clang/test/Preprocessor/flt_eval_macro.cpp
blob: 37c28f21333f95c874e45358b30b34f26beefba7 (plain)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// RUN: %clang_cc1 -E -dM -triple=x86_64-none-none  %s -o - \
// RUN:   | FileCheck %s -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple=x86_64-none-none -target-feature -sse \
// RUN:   %s -o - | FileCheck %s -check-prefix=EXT -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple=arm64e-apple-ios -target-feature -sse \
// RUN:   %s -o - | FileCheck %s  -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple=arm64e-apple-ios -target-feature +sse \
// RUN:   %s -o - | FileCheck %s  -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple=arm64_32-apple-ios  %s -o - \
// RUN:   | FileCheck %s  -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple=arm64_32-apple-ios -target-feature -sse \
// RUN:   %s -o - | FileCheck %s  -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple=x86_64-apple-macos13.0 -ffast-math \
// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-MINUS-ONE -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple i386-pc-windows -target-cpu pentium4 %s -o - \
// RUN:   | FileCheck %s  -strict-whitespace

// RUN: %clang_cc1 -E -dM -triple i386-pc-windows -target-cpu pentium4 \
// RUN:   -target-feature -sse %s -o - | FileCheck -check-prefix=EXT %s \
// RUN:   -strict-whitespace

#ifdef __FLT_EVAL_METHOD__
#if __FLT_EVAL_METHOD__ == 3
#define __GLIBC_FLT_EVAL_METHOD 2
#else
#define __GLIBC_FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#endif
#elif defined __x86_64__
#define __GLIBC_FLT_EVAL_METHOD 0
#else
#define __GLIBC_FLT_EVAL_METHOD 2
#endif

#if __GLIBC_FLT_EVAL_METHOD == -1
#define Name "MinusOne"
#elif __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16
#define Name "One"
#elif __GLIBC_FLT_EVAL_METHOD == 1
#define Name "Two"
#elif __GLIBC_FLT_EVAL_METHOD == 2
#define Name "Three"
#elif __GLIBC_FLT_EVAL_METHOD == 32
#define Name "Four"
#elif __GLIBC_FLT_EVAL_METHOD == 33
#define Name "Five"
#elif __GLIBC_FLT_EVAL_METHOD == 64
#define Name "Six"
#elif __GLIBC_FLT_EVAL_METHOD == 65
#define Name "Seven"
#elif __GLIBC_FLT_EVAL_METHOD == 128
#define Name "Eight"
#elif __GLIBC_FLT_EVAL_METHOD == 129
#define Name "Nine"
#else
#error "Unknown __GLIBC_FLT_EVAL_METHOD"
#endif

int foo() {
  // CHECK: #define Name "One"
  // CHECK-MINUS-ONE: #define Name "MinusOne"
  // EXT: #define Name "Three"
  return Name;
}

#pragma fp eval_method(double)

#if __FLT_EVAL_METHOD__ == 3
#define Val "Unset"
#elif __FLT_EVAL_METHOD__ == 0
#define Val "val0"
#elif __FLT_EVAL_METHOD__ == 1
#define Val "val1"
#elif __FLT_EVAL_METHOD__ == 2
#define Val "val2"
#endif

int goo() {
  // CHECK: #define Val "val0"
  // EXT: #define Val "val2"
  return Val;
}