Skip to content

Commit abcff7b

Browse files
[CIR][NFC] Change GetMemberOp index type (#1811)
This PR is inspired by the discussion in #1745 (comment). When changing the type of ```mlir IndexAttr:$index, I64Attr:$index ``` in `GetMemberOp`, the `getIndex` method becomes auto-generated. This allows us to remove the custom builder previously defined for this operation.
1 parent bd6318e commit abcff7b

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,29 +2962,16 @@ def CIR_GetMemberOp : CIR_Op<"get_member"> {
29622962
let arguments = (ins
29632963
Arg<CIR_PointerType, "the address to load from", [MemRead]>:$addr,
29642964
StrAttr:$name,
2965-
IndexAttr:$index_attr);
2965+
I64Attr:$index);
29662966

29672967
let results = (outs Res<CIR_PointerType, "">:$result);
29682968

29692969
let assemblyFormat = [{
2970-
$addr `[` $index_attr `]` attr-dict
2970+
$addr `[` $index `]` attr-dict
29712971
`:` qualified(type($addr)) `->` qualified(type($result))
29722972
}];
29732973

2974-
let builders = [
2975-
OpBuilder<(ins "mlir::Type":$type,
2976-
"mlir::Value":$value,
2977-
"llvm::StringRef":$name,
2978-
"unsigned":$index),
2979-
[{
2980-
mlir::APInt fieldIdx(64, index);
2981-
build($_builder, $_state, type, value, name, fieldIdx);
2982-
}]>
2983-
];
2984-
29852974
let extraClassDeclaration = [{
2986-
/// Return the index of the record member being accessed.
2987-
uint64_t getIndex() { return getIndexAttr().getZExtValue(); }
29882975

29892976
/// Return the record type pointed by the base pointer.
29902977
cir::PointerType getAddrTy() { return getAddr().getType(); }

0 commit comments

Comments
 (0)