56 ConversionPatternRewriter &rewriter)
const override {
60 switch (op.getDimension()) {
61 case gpu::Dimension::x:
62 newOp = XOp::create(rewriter, loc, IntegerType::get(context, 32));
64 case gpu::Dimension::y:
65 newOp = YOp::create(rewriter, loc, IntegerType::get(context, 32));
67 case gpu::Dimension::z:
68 newOp = ZOp::create(rewriter, loc, IntegerType::get(context, 32));
79 if (
auto funcOp = op->template getParentOfType<FunctionOpInterface>()) {
83 gpu::GPUDialect::KnownBlockSizeAttrHelper(op.
getContext());
84 if (blockHelper.isAttrPresent(funcOp))
85 funcBounds = blockHelper.getAttr(funcOp);
90 gpu::GPUDialect::KnownGridSizeAttrHelper(op.
getContext());
91 if (gridHelper.isAttrPresent(funcOp))
92 funcBounds = gridHelper.getAttr(funcOp);
97 gpu::GPUDialect::KnownClusterSizeAttrHelper(op.
getContext());
98 if (clusterHelper.isAttrPresent(funcOp))
99 funcBounds = clusterHelper.getAttr(funcOp);
106 if (
auto gpuFunc = op->template getParentOfType<gpu::GPUFuncOp>()) {
109 funcBounds = gpuFunc.getKnownBlockSizeAttr();
112 funcBounds = gpuFunc.getKnownGridSizeAttr();
115 funcBounds = gpuFunc.getKnownClusterSizeAttr();
121 std::optional<int32_t> upperBound;
124 funcBounds.
asArrayRef()[
static_cast<uint32_t
>(op.getDimension())];
125 if (
auto opBound = op.getUpperBound())
126 upperBound = opBound->getZExtValue();
130 int32_t
max = *upperBound == std::numeric_limits<int32_t>::max()
133 newOp->
setAttr(
"range", LLVM::ConstantRangeAttr::get(
134 rewriter.getContext(), 32,
min,
max));
136 if (indexBitwidth > 32) {
137 newOp = LLVM::SExtOp::create(rewriter, loc,
138 IntegerType::get(context, indexBitwidth),
140 }
else if (indexBitwidth < 32) {
141 newOp = LLVM::TruncOp::create(rewriter, loc,
142 IntegerType::get(context, indexBitwidth),