Mercurial > hg > CbC > CbC_llvm
comparison mlir/docs/Traits.md @ 173:0572611fdcc8 llvm10 llvm12
reorgnization done
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 25 May 2020 11:55:54 +0900 |
parents | 1d019706d866 |
children | 2e18cbf3894f |
comparison
equal
deleted
inserted
replaced
172:9fbae9c8bf63 | 173:0572611fdcc8 |
---|---|
1 # Introduction to MLIR Operation Traits | 1 # Operation Traits |
2 | 2 |
3 [TOC] | 3 [TOC] |
4 | 4 |
5 MLIR allows for a truly open operation ecosystem, as any dialect may define | 5 MLIR allows for a truly open operation ecosystem, as any dialect may define |
6 operations that suit a specific level of abstraction. `Traits` are a mechanism | 6 operations that suit a specific level of abstraction. `Traits` are a mechanism |
7 in which to abstract implementation details and properties that are common | 7 which abstracts implementation details and properties that are common |
8 across many different operations. `Traits` may be used to specify special | 8 across many different operations. `Traits` may be used to specify special |
9 properties and constraints of the operation, including whether the operation has | 9 properties and constraints of the operation, including whether the operation has |
10 side effects or whether its output has the same type as the input. Some examples | 10 side effects or whether its output has the same type as the input. Some examples |
11 of traits are `Commutative`, `SingleResult`, `Terminator`, etc. See the more | 11 of traits are `Commutative`, `SingleResult`, `Terminator`, etc. See the more |
12 [comprehensive list](#traits) below for more examples of what is possible. | 12 [comprehensive list](#traits) below for more examples of what is possible. |
132 may be used directly by any dialect. The format of the header for each trait | 132 may be used directly by any dialect. The format of the header for each trait |
133 section goes as follows: | 133 section goes as follows: |
134 | 134 |
135 * `Header` | 135 * `Header` |
136 - (`C++ class` -- `ODS class`(if applicable)) | 136 - (`C++ class` -- `ODS class`(if applicable)) |
137 | |
138 ### AffineScope | |
139 | |
140 * `OpTrait::AffineScope` -- `AffineScope` | |
141 | |
142 This trait is carried by region holding operations that define a new scope for | |
143 the purposes of polyhedral optimization and the affine dialect in particular. | |
144 Any SSA values of 'index' type that either dominate such operations, or are | |
145 defined at the top-level of such operations, or appear as region arguments for | |
146 such operations automatically become valid symbols for the polyhedral scope | |
147 defined by that operation. As a result, such SSA values could be used as the | |
148 operands or index operands of various affine dialect operations like affine.for, | |
149 affine.load, and affine.store. The polyhedral scope defined by an operation | |
150 with this trait includes all operations in its region excluding operations that | |
151 are nested inside of other operations that themselves have this trait. | |
152 | |
153 ### AutomaticAllocationScope | |
154 | |
155 * `OpTrait::AutomaticAllocationScope` -- `AutomaticAllocationScope` | |
156 | |
157 This trait is carried by region holding operations that define a new scope for | |
158 automatic allocation. Such allocations are automatically freed when control is | |
159 transferred back from the regions of such operations. As an example, allocations | |
160 performed by [`std.alloca`](Dialects/Standard.md#stdalloca-allocaop) are | |
161 automatically freed when control leaves the region of its closest surrounding op | |
162 that has the trait AutomaticAllocationScope. | |
137 | 163 |
138 ### Broadcastable | 164 ### Broadcastable |
139 | 165 |
140 * `OpTrait::ResultsBroadcastableShape` -- `ResultsBroadcastableShape` | 166 * `OpTrait::ResultsBroadcastableShape` -- `ResultsBroadcastableShape` |
141 | 167 |
204 foo.yield %result : i32 | 230 foo.yield %result : i32 |
205 } | 231 } |
206 ``` | 232 ``` |
207 | 233 |
208 This trait is an important structural property of the IR, and enables operations | 234 This trait is an important structural property of the IR, and enables operations |
209 to have [passes](WritingAPass.md) scheduled under them. | 235 to have [passes](PassManagement.md) scheduled under them. |
210 | |
211 ### NoSideEffect | |
212 | |
213 * `OpTrait::HasNoSideEffect` -- `NoSideEffect` | |
214 | |
215 This trait signifies that the operation is pure and has no visible side effects. | |
216 | 236 |
217 ### Single Block with Implicit Terminator | 237 ### Single Block with Implicit Terminator |
218 | 238 |
219 * `OpTrait::SingleBlockImplicitTerminator<typename TerminatorOpType>` : | 239 * `OpTrait::SingleBlockImplicitTerminator<typename TerminatorOpType>` : |
220 `SingleBlockImplicitTerminator<string op>` | 240 `SingleBlockImplicitTerminator<string op>` |