[clang] [clang] Add `__bf16` Type Support Macros With Literal Suffix Support (PR #134214)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 4 01:52:55 PDT 2025
================
@@ -978,6 +979,28 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
// we break out of the loop.
for (; s != ThisTokEnd; ++s) {
switch (*s) {
+ case 'b':
+ case 'B':
+ if (!isFPConstant)
+ break; // Error for integer constant.
+ if (isBFloat16)
+ break;
+ if (!Target.hasBFloat16Type())
+ break;
+ if (HasSize)
+ break;
+ HasSize = true;
+
+ if ((Target.hasBFloat16Type() || LangOpts.CUDA ||
+ (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())) &&
----------------
overmighty wrote:
We might not need to check for `LangOpts.CUDA || (LangOpts.OpenMPIsTargetDevice && Target.getTriple().isNVPTX())` in our case:
https://github.com/llvm/llvm-project/blob/9eb7e64145f66f59f07edffb4f9c8a648174543e/clang/lib/Basic/Targets/NVPTX.h#L202
I'm not sure why it was needed for `f16` literals.
https://github.com/llvm/llvm-project/pull/134214
More information about the cfe-commits
mailing list