[Mlir-commits] [mlir] [mlir][interfaces] Add the `TargetInfo` attribute interface (PR #78073)

Mehdi Amini llvmlistbot at llvm.org
Sun Apr 20 06:02:03 PDT 2025


================
@@ -800,3 +815,28 @@ NVVMTargetAttrImpl::createObject(Attribute attribute, Operation *module,
       builder.getStringAttr(StringRef(object.data(), object.size())),
       objectProps, /*kernels=*/nullptr);
 }
+
+StringRef NVVMTargetInfoAttrImpl::getTargetTriple(Attribute attribute) const {
+  return cast<NVVMTargetAttr>(attribute).getTriple();
+}
+
+StringRef NVVMTargetInfoAttrImpl::getTargetChip(Attribute attribute) const {
+  return cast<NVVMTargetAttr>(attribute).getChip();
+}
+
+std::string
+NVVMTargetInfoAttrImpl::getTargetFeatures(Attribute attribute) const {
+  return cast<NVVMTargetAttr>(attribute).getFeatures().str();
+}
+
+LogicalResult NVVMTargetInfoAttrImpl::setTargetSpec(Attribute attribute,
+                                                    TargetSpec &spec) const {
+  initializeTarget();
+  FailureOr<TargetInfo> info =
+      TargetInfo::getTargetInfo(cast<TargetAttrInterface>(attribute));
+  if (failed(info))
+    return failure();
+  spec.dataLayout =
+      translateDataLayout(info->getDataLayout(), attribute.getContext());
----------------
joker-eph wrote:

Despite the method name, this does only set the data layout?


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


More information about the Mlir-commits mailing list