@@ -210,9 +210,9 @@ style for types with nested angle brackets and keyword specifiers rather than
210
210
using different bracket styles to differentiate types. Types inside the angle
211
211
brackets may omit the ` !llvm. ` prefix for brevity: the parser first attempts to
212
212
find a type (starting with ` ! ` or a built-in type) and falls back to accepting a
213
- keyword. For example, ` !llvm.ptr< !llvm.ptr<i32>> ` and ` !llvm.ptr<ptr<i32>> ` are
214
- equivalent, with the latter being the canonical form, and denote a pointer to a
215
- pointer to a 32-bit integer .
213
+ keyword. For example, ` !llvm.struct<( !llvm.ptr, f32)> ` and
214
+ ` !llvm.struct<(ptr, f32)> ` are equivalent, with the latter being the canonical
215
+ form, and denote a struct containing a pointer and a float .
216
216
217
217
### Built-in Type Compatibility
218
218
@@ -232,8 +232,8 @@ compatibility check.
232
232
233
233
Each LLVM IR type corresponds to * exactly one* MLIR type, either built-in or
234
234
LLVM dialect type. For example, because ` i32 ` is LLVM-compatible, there is no
235
- ` !llvm.i32 ` type. However, ` !llvm.ptr<T > ` is defined in the LLVM dialect as
236
- there is no corresponding built-in type.
235
+ ` !llvm.i32 ` type. However, ` !llvm.struct<(T, ...) > ` is defined in the LLVM
236
+ dialect as there is no corresponding built-in type.
237
237
238
238
### Additional Simple Types
239
239
@@ -263,24 +263,19 @@ the element type, which can be either compatible built-in or LLVM dialect types.
263
263
264
264
Pointer types specify an address in memory.
265
265
266
- Both opaque and type-parameterized pointer types are supported.
267
- [ Opaque pointers] ( https://llvm.org/docs/OpaquePointers.html ) do not indicate the
268
- type of the data pointed to, and are intended to simplify LLVM IR by encoding
269
- behavior relevant to the pointee type into operations rather than into types.
270
- Non-opaque pointer types carry the pointee type as a type parameter. Both kinds
271
- of pointers may be additionally parameterized by an address space. The address
272
- space is an integer, but this choice may be reconsidered if MLIR implements
273
- named address spaces. The syntax of pointer types is as follows:
266
+ Pointers are [ opaque] ( https://llvm.org/docs/OpaquePointers.html ) , i.e., do not
267
+ indicate the type of the data pointed to, and are intended to simplify LLVM IR
268
+ by encoding behavior relevant to the pointee type into operations rather than
269
+ into types. Pointers can optionally be parametrized with an address space. The
270
+ address space is an integer, but this choice may be reconsidered if MLIR
271
+ implements named address spaces. The syntax of pointer types is as follows:
274
272
275
273
```
276
274
llvm-ptr-type ::= `!llvm.ptr` (`<` integer-literal `>`)?
277
- | `!llvm.ptr<` type (`,` integer-literal)? `>`
278
275
```
279
276
280
- where the former case is the opaque pointer type and the latter case is the
281
- non-opaque pointer type; the optional group containing the integer literal
282
- corresponds to the memory space. All cases are represented by ` LLVMPointerType `
283
- internally.
277
+ where the optional group containing the integer literal corresponds to the
278
+ address space. All cases are represented by ` LLVMPointerType ` internally.
284
279
285
280
#### Array Types
286
281
@@ -346,7 +341,7 @@ syntax:
346
341
347
342
Note that the sets of element types supported by built-in and LLVM dialect
348
343
vector types are mutually exclusive, e.g., the built-in vector type does not
349
- accept ` !llvm.ptr<i32> ` and the LLVM dialect fixed-width vector type does not
344
+ accept ` !llvm.ptr ` and the LLVM dialect fixed-width vector type does not
350
345
accept ` i32 ` .
351
346
352
347
The following functions are provided to operate on any kind of the vector types
@@ -367,12 +362,11 @@ compatible with the LLVM dialect:
367
362
368
363
``` mlir
369
364
vector<42 x i32> // Vector of 42 32-bit integers.
370
- !llvm.vec<42 x ptr<i32>> // Vector of 42 pointers to 32-bit integers .
365
+ !llvm.vec<42 x ptr> // Vector of 42 pointers.
371
366
!llvm.vec<? x 4 x i32> // Scalable vector of 32-bit integers with
372
367
// size divisible by 4.
373
368
!llvm.array<2 x vector<2 x i32>> // Array of 2 vectors of 2 32-bit integers.
374
- !llvm.array<2 x vec<2 x ptr<i32>>> // Array of 2 vectors of 2 pointers to 32-bit
375
- // integers.
369
+ !llvm.array<2 x vec<2 x ptr>> // Array of 2 vectors of 2 pointers.
376
370
```
377
371
378
372
### Structure Types
@@ -421,21 +415,6 @@ type-or-ref ::= <any compatible type with optional !llvm.>
421
415
| `!llvm.`? `struct<` string-literal `>`
422
416
```
423
417
424
- The body of the identified struct is printed in full unless the it is
425
- transitively contained in the same struct. In the latter case, only the
426
- identifier is printed. For example, the structure containing the pointer to
427
- itself is represented as ` !llvm.struct<"A", (ptr<"A">)> ` , and the structure ` A `
428
- containing two pointers to the structure ` B ` containing a pointer to the
429
- structure ` A ` is represented as `!llvm.struct<"A", (ptr<"B", (ptr<"A">)>,
430
- ptr<"B", (ptr<"A">))>` . Note that the structure ` B` is "unrolled" for both
431
- elements. _ A structure with the same name but different body is a syntax error._
432
- ** The user must ensure structure name uniqueness across all modules processed in
433
- a given MLIR context.** Structure names are arbitrary string literals and may
434
- include, e.g., spaces and keywords.
435
-
436
- Identified structs may be _ opaque_ . In this case, the body is unknown but the
437
- structure type is considered _ initialized_ and is valid in the IR.
438
-
439
418
#### Literal Structure Types
440
419
441
420
Literal structures are uniqued according to the list of elements they contain,
@@ -460,11 +439,10 @@ elements provided.
460
439
!llvm.struct<packed (i8, i32)> // packed struct
461
440
!llvm.struct<"a"> // recursive reference, only allowed within
462
441
// another struct, NOT allowed at top level
463
- !llvm.struct<"a", ptr<struct<"a">>> // supported example of recursive reference
464
442
!llvm.struct<"a", ()> // empty, named (necessary to differentiate from
465
443
// recursive reference)
466
444
!llvm.struct<"a", opaque> // opaque, named
467
- !llvm.struct<"a", (i32)> // named
445
+ !llvm.struct<"a", (i32, ptr )> // named
468
446
!llvm.struct<"a", packed (i8, i32)> // named, packed
469
447
```
470
448
0 commit comments