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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 12:35:07 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
----------------
AaronBallman wrote:

Values from TR 18037:2008 are:
```
USFRACT_FBIT 7
USFRACT_MAX 0.9921875UHR
USFRACT_EPSILON 0.0078125UHR
```
The values are conforming though different, just checking whether this is intentional given that `SFRACT` are using the identical values from the TR (this same thing happens with all the other `unsigned` variants).

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


More information about the cfe-commits mailing list