[Mlir-commits] [mlir] [mlir][LLVM] Support `immargs` in LLVM_IntrOpBase intrinsics (PR #73013)

Benjamin Maxwell llvmlistbot at llvm.org
Wed Nov 22 03:56:45 PST 2023


================
@@ -1199,6 +1199,45 @@ ModuleImport::convertValues(ArrayRef<llvm::Value *> values) {
   return remapped;
 }
 
+LogicalResult mlir::LLVM::detail::convertIntrinsicArguments(
+    ModuleImport &moduleInport, ArrayRef<llvm::Value *> values,
+    ArrayRef<unsigned> immArgPositions, ArrayRef<StringLiteral> immArgAttrNames,
+    SmallVectorImpl<Value> &valuesOut,
+    SmallVectorImpl<NamedAttribute> &attrsOut) {
+
+  assert(immArgPositions.size() == immArgAttrNames.size() &&
+         "LLVM `immArgPositions` and MLIR `immArgAttrNames` should have equal "
+         "length");
+
+  auto maybeMlirValues = moduleInport.convertValues(values);
----------------
MacDue wrote:

Good point, I've switched this to use `getScalarConstantAsAttr()` now, which goes directly to an MLIR attribute without creating any constant ops. This also removes one redundant constant from a test case (since the previous attribute import logic did also created redundant constant ops). 

https://github.com/llvm/llvm-project/pull/73013


More information about the Mlir-commits mailing list