Skip to content

Commit 0b5b910

Browse files
committed
Apply review suggestions
1 parent 963cf44 commit 0b5b910

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,13 +2914,13 @@ mlir::LogicalResult CIRToLLVMInlineAsmOpLowering::matchAndRewrite(
29142914
if (op.getNumResults())
29152915
llResTy = getTypeConverter()->convertType(op.getType(0));
29162916

2917-
auto dialect = op.getAsmFlavor();
2918-
auto llDialect = dialect == cir::AsmFlavor::x86_att
2919-
? mlir::LLVM::AsmDialect::AD_ATT
2920-
: mlir::LLVM::AsmDialect::AD_Intel;
2917+
cir::AsmFlavor dialect = op.getAsmFlavor();
2918+
mlir::LLVM::AsmDialect llDialect = dialect == cir::AsmFlavor::x86_att
2919+
? mlir::LLVM::AsmDialect::AD_ATT
2920+
: mlir::LLVM::AsmDialect::AD_Intel;
29212921

29222922
SmallVector<mlir::Attribute> opAttrs;
2923-
auto llvmAttrName = mlir::LLVM::InlineAsmOp::getElementTypeAttrName();
2923+
StringRef llvmAttrName = mlir::LLVM::InlineAsmOp::getElementTypeAttrName();
29242924

29252925
// this is for the lowering to LLVM from LLVM dialect. Otherwise, if we
29262926
// don't have the result (i.e. void type as a result of operation), the
@@ -2931,31 +2931,28 @@ mlir::LogicalResult CIRToLLVMInlineAsmOpLowering::matchAndRewrite(
29312931

29322932
SmallVector<mlir::Value> llvmOperands;
29332933
SmallVector<mlir::Value> cirOperands;
2934-
auto llvmAsmOps = adaptor.getAsmOperands();
2935-
auto cirAsmOps = op.getAsmOperands();
2936-
for (size_t i = 0; i < llvmAsmOps.size(); ++i) {
2937-
auto llvmOps = llvmAsmOps[i];
2938-
auto cirOps = cirAsmOps[i];
2939-
llvmOperands.append(llvmOps.begin(), llvmOps.end());
2940-
cirOperands.append(cirOps.begin(), cirOps.end());
2934+
for (auto [llvmOp, cirOp] :
2935+
llvm::zip(adaptor.getAsmOperands(), op.getAsmOperands())) {
2936+
llvmOperands.append(llvmOp.begin(), llvmOp.end());
2937+
cirOperands.append(cirOp.begin(), cirOp.end());
29412938
}
29422939

29432940
// so far we infer the llvm dialect element type attr from
29442941
// CIR operand type.
2945-
auto cirOpAttrs = op.getOperandAttrs();
2946-
for (std::size_t i = 0; i < cirOpAttrs.size(); ++i) {
2947-
if (!cirOpAttrs[i]) {
2942+
for (auto [i, cirOpAttr] : llvm::enumerate(op.getOperandAttrs())) {
2943+
if (!cirOpAttr) {
29482944
opAttrs.push_back(mlir::Attribute());
29492945
continue;
29502946
}
29512947

29522948
SmallVector<mlir::NamedAttribute> attrs;
2953-
auto typ = cast<cir::PointerType>(cirOperands[i].getType());
2954-
auto typAttr = mlir::TypeAttr::get(convertTypeForMemory(
2949+
cir::PointerType typ =
2950+
mlir::cast<cir::PointerType>(cirOperands[i].getType());
2951+
mlir::TypeAttr typAttr = mlir::TypeAttr::get(convertTypeForMemory(
29552952
*getTypeConverter(), dataLayout, typ.getPointee()));
29562953

29572954
attrs.push_back(rewriter.getNamedAttr(llvmAttrName, typAttr));
2958-
auto newDict = rewriter.getDictionaryAttr(attrs);
2955+
mlir::DictionaryAttr newDict = rewriter.getDictionaryAttr(attrs);
29592956
opAttrs.push_back(newDict);
29602957
}
29612958

0 commit comments

Comments
 (0)