[clang] [llvm] [clang] Add fixed point precision macros (PR #81207)

via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 13:19:15 PST 2024


================
@@ -0,0 +1,67 @@
+/// Assert the fixed point precision macros according to N1169 7.18a.3 are
+/// defined when -ffixed-point is provided.
+
+// RUN: %clang_cc1 -triple=x86_64 -E -dM -ffixed-point -x c < /dev/null | FileCheck -match-full-lines %s
+// RUN: %clang_cc1 -triple=x86_64 -E -dM -ffixed-point -x c++ < /dev/null | FileCheck -match-full-lines %s
+
+/// These are the implementation-defined values for x86_64.
+// CHECK-DAG:#define __SFRACT_EPSILON__ 0.0078125hr
+// CHECK-DAG:#define __SFRACT_FBIT__ 7
+// CHECK-DAG:#define __SFRACT_MAX__ 0.9921875hr
+// CHECK-DAG:#define __SFRACT_MIN__ (-0.5hr-0.5hr)
+
+// CHECK-DAG:#define __USFRACT_EPSILON__ 0.00390625uhr
+// CHECK-DAG:#define __USFRACT_FBIT__ 8
+// CHECK-DAG:#define __USFRACT_MAX__ 0.99609375uhr
----------------
PiJoules wrote:

I believe those values are just example values for `7.18a.3 Precision macros` and the actual values are implementation defined:

```
The values in the following list shall be replaced by constant expressions with implementation-defined values with the same type
```

The values in this test come from the "typical desktop processor" example in `A.3 Possible Data Type Implementations`.

https://github.com/llvm/llvm-project/pull/81207


More information about the cfe-commits mailing list