================
@@ -1823,10 +1819,11 @@ mlir::Attribute 
ConstantEmitter::emitForMemory(CIRGenModule &cgm,
     cgm.errorNYI("emitForMemory: zero-extend HLSL bool vectors");
   }
 
-  if (destType->isBitIntType()) {
-    cgm.errorNYI("emitForMemory: _BitInt type");
-  }
-
+  // CIR represents a _BitInt(N) value in memory at its exact width
----------------
adams381 wrote:

Confirmed at the byte level: `signed _BitInt(6) = -1` emits `0x3f` under 
`-fclangir` where classic/GCC write `0xff` (and `signed _BitInt(17) = -1` -> 
`ff ff 01 00` vs `ff ff ff ff`). The exact-width value reaches LLVM and the 
backend zero-fills the storage padding instead of sign-extending it; unsigned 
and non-negative values happen to match, which is why the value-level tests 
missed it.

This matches how `cir.bool` already works, so `return c` here is fine -- the 
gap is that lowering doesn't expand `_BitInt` yet. I'll add that to LowerToLLVM 
(`convertTypeForMemory` + `emitToMemory`/`emitFromMemory`, sign/zero-extending 
to the storage integer), erroring out on the long-`_BitInt` byte-array case for 
now instead of emitting wrong bytes, and rebuild the PR on that.

https://github.com/llvm/llvm-project/pull/205605
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to