================
@@ -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
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to