[clang] [NFC][HLSL] Cleanup TargetInfo handling (PR #90694)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Wed May 1 09:47:45 PDT 2024


================
@@ -406,6 +406,16 @@ void TargetInfo::adjust(DiagnosticsEngine &Diags, LangOptions &Opts) {
     LongDoubleAlign = 64;
   }
 
+  // HLSL explicitly defines the sizes and formats of some data types, and we
+  // need to conform to those regardless of what architecture you are targeting.
+  if (Opts.HLSL) {
+    LongWidth = LongAlign = 64;
+    if (!Opts.NativeHalfType) {
+      HalfFormat = &llvm::APFloat::IEEEsingle();
+      HalfWidth = HalfAlign = 32;
----------------
llvm-beanz wrote:

Yes, and I totally glossed over that this fixes a bug. Without this line `sizeof(half)` returns the wrong value.

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


More information about the cfe-commits mailing list