Skip to content

Commit 9b67848

Browse files
committed
Update docs
1 parent ef55a79 commit 9b67848

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,24 @@ include "mlir/Interfaces/DataLayoutInterfaces.td"
1919
// LLVM_TargetAttr
2020
//===----------------------------------------------------------------------===//
2121

22-
def LLVM_TargetAttr : LLVM_Attr<"Target", "target", [LLVM_TargetAttrInterface]> {
23-
let mnemonic = "target";
24-
let summary = "TODO";
22+
def LLVM_TargetAttr : LLVM_Attr<"Target", "target",
23+
[LLVM_TargetAttrInterface]> {
24+
let summary = "LLVM target info: triple, chip, features";
2525
let description = [{
26-
TODO
26+
An attribute to hold LLVM target information, specifying LLVM's target
27+
`triple` string, the target `chip` string (i.e. the `cpu` string), and
28+
target `features` string as an attribute. The latter two are optional.
29+
30+
Has facilities to obtain the corresponding `llvm::TargetMachine` and
31+
`llvm::DataLayout`, given the relevant LLVM backend is loaded.
32+
33+
---
34+
35+
Responds to DLTI-queries on the keys:
36+
* A query for `"triple"` returns the `StringAttr` for the `triple`.
37+
* A query for `"chip"` returns the `StringAttr` for the `chip`/`cpu`, if provided.
38+
* A query for `"features"` returns the `TargetFeaturesAttr`, if provided.
39+
* Individual features can be queried for on this attribute.
2740
}];
2841
let parameters = (ins "StringAttr":$triple,
2942
OptionalParameter<"StringAttr">:$chip,
@@ -50,9 +63,14 @@ def LLVM_TargetAttr : LLVM_Attr<"Target", "target", [LLVM_TargetAttrInterface]>
5063

5164
def LLVM_DataLayoutAttr
5265
: LLVM_Attr<"DataLayout", "data_layout", [DataLayoutSpecInterface]> {
53-
let summary = "TODO";
66+
let summary = "LLVM data layout string, exposed through DLTI";
5467
let description = [{
55-
TODO
68+
An attribute to hold a LLVM data layout string.
69+
70+
The LLVM data layout string is parsed and mapped to the corresponding MLIR
71+
data layout specification. The `#llvm.data_layout` attribute then serves as
72+
a proxy, forwarding all DLTI queries to the underlying MLIR data layout
73+
specification.
5674
}];
5775
let parameters = (ins "StringAttr":$data_layout_str,
5876
OptionalParameter<"DataLayoutSpecInterface", "{}">:$data_layout_spec);

mlir/include/mlir/Dialect/LLVMIR/LLVMInterfaces.td

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -536,9 +536,19 @@ def LLVM_DIRecursiveTypeAttrInterface
536536
def LLVM_TargetAttrInterface
537537
: AttrInterface<"TargetAttrInterface", [DLTIQueryInterface]> {
538538
let description = [{
539-
TODO
540-
541-
NEEDS TO document which TI keys it responds to.
539+
Interface for attributes that describe LLVM targets.
540+
541+
These attributes should be able to return the specified target
542+
`triple`, `chip` and `features` and are expected to be able to
543+
produce the corresponding `llvm::TargetMachine` and
544+
`llvm::DataLayout`. These methods can fail in case the backend
545+
is not available.
546+
547+
Implementing attributes should provide a
548+
`DLTIQueryInterface::query()` implementation which responds to
549+
keys `"triple"`, `"chip"` and `"features"` by returning an
550+
appropriate `StringAttr`, `StringAttr` and
551+
`LLVM_TargetFeaturesAttr`.
542552
}];
543553
let cppNamespace = "::mlir::LLVM";
544554
let methods = [

0 commit comments

Comments
 (0)