Skip to content

Commit bc060a6

Browse files
committed
extract function to c++
1 parent 1ba0517 commit bc060a6

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,7 @@ class NVVM_SpecialRangeableRegisterOp<string mnemonic> :
155155
void $cppClass::inferResultRanges(
156156
ArrayRef<::mlir::ConstantIntRanges> argRanges,
157157
SetIntRangeFn setResultRanges) {
158-
if (auto rangeAttr = getOperation()->getAttrOfType<LLVM::ConstantRangeAttr>("range")) {
159-
setResultRanges(getResult(),
160-
{rangeAttr.getLower(), rangeAttr.getUpper(),
161-
rangeAttr.getLower(), rangeAttr.getUpper()});
162-
}
158+
nvvmInferResultRanges(getOperation(), getResult(), argRanges, setResultRanges);
163159
}
164160
}];
165161

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,17 @@ llvm::Intrinsic::ID CpAsyncBulkTensorReduceOp::getIntrinsicID(
11581158
llvm_unreachable("Invalid Reduction Op for CpAsyncBulkTensorReduceOp");
11591159
}
11601160

1161+
/// Infer the result ranges for the NVVM SpecialRangeableRegisterOp that migth
1162+
/// have ConstantRangeAttr.
1163+
static void nvvmInferResultRanges(Operation *op, Value result,
1164+
ArrayRef<::mlir::ConstantIntRanges> argRanges,
1165+
SetIntRangeFn setResultRanges) {
1166+
if (auto rangeAttr = op->getAttrOfType<LLVM::ConstantRangeAttr>("range")) {
1167+
setResultRanges(result, {rangeAttr.getLower(), rangeAttr.getUpper(),
1168+
rangeAttr.getLower(), rangeAttr.getUpper()});
1169+
}
1170+
}
1171+
11611172
//===----------------------------------------------------------------------===//
11621173
// NVVMDialect initialization, type parsing, and registration.
11631174
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)