|
14 | 14 | #define CLANG_CIR_DIALECT_IR_CIRTYPES_TD |
15 | 15 |
|
16 | 16 | include "clang/CIR/Dialect/IR/CIRDialect.td" |
| 17 | +include "clang/CIR/Dialect/IR/CIREnumAttr.td" |
17 | 18 | include "clang/CIR/Dialect/IR/CIRTypeConstraints.td" |
18 | 19 | include "clang/CIR/Interfaces/CIRTypeInterfaces.td" |
19 | 20 | include "mlir/Interfaces/DataLayoutInterfaces.td" |
20 | 21 | include "mlir/IR/AttrTypeBase.td" |
| 22 | +include "mlir/IR/EnumAttr.td" |
21 | 23 |
|
22 | 24 | //===----------------------------------------------------------------------===// |
23 | 25 | // CIR Types |
@@ -226,31 +228,57 @@ def CIR_PointerType : CIR_Type<"Pointer", "ptr", [ |
226 | 228 | ]> { |
227 | 229 | let summary = "CIR pointer type"; |
228 | 230 | let description = [{ |
229 | | - The `!cir.ptr` type represents C and C++ pointer types and C++ reference |
230 | | - types, other than pointers-to-members. The `pointee` type is the type |
231 | | - pointed to. |
| 231 | + The `!cir.ptr` type is a typed pointer type. It is used to represent |
| 232 | + pointers to objects in C/C++. The type of the pointed-to object is given by |
| 233 | + the `pointee` parameter. The `addrSpace` parameter is an optional address |
| 234 | + space attribute that specifies the address space of the pointer. If not |
| 235 | + specified, the pointer is assumed to be in the default address space. |
232 | 236 |
|
233 | | - TODO(CIR): The address space attribute is not yet implemented. |
234 | | - }]; |
| 237 | + The `!cir.ptr` type can point to any type, including fundamental types, |
| 238 | + records, arrays, vectors, functions, and other pointers. It can also point |
| 239 | + to incomplete types, such as incomplete records. |
235 | 240 |
|
236 | | - let parameters = (ins "mlir::Type":$pointee); |
| 241 | + Note: Data-member pointers and method pointers are represented by |
| 242 | + `!cir.data_member` and `!cir.method` types, respectively not by |
| 243 | + `!cir.ptr` type. |
237 | 244 |
|
238 | | - let builders = [ |
239 | | - TypeBuilderWithInferredContext<(ins "mlir::Type":$pointee), [{ |
240 | | - return $_get(pointee.getContext(), pointee); |
241 | | - }]>, |
242 | | - TypeBuilder<(ins "mlir::Type":$pointee), [{ |
243 | | - return $_get($_ctxt, pointee); |
244 | | - }]> |
245 | | - ]; |
| 245 | + Examples: |
246 | 246 |
|
247 | | - let assemblyFormat = [{ |
248 | | - `<` $pointee `>` |
| 247 | + ```mlir |
| 248 | + !cir.ptr<!cir.int<u, 8>> |
| 249 | + !cir.ptr<!cir.float> |
| 250 | + !cir.ptr<!cir.record<struct "MyStruct">> |
| 251 | + !cir.ptr<!cir.record<struct "MyStruct">, addrspace(offload_private)> |
| 252 | + !cir.ptr<!cir.int<u, 8>, addrspace(target<1>)> |
| 253 | + ``` |
249 | 254 | }]; |
250 | 255 |
|
251 | | - let genVerifyDecl = 1; |
| 256 | + let parameters = (ins "mlir::Type":$pointee, |
| 257 | + CIR_DefaultValuedEnumParameter<CIR_AddressSpace, |
| 258 | + "cir::AddressSpace::Default">:$addrSpace); |
252 | 259 |
|
253 | 260 | let skipDefaultBuilders = 1; |
| 261 | + let builders = [TypeBuilderWithInferredContext< |
| 262 | + (ins "mlir::Type":$pointee, |
| 263 | + CArg<"cir::AddressSpace", |
| 264 | + "cir::AddressSpace::Default">:$addrSpace), |
| 265 | + [{ |
| 266 | + return $_get(pointee.getContext(), pointee, addrSpace); |
| 267 | + }]>, |
| 268 | + TypeBuilder< |
| 269 | + (ins "mlir::Type":$pointee, |
| 270 | + CArg<"cir::AddressSpace", |
| 271 | + "cir::AddressSpace::Default">:$addrSpace), |
| 272 | + [{ |
| 273 | + return $_get($_ctxt, pointee, addrSpace); |
| 274 | + }]>]; |
| 275 | + |
| 276 | + let assemblyFormat = [{ |
| 277 | + `<` |
| 278 | + $pointee |
| 279 | + ( `,` `addrspace` `(` custom<AddressSpaceValue>($addrSpace)^ `)` )? |
| 280 | + `>` |
| 281 | + }]; |
254 | 282 |
|
255 | 283 | let extraClassDeclaration = [{ |
256 | 284 | template <typename ...Types> |
|
0 commit comments