[Mlir-commits] [mlir] [MLIR][NVVM] Declare InferIntRangeInterface for RangeableRegisterOp (PR #122263)
Christian Ulmann
llvmlistbot at llvm.org
Thu Jan 9 06:18:08 PST 2025
================
@@ -147,6 +148,21 @@ class NVVM_SpecialRangeableRegisterOp<string mnemonic, list<Trait> traits = []>
build($_builder, $_state, resultType, ::mlir::LLVM::ConstantRangeAttr{});
}]>
];
+
+ // Define this method for the InferIntRangeInterface.
+ let extraClassDefinition = [{
+ // Infer the result ranges based on the range attribute.
+ void $cppClass::inferResultRanges(
+ ArrayRef<::mlir::ConstantIntRanges> argRanges,
+ SetIntRangeFn setResultRanges) {
+ if (auto rangeAttr = getOperation()->getAttrOfType<LLVM::ConstantRangeAttr>("range")) {
+ setResultRanges(getResult(),
+ {rangeAttr.getLower(), rangeAttr.getUpper(),
+ rangeAttr.getLower(), rangeAttr.getUpper()});
+ }
+ }
+ }];
----------------
Dinistro wrote:
Nit: I would prefer if the implementation would be in cpp and that the tablegen part only contains a simple forwarding to said function. Dealing with C++ code implemented in tablegen can be annoying due to lacking LSP support.
https://github.com/llvm/llvm-project/pull/122263
More information about the Mlir-commits
mailing list