Skip to content

Commit 0282e28

Browse files
el-evandykaylor
andcommitted
Apply review suggestions
Co-authored-by: Andy Kaylor <[email protected]>
1 parent 8e86b93 commit 0282e28

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
@@ -2266,8 +2266,8 @@ def CIR_InlineAsmOp : CIR_Op<"asm", [RecursiveMemoryEffects]> {
22662266
let description = [{
22672267
The `cir.asm` operation represents C/C++ asm inline.
22682268

2269-
CIR constraints strings follow barely the same rules that are established
2270-
for the C level assembler constraints with several differences caused by
2269+
CIR constraints strings follow the same rules that are established for
2270+
the C level assembler constraints with several differences caused by
22712271
clang::AsmStmt processing.
22722272

22732273
Thus, numbers that appears in the constraint string may also refer to:
@@ -2277,11 +2277,9 @@ def CIR_InlineAsmOp : CIR_Op<"asm", [RecursiveMemoryEffects]> {
22772277
Operand attributes are a storage, where each element corresponds to the
22782278
operand with the same index. The first index relates to the operation
22792279
result (if any).
2280-
Note, the operands themselves are stored as VariadicOfVariadic in the next
2281-
order: output, input and then in/out operands.
2282-
2283-
Note, when several output operands are present, the result type may be
2284-
represented as an anon record type.
2280+
The operands themselves are stored as VariadicOfVariadic in the following
2281+
order: output, input and then in/out operands. When several output operands
2282+
are present, the result type may be represented as an anonymous record type.
22852283

22862284
Example:
22872285
```C++

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

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

2435-
for (auto ops : getAsmOperands()) {
2435+
for (mlir::OperandRange ops : getAsmOperands()) {
24362436
p << *nameIt << " = ";
24372437

24382438
p << '[';
@@ -2504,7 +2504,7 @@ ParseResult cir::InlineAsmOp::parse(OpAsmParser &parser,
25042504
llvm::SmallVector<int32_t> operandsGroupSizes;
25052505
std::string asmString, constraints;
25062506
Type resType;
2507-
auto *ctxt = parser.getBuilder().getContext();
2507+
MLIRContext *ctxt = parser.getBuilder().getContext();
25082508

25092509
auto error = [&](const Twine &msg) -> LogicalResult {
25102510
return parser.emitError(parser.getCurrentLocation(), msg);
@@ -2528,7 +2528,7 @@ ParseResult cir::InlineAsmOp::parse(OpAsmParser &parser,
25282528
OpAsmParser::UnresolvedOperand op;
25292529

25302530
if (parser.parseOperand(op) || parser.parseColon())
2531-
return mlir::failure();
2531+
return error("can't parse operand");
25322532

25332533
Type typ;
25342534
if (parser.parseType(typ).failed())
@@ -2556,26 +2556,30 @@ ParseResult cir::InlineAsmOp::parse(OpAsmParser &parser,
25562556
return mlir::success();
25572557
}
25582558

2559-
if (parser.parseCommaSeparatedList([&]() {
2560-
Value val;
2561-
if (parseValue(val).succeeded()) {
2562-
result.operands.push_back(val);
2563-
size++;
2564-
2565-
if (parser.parseOptionalLParen().failed()) {
2566-
operandAttrs.push_back(mlir::Attribute());
2567-
return mlir::success();
2568-
}
2569-
2570-
if (parser.parseKeyword("maybe_memory").succeeded()) {
2571-
operandAttrs.push_back(mlir::UnitAttr::get(ctxt));
2572-
if (parser.parseRParen())
2573-
return expected(")");
2574-
return mlir::success();
2575-
}
2576-
}
2577-
return mlir::failure();
2578-
}))
2559+
auto parseOperand = [&]() {
2560+
Value val;
2561+
if (parseValue(val).succeeded()) {
2562+
result.operands.push_back(val);
2563+
size++;
2564+
2565+
if (parser.parseOptionalLParen().failed()) {
2566+
operandAttrs.push_back(mlir::Attribute());
2567+
return mlir::success();
2568+
}
2569+
2570+
if (parser.parseKeyword("maybe_memory").succeeded()) {
2571+
operandAttrs.push_back(mlir::UnitAttr::get(ctxt));
2572+
if (parser.parseRParen())
2573+
return expected(")");
2574+
return mlir::success();
2575+
} else {
2576+
return expected("maybe_memory");
2577+
}
2578+
}
2579+
return mlir::failure();
2580+
};
2581+
2582+
if (parser.parseCommaSeparatedList(parseOperand).failed())
25792583
return mlir::failure();
25802584

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

0 commit comments

Comments
 (0)