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

via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 5 10:39:31 PST 2024


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


https://github.com/sethp commented:

Thanks for your work on this! I enjoyed getting a chance to learn more about `Interp`, and though I'm not super familiar with C++ (the language or compiler internals), there definitely seems to be more than a few lessons learned from the `ExprConstant` evaluator in here. Kudos!

I did learn a lot about implementing bit-casts as part of #74775 , especially as they relate to bit-fields and endian-ness, and I tried to relay some of those lessons here. I'd recommend checking out the updated tests, I went into some detail describing the behavior of bit-precise types, booleans, and bit-fields (as well as the intersection between all three). 

The latest tests covering booleans & bit fields from my branch are at: https://github.com/llvm/llvm-project/blob/2e0d3f81e4f5b623bb476bfac0278cfc6d1bd4bc/clang/test/SemaCXX/constexpr-builtin-bit-cast.cpp

My system's `clang` (especially `clangd`) doesn't particularly love the `_BitInt(X)` stuff, so I split that out into its own file: https://github.com/llvm/llvm-project/blob/2e0d3f81e4f5b623bb476bfac0278cfc6d1bd4bc/clang/test/SemaCXX/constexpr-builtin-bit-cast-bitint.cpp

I hope that's helpful!

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


More information about the cfe-commits mailing list