[llvm-branch-commits] [clang] [CIR] Add InlineAsmOp lowering to LLVM (PR #153387)
Iris Shi via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Aug 13 20:37:08 PDT 2025
================
@@ -2896,6 +2898,71 @@ mlir::LogicalResult CIRToLLVMGetBitfieldOpLowering::matchAndRewrite(
return mlir::success();
}
+mlir::LogicalResult CIRToLLVMInlineAsmOpLowering::matchAndRewrite(
+ cir::InlineAsmOp op, OpAdaptor adaptor,
+ mlir::ConversionPatternRewriter &rewriter) const {
+ mlir::Type llResTy;
+ if (op.getNumResults())
+ llResTy = getTypeConverter()->convertType(op.getType(0));
+
+ auto dialect = op.getAsmFlavor();
+ auto llDialect = dialect == cir::AsmFlavor::x86_att
+ ? mlir::LLVM::AsmDialect::AD_ATT
+ : mlir::LLVM::AsmDialect::AD_Intel;
+
+ SmallVector<mlir::Attribute> opAttrs;
+ auto llvmAttrName = mlir::LLVM::InlineAsmOp::getElementTypeAttrName();
+
+ // this is for the lowering to LLVM from LLVM dialect. Otherwise, if we
+ // don't have the result (i.e. void type as a result of operation), the
+ // element type attribute will be attached to the whole instruction, but not
+ // to the operand
+ if (!op.getNumResults())
+ opAttrs.push_back(mlir::Attribute());
+
+ SmallVector<mlir::Value> llvmOperands;
+ SmallVector<mlir::Value> cirOperands;
+ auto llvmAsmOps = adaptor.getAsmOperands();
+ auto cirAsmOps = op.getAsmOperands();
+ for (size_t i = 0; i < llvmAsmOps.size(); ++i) {
----------------
el-ev wrote:
Replaced this one with `llvm::zip` and the next with `llvm::enumerate`. Thanks.
https://github.com/llvm/llvm-project/pull/153387
More information about the llvm-branch-commits
mailing list