[clang] [clang][Interp] Implement __builtin_bit_cast (PR #68288)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 26 10:41:05 PDT 2023


Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>,
Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm/llvm-project/pull/68288/clang at github.com>


================
@@ -66,6 +67,12 @@ class Boolean final {
   Boolean toUnsigned() const { return *this; }
 
   constexpr static unsigned bitWidth() { return 1; }
+  constexpr static unsigned objectReprBits() { return 8; }
+  constexpr static unsigned valueReprBytes(const ASTContext &Ctx) { return 1; }
+  constexpr static unsigned valueReprBits(const ASTContext &Ctx) {
+    return 8;
+  } // FIXME: Is this correct?
----------------
AaronBallman wrote:

https://eel.is/c++draft/basic#fundamental-10 -- so it's implementation-defined how many bits are in the value representation; we default to 8 (https://github.com/llvm/llvm-project/blob/59750027b91000a56735d4f533225a3aeda996ce/clang/lib/Basic/TargetInfo.cpp#L72) and I didn't see any targets that use a different value.

I think we may need to use `TargetInfo` for these at some point so we're matching the target when constant evaluating on the host. But I think that can happen later.

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


More information about the cfe-commits mailing list