[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)
Momchil Velikov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 10 08:08:01 PDT 2024
================
@@ -1886,6 +1896,29 @@ llvm::Constant *ConstantEmitter::emitForMemory(CodeGenModule &CGM,
return Res;
}
+ if (destType->isBitIntType()) {
+ if (CGM.getTypes().typeRequiresSplitIntoByteArray(destType, C->getType())) {
+ // Long _BitInt has array of bytes as in-memory type.
+ // So, split constant into individual bytes.
+ ConstantAggregateBuilder Builder(CGM);
+ llvm::Type *DesiredTy = CGM.getTypes().ConvertTypeForMem(destType);
+ llvm::Type *LoadStoreTy =
----------------
momchil-velikov wrote:
It would seem instead of invoking `convertTypeForLoadStore` we could use the bit width of the in-memory type and sign-/zero- extend the `APInt Value`, something like.
```
llvm::APInt Value;
if destType is unsigned
Value = CI->getValue().zext(Width);
else
Value = CI->getValue().sext(Width);
```
https://github.com/llvm/llvm-project/pull/91364
More information about the cfe-commits
mailing list