================ @@ -2896,6 +2898,68 @@ 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)); + + cir::AsmFlavor dialect = op.getAsmFlavor(); + mlir::LLVM::AsmDialect llDialect = dialect == cir::AsmFlavor::x86_att + ? mlir::LLVM::AsmDialect::AD_ATT + : mlir::LLVM::AsmDialect::AD_Intel; + + SmallVector<mlir::Attribute> opAttrs; + StringRef 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; + for (auto [llvmOp, cirOp] : + llvm::zip(adaptor.getAsmOperands(), op.getAsmOperands())) { + llvmOperands.append(llvmOp.begin(), llvmOp.end()); + cirOperands.append(cirOp.begin(), cirOp.end()); + } + + // so far we infer the llvm dialect element type attr from + // CIR operand type. + for (auto [i, cirOpAttr] : llvm::enumerate(op.getOperandAttrs())) { ---------------- mmha wrote:
```suggestion for (auto const&[cirOpAttr, cirOp] : zip(op.getOperandAttrs(), cirOperands)) { ``` https://github.com/llvm/llvm-project/pull/153387 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits