[clang] [CIR] Add custom assembly format for alloca op to fix flag parsing (PR #198962)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 1 20:50:21 PDT 2026
================
@@ -653,13 +631,13 @@ def CIR_AllocaOp : CIR_Op<"alloca", [
}];
let assemblyFormat = [{
- $allocaType `,` qualified(type($addr)) `,`
+ $name
+ `align` `(` $alignment `)`
+ oilist( `init` $init
+ | `const` $constant
+ | `cleanup_dest_slot` $cleanup_dest_slot)
($dynAllocSize^ `:` type($dynAllocSize) `,`)?
- `[` $name
- (`,` `init` $init^)?
- (`,` `const` $constant^)?
- (`,` `cleanup_dest_slot` $cleanup_dest_slot^)?
- `]`
+ $allocaType `->` qualified(type($addr))
----------------
Andres-Salamanca wrote:
i tried a few things to drop the type of `dynAllocSize`:
- removing `type($dynAllocSize)` from the format gives: `error: type of operand #0, named 'dynAllocSize', is not buildable and a buildable type cannot be inferred`
- changing to `Optional<UI64>` gives: `error: 'cir.alloca' op operand #0 must be 64-bit unsigned integer, but got '!cir.int<u, 64'` since CIR uses `!cir.int<u, 64` which is different from the MLIR builtin `i64`
- changing to `Optional<CIR_IntType>` gives the same buildable type error
i also confirmed that in practice it's always `!u64i` from looking at the generated CIR. am i missing something here? if not i think we'd need to keep the type in the format:
`%1 = cir.alloca "n" align(4) init size(%sz : !u64i) : !cir.ptr<!s32i`
https://github.com/llvm/llvm-project/pull/198962
More information about the cfe-commits
mailing list