[clang] [llvm] [clang] Add fixed point precision macros (PR #81207)
Aaron Ballman via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 13 12:35:07 PST 2024
================
@@ -1097,6 +1150,47 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
TI.getTypeWidth(TI.getIntMaxType()) &&
"uintmax_t and intmax_t have different widths?");
+ if (LangOpts.FixedPoint) {
+ // Each unsigned type has the same width as their signed type.
+ DefineFixedPointMacros(TI, Builder, "SFRACT", "hr", TI.getShortFractWidth(),
+ TI.getShortFractScale(), /*Signed=*/true);
+ DefineFixedPointMacros(TI, Builder, "USFRACT", "uhr",
+ TI.getShortFractWidth(),
+ TI.getUnsignedShortFractScale(), /*Signed=*/false);
+ DefineFixedPointMacros(TI, Builder, "FRACT", "r", TI.getFractWidth(),
+ TI.getFractScale(), /*Signed=*/true);
+ DefineFixedPointMacros(TI, Builder, "UFRACT", "ur", TI.getFractWidth(),
+ TI.getUnsignedFractScale(), /*Signed=*/false);
+ DefineFixedPointMacros(TI, Builder, "LFRACT", "lr", TI.getLongFractWidth(),
----------------
AaronBallman wrote:
Slight preference for using `L` instead of `l` because of font problems where the `l` may look like a `1`. Might be worth making them use the uppercase suffix consistently.
https://github.com/llvm/llvm-project/pull/81207
More information about the llvm-commits
mailing list