Skip to content

Commit 0e6a760

Browse files
el-evandykaylor
andcommitted
Apply review suggestions
Co-authored-by: Andy Kaylor <[email protected]>
1 parent 40788c8 commit 0e6a760

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,8 +2251,8 @@ def CIR_InlineAsmOp : CIR_Op<"asm", [RecursiveMemoryEffects]> {
22512251
let description = [{
22522252
The `cir.asm` operation represents C/C++ asm inline.
22532253

2254-
CIR constraints strings follow barely the same rules that are established
2255-
for the C level assembler constraints with several differences caused by
2254+
CIR constraints strings follow the same rules that are established for
2255+
the C level assembler constraints with several differences caused by
22562256
clang::AsmStmt processing.
22572257

22582258
Thus, numbers that appears in the constraint string may also refer to:
@@ -2262,11 +2262,9 @@ def CIR_InlineAsmOp : CIR_Op<"asm", [RecursiveMemoryEffects]> {
22622262
Operand attributes are a storage, where each element corresponds to the
22632263
operand with the same index. The first index relates to the operation
22642264
result (if any).
2265-
Note, the operands themselves are stored as VariadicOfVariadic in the next
2266-
order: output, input and then in/out operands.
2267-
2268-
Note, when several output operands are present, the result type may be
2269-
represented as an anon record type.
2265+
The operands themselves are stored as VariadicOfVariadic in the following
2266+
order: output, input and then in/out operands. When several output operands
2267+
are present, the result type may be represented as an anonymous record type.
22702268

22712269
Example:
22722270
```C++

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2419,7 +2419,7 @@ void cir::InlineAsmOp::print(OpAsmPrinter &p) {
24192419
auto *nameIt = names.begin();
24202420
auto *attrIt = getOperandAttrs().begin();
24212421

2422-
for (auto ops : getAsmOperands()) {
2422+
for (mlir::OperandRange ops : getAsmOperands()) {
24232423
p << *nameIt << " = ";
24242424

24252425
p << '[';
@@ -2491,7 +2491,7 @@ ParseResult cir::InlineAsmOp::parse(OpAsmParser &parser,
24912491
llvm::SmallVector<int32_t> operandsGroupSizes;
24922492
std::string asmString, constraints;
24932493
Type resType;
2494-
auto *ctxt = parser.getBuilder().getContext();
2494+
MLIRContext *ctxt = parser.getBuilder().getContext();
24952495

24962496
auto error = [&](const Twine &msg) -> LogicalResult {
24972497
return parser.emitError(parser.getCurrentLocation(), msg);
@@ -2515,7 +2515,7 @@ ParseResult cir::InlineAsmOp::parse(OpAsmParser &parser,
25152515
OpAsmParser::UnresolvedOperand op;
25162516

25172517
if (parser.parseOperand(op) || parser.parseColon())
2518-
return mlir::failure();
2518+
return error("can't parse operand");
25192519

25202520
Type typ;
25212521
if (parser.parseType(typ).failed())
@@ -2543,26 +2543,30 @@ ParseResult cir::InlineAsmOp::parse(OpAsmParser &parser,
25432543
return mlir::success();
25442544
}
25452545

2546-
if (parser.parseCommaSeparatedList([&]() {
2547-
Value val;
2548-
if (parseValue(val).succeeded()) {
2549-
result.operands.push_back(val);
2550-
size++;
2551-
2552-
if (parser.parseOptionalLParen().failed()) {
2553-
operandAttrs.push_back(mlir::Attribute());
2554-
return mlir::success();
2555-
}
2556-
2557-
if (parser.parseKeyword("maybe_memory").succeeded()) {
2558-
operandAttrs.push_back(mlir::UnitAttr::get(ctxt));
2559-
if (parser.parseRParen())
2560-
return expected(")");
2561-
return mlir::success();
2562-
}
2563-
}
2564-
return mlir::failure();
2565-
}))
2546+
auto parseOperand = [&]() {
2547+
Value val;
2548+
if (parseValue(val).succeeded()) {
2549+
result.operands.push_back(val);
2550+
size++;
2551+
2552+
if (parser.parseOptionalLParen().failed()) {
2553+
operandAttrs.push_back(mlir::Attribute());
2554+
return mlir::success();
2555+
}
2556+
2557+
if (parser.parseKeyword("maybe_memory").succeeded()) {
2558+
operandAttrs.push_back(mlir::UnitAttr::get(ctxt));
2559+
if (parser.parseRParen())
2560+
return expected(")");
2561+
return mlir::success();
2562+
} else {
2563+
return expected("maybe_memory");
2564+
}
2565+
}
2566+
return mlir::failure();
2567+
};
2568+
2569+
if (parser.parseCommaSeparatedList(parseOperand).failed())
25662570
return mlir::failure();
25672571

25682572
if (parser.parseRSquare().failed() || parser.parseComma().failed())

0 commit comments

Comments
 (0)