llvm-capstone/clang/test/Preprocessor/flt_eval_macro.cpp
Zahira Ammarguellat 2f1264260b Revert "Currently the control of the eval-method is mixed with fast-math."
Setting __FLT_EVAL_METHOD__ to -1 with fast-math will set
__GLIBC_FLT_EVAL_METHOD to 2 and long double ends up being used for
float_t and double_t. This creates some ABI breakage with various C libraries.
See details here: https://github.com/llvm/llvm-project/issues/60781

This reverts commit bbf0d1932a3c1be970ed8a580e51edf571b80fd5.
2023-03-10 14:44:06 -05:00

88 lines
2.5 KiB
C++

// 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 -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"
// 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;
}