[mlir][LLVM] Plumb range attributes on parameters and results through (#117801)

We've had the ability to define LLVM's `range` attribute through
 #llvm.constant_range for some time, and have used this for some GPU
intrinsics. This commit allows using `llvm.range` as a parameter or
result attribute on function declarations and definitions.
This commit is contained in:
Krzysztof Drewniak
2024-11-27 12:31:51 -06:00
committed by GitHub
parent 1bc9de2474
commit 92a15dd748
6 changed files with 32 additions and 3 deletions

View File

@@ -1581,7 +1581,12 @@ ModuleTranslation::convertParameterAttrs(LLVMFuncOp func, int argIdx,
.Case<IntegerAttr>([&](auto intAttr) {
attrBuilder.addRawIntAttr(llvmKind, intAttr.getInt());
})
.Case<UnitAttr>([&](auto) { attrBuilder.addAttribute(llvmKind); });
.Case<UnitAttr>([&](auto) { attrBuilder.addAttribute(llvmKind); })
.Case<LLVM::ConstantRangeAttr>([&](auto rangeAttr) {
attrBuilder.addConstantRangeAttr(
llvmKind, llvm::ConstantRange(rangeAttr.getLower(),
rangeAttr.getUpper()));
});
} else if (namedAttr.getNameDialect()) {
if (failed(iface.convertParameterAttr(func, argIdx, namedAttr, *this)))
return failure();