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

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


================
@@ -354,6 +354,46 @@ def TargetSystemSpecInterface : AttrInterface<"TargetSystemSpecInterface", [DLTI
   }];
 }
 
+def TargetAttrInterface : AttrInterface<"TargetAttrInterface"> {
+  let cppNamespace = "::mlir";
+
+  let description = [{
+    Attribute interface describing target information.
+
+    Target information attributes provide essential information on a
+    compilation target. This information includes the target triple identifier,
+    the target chip identifier, a string representation of the target features,
+    and the target spec data layout.
+  }];
+
+  let methods = [
+    InterfaceMethod<
+      /*description=*/"Returns the target triple identifier.",
+      /*retTy=*/"::llvm::StringRef",
+      /*methodName=*/"getTargetTriple",
+      /*args=*/(ins)
+    >,
+    InterfaceMethod<
+      /*description=*/"Returns the target chip identifier.",
+      /*retTy=*/"::llvm::StringRef",
+      /*methodName=*/"getTargetChip",
+      /*args=*/(ins)
+    >,
+    InterfaceMethod<
+      /*description=*/"Returns the target features as a string.",
+      /*retTy=*/"std::string",
+      /*methodName=*/"getTargetFeatures",
+      /*args=*/(ins)
+    >,
+    InterfaceMethod<
+      /*description=*/"Sets the target spec. Returns failure if there was a problem.",
+      /*retTy=*/"::llvm::LogicalResult",
+      /*methodName=*/"setTargetSpec",
+      /*args=*/(ins "::mlir::TargetSpec&":$spec)
----------------
joker-eph wrote:

```suggestion
      /*retTy=*/"::mlir::FailureOr<::mlir::TargetSpec>",
      /*methodName=*/"getTargetSpec",
      /*args=*/(ins)
```

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


More information about the Mlir-commits mailing list