[flang-commits] [flang] [mlir] [Flang][MLIR][OpenMP] Add support for target-cpu and target-features (PR #75344)

Benjamin Maxwell via flang-commits flang-commits at lists.llvm.org
Wed Dec 13 07:41:56 PST 2023


================
@@ -379,6 +381,19 @@ mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
     newFuncOp.setMemoryAttr(memoryAttr);
   }
 
+  // Create target_features attribute.
+  if (funcOp->hasAttr(targetFeaturesAttrName)) {
+    auto attr = funcOp->getAttrOfType<StringAttr>(targetFeaturesAttrName);
+    if (!attr) {
+      funcOp->emitError() << "Contains " << targetFeaturesAttrName
+                          << " attribute not of type StringAttr";
+      return rewriter.notifyMatchFailure(
+          funcOp, "Contains target features attribute not of type StringAttr");
+    }
+    newFuncOp.setTargetFeaturesAttr(
+        LLVM::TargetFeaturesAttr::get(rewriter.getContext(), attr.strref()));
+  }
----------------
MacDue wrote:

Just wondering, why make this a `StringAttr` rather than a `LLVM::TargetFeaturesAttr`? I see for other attributes (e.g. `llvm.linkage`) the corresponding LLVM dialect attribute type is used. 

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


More information about the flang-commits mailing list