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);
99 if (
auto gpuFunc = op->template getParentOfType<gpu::GPUFuncOp>()) {
102 funcBounds = gpuFunc.getKnownBlockSizeAttr();
105 funcBounds = gpuFunc.getKnownGridSizeAttr();
111 std::optional<int32_t> upperBound;
114 funcBounds.
asArrayRef()[
static_cast<uint32_t
>(op.getDimension())];
115 if (
auto opBound = op.getUpperBound())
116 upperBound = opBound->getZExtValue();
120 int32_t
max = *upperBound == std::numeric_limits<int32_t>::max()
123 newOp->
setAttr(
"range", LLVM::ConstantRangeAttr::get(
124 rewriter.getContext(), 32,
min,
max));
126 if (indexBitwidth > 32) {
127 newOp = LLVM::SExtOp::create(rewriter, loc,
128 IntegerType::get(context, indexBitwidth),
130 }
else if (indexBitwidth < 32) {
131 newOp = LLVM::TruncOp::create(rewriter, loc,
132 IntegerType::get(context, indexBitwidth),