Skip to content

Commit ecea64a

Browse files
committed
Apply review suggestions
1 parent 5fd1ca8 commit ecea64a

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
@@ -2905,13 +2905,13 @@ mlir::LogicalResult CIRToLLVMInlineAsmOpLowering::matchAndRewrite(
29052905
if (op.getNumResults())
29062906
llResTy = getTypeConverter()->convertType(op.getType(0));
29072907

2908-
auto dialect = op.getAsmFlavor();
2909-
auto llDialect = dialect == cir::AsmFlavor::x86_att
2910-
? mlir::LLVM::AsmDialect::AD_ATT
2911-
: mlir::LLVM::AsmDialect::AD_Intel;
2908+
cir::AsmFlavor dialect = op.getAsmFlavor();
2909+
mlir::LLVM::AsmDialect llDialect = dialect == cir::AsmFlavor::x86_att
2910+
? mlir::LLVM::AsmDialect::AD_ATT
2911+
: mlir::LLVM::AsmDialect::AD_Intel;
29122912

29132913
SmallVector<mlir::Attribute> opAttrs;
2914-
auto llvmAttrName = mlir::LLVM::InlineAsmOp::getElementTypeAttrName();
2914+
StringRef llvmAttrName = mlir::LLVM::InlineAsmOp::getElementTypeAttrName();
29152915

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

29232923
SmallVector<mlir::Value> llvmOperands;
29242924
SmallVector<mlir::Value> cirOperands;
2925-
auto llvmAsmOps = adaptor.getAsmOperands();
2926-
auto cirAsmOps = op.getAsmOperands();
2927-
for (size_t i = 0; i < llvmAsmOps.size(); ++i) {
2928-
auto llvmOps = llvmAsmOps[i];
2929-
auto cirOps = cirAsmOps[i];
2930-
llvmOperands.append(llvmOps.begin(), llvmOps.end());
2931-
cirOperands.append(cirOps.begin(), cirOps.end());
2925+
for (auto [llvmOp, cirOp] :
2926+
llvm::zip(adaptor.getAsmOperands(), op.getAsmOperands())) {
2927+
llvmOperands.append(llvmOp.begin(), llvmOp.end());
2928+
cirOperands.append(cirOp.begin(), cirOp.end());
29322929
}
29332930

29342931
// so far we infer the llvm dialect element type attr from
29352932
// CIR operand type.
2936-
auto cirOpAttrs = op.getOperandAttrs();
2937-
for (std::size_t i = 0; i < cirOpAttrs.size(); ++i) {
2938-
if (!cirOpAttrs[i]) {
2933+
for (auto [i, cirOpAttr] : llvm::enumerate(op.getOperandAttrs())) {
2934+
if (!cirOpAttr) {
29392935
opAttrs.push_back(mlir::Attribute());
29402936
continue;
29412937
}
29422938

29432939
SmallVector<mlir::NamedAttribute> attrs;
2944-
auto typ = cast<cir::PointerType>(cirOperands[i].getType());
2945-
auto typAttr = mlir::TypeAttr::get(convertTypeForMemory(
2940+
cir::PointerType typ =
2941+
mlir::cast<cir::PointerType>(cirOperands[i].getType());
2942+
mlir::TypeAttr typAttr = mlir::TypeAttr::get(convertTypeForMemory(
29462943
*getTypeConverter(), dataLayout, typ.getPointee()));
29472944

29482945
attrs.push_back(rewriter.getNamedAttr(llvmAttrName, typAttr));
2949-
auto newDict = rewriter.getDictionaryAttr(attrs);
2946+
mlir::DictionaryAttr newDict = rewriter.getDictionaryAttr(attrs);
29502947
opAttrs.push_back(newDict);
29512948
}
29522949

0 commit comments

Comments
 (0)