Skip to content

Commit ae442d1

Browse files
committed
add getter
1 parent 83a8b2b commit ae442d1

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,10 @@ def LLVM_TBAATagArrayAttr
10951095
//===----------------------------------------------------------------------===//
10961096

10971097
def LLVM_ConstantRangeAttr : LLVM_Attr<"ConstantRange", "constant_range"> {
1098-
let parameters = (ins "::llvm::APInt":$lower, "::llvm::APInt":$upper);
1098+
let parameters = (ins
1099+
"::llvm::APInt":$lower,
1100+
"::llvm::APInt":$upper
1101+
);
10991102
let summary = "A range of two integers, corresponding to LLVM's ConstantRange";
11001103
let description = [{
11011104
A pair of two integers, mapping to the ConstantRange structure in LLVM IR,
@@ -1117,6 +1120,15 @@ def LLVM_ConstantRangeAttr : LLVM_Attr<"ConstantRange", "constant_range"> {
11171120
return $_get($_ctxt, ::llvm::APInt(bitWidth, lower), ::llvm::APInt(bitWidth, upper));
11181121
}]>
11191122
];
1123+
/*let extraClassDeclaration = [{
1124+
::llvm::APInt getLower() const {
1125+
return getImpl()->getLower();
1126+
}
1127+
::llvm::APInt getUpper() const {
1128+
return getImpl()->getUpper();
1129+
}
1130+
}];*/
1131+
11201132

11211133
let hasCustomAssemblyFormat = 1;
11221134
let genVerifyDecl = 1;

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrs.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ struct ConstantRangeAttrStorage : public AttributeStorage {
6565
return KeyTy(lower, upper);
6666
}
6767

68+
llvm::APInt getLower() const { return lower; }
69+
llvm::APInt getUpper() const { return upper; }
70+
6871
/// The parametric data held by the storage class.
6972
llvm::APInt lower;
7073
llvm::APInt upper;

mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,14 @@ DIRecursiveTypeAttrInterface DISubprogramAttr::getRecSelf(DistinctAttr recId) {
257257
// ConstantRangeAttr
258258
//===----------------------------------------------------------------------===//
259259

260+
llvm::APInt ConstantRangeAttr::getLower() const {
261+
return getImpl()->getLower();
262+
}
263+
264+
llvm::APInt ConstantRangeAttr::getUpper() const {
265+
return getImpl()->getUpper();
266+
}
267+
260268
Attribute ConstantRangeAttr::parse(AsmParser &parser, Type odsType) {
261269
llvm::SMLoc loc = parser.getCurrentLocation();
262270
IntegerType widthType;

0 commit comments

Comments
 (0)