[clang] [CIR] Add custom assembly format for alloca op to fix flag parsing (PR #198962)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Sun May 24 01:47:02 PDT 2026
xlauko wrote:
> In that case we could keep the brackets as @erichkeane mentioned they stick out nicely, drop the commas between flags and use `oilist` as @xlauko suggested, and also move the alignment out of the attr-dict to make it look closer to `llvm.alloca` as @andykaylor suggested and consistent with `cir.store`:
>
> ```mlir
> %0 = cir.alloca !s32i, !cir.ptr<!s32i>, align(4) ["n" init const]
> ```
>
> does that look good to all of you or do you have other suggestions?
So to be more uniform, we usually put attributes before operands (see e.g. load/store), types should be represented "funtional type, so you distinguish operand types and return types, i.e. to be uniform with the rest of the dialect:
```mlir
%0 = cir.alloca "n" align(4) init const %size : !s32i -> !cir.ptr<!s32i>
```
% maybe different order of unitattribute alignemnt and name?
this follows convention of other dialects too, e.g.
```mlir
%0 = llvm.alloca inalloca %size x i32 : (i64) -> !llvm.ptr
```
I understand @erichkeane desire to make attributes more differentiable, but then question is why is alignment is at different place, why only this operation, why square brackets, which we use for "offset-like" information in other places? For newcomers and in general I find more valuable unsuprising choices.
https://github.com/llvm/llvm-project/pull/198962
More information about the cfe-commits
mailing list