Skip to content

Commit d34c423

Browse files
committed
Fix parser
1 parent b3ba450 commit d34c423

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

mlir/lib/Dialect/AMDGPU/IR/AMDGPUDialect.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,22 @@ struct AMDGPUInlinerInterface final : DialectInlinerInterface {
5252

5353
static ParseResult
5454
parseDynamicIndex(OpAsmParser &parser,
55-
std::optional<OpAsmParser::UnresolvedOperand> dynamicSize,
55+
std::optional<OpAsmParser::UnresolvedOperand> &dynamicSize,
5656
IntegerAttr &staticSize) {
5757

58-
int64_t staticVal = 0;
59-
if (parser.parseOptionalInteger(staticVal).has_value()) {
58+
int64_t staticVal;
59+
OptionalParseResult parseResult = parser.parseOptionalInteger(staticVal);
60+
if (parseResult.has_value()) {
6061
staticSize = parser.getBuilder().getIndexAttr(staticVal);
6162
return success();
6263
}
63-
64-
return parser.parseOperand(dynamicSize.value());
64+
65+
OpAsmParser::UnresolvedOperand operand = OpAsmParser::UnresolvedOperand{};
66+
if (parser.parseOperand(operand)) {
67+
dynamicSize = operand;
68+
return success();
69+
}
70+
return failure();
6571
}
6672

6773
static void printDynamicIndex(OpAsmPrinter &printer, Operation *op,

mlir/test/Dialect/AMDGPU/ops.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ func.func @make_dma_descriptor(%base: !amdgpu.tdm_base<i32>, %barrier: memref<8x
730730
globalStride [1]
731731
// CHECK-SAME: sharedSize [0]
732732
sharedSize [0]
733-
// CHECK-SAME: padShared(1 every 1)
733+
// CHECK-SAME: padShared(%[[IDX]] every %[[IDX]])
734734
padShared(%idx every %idx)
735735
: !amdgpu.tdm_base<i32> -> !amdgpu.tdm_descriptor
736736

0 commit comments

Comments
 (0)