|
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,32 +228,54 @@ 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. |
| 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. |
| 240 | + |
| 241 | + Examples: |
| 242 | + |
| 243 | + ```mlir |
| 244 | + !cir.ptr<!cir.int<u, 8>> |
| 245 | + !cir.ptr<!cir.float> |
| 246 | + !cir.ptr<!cir.record<struct "MyStruct">> |
| 247 | + !cir.ptr<!cir.int<u, 8>, target_address_space(1)> |
| 248 | + !cir.ptr<!cir.record<struct "MyStruct">, target_address_space(5)> |
| 249 | + ``` |
234 | 250 | }];
|
235 | 251 |
|
236 |
| - let parameters = (ins "mlir::Type":$pointee); |
| 252 | + let parameters = (ins |
| 253 | + "mlir::Type":$pointee, |
| 254 | + OptionalParameter< |
| 255 | + "cir::TargetAddressSpaceAttr">:$addrSpace |
| 256 | + ); |
237 | 257 |
|
| 258 | + let skipDefaultBuilders = 1; |
238 | 259 | let builders = [
|
239 |
| - TypeBuilderWithInferredContext<(ins "mlir::Type":$pointee), [{ |
240 |
| - return $_get(pointee.getContext(), pointee); |
| 260 | + TypeBuilderWithInferredContext<(ins |
| 261 | + "mlir::Type":$pointee, |
| 262 | + CArg<"cir::TargetAddressSpaceAttr", "nullptr">:$addrSpace), [{ |
| 263 | + return $_get(pointee.getContext(), pointee, addrSpace); |
241 | 264 | }]>,
|
242 |
| - TypeBuilder<(ins "mlir::Type":$pointee), [{ |
243 |
| - return $_get($_ctxt, pointee); |
| 265 | + TypeBuilder<(ins |
| 266 | + "mlir::Type":$pointee, |
| 267 | + CArg<"cir::TargetAddressSpaceAttr", "nullptr">:$addrSpace), [{ |
| 268 | + return $_get($_ctxt, pointee, addrSpace); |
244 | 269 | }]>
|
245 | 270 | ];
|
246 | 271 |
|
247 | 272 | let assemblyFormat = [{
|
248 |
| - `<` $pointee `>` |
| 273 | + `<` |
| 274 | + $pointee |
| 275 | + ( `,` ` ` custom<TargetAddressSpace>($addrSpace)^ )? |
| 276 | + `>` |
249 | 277 | }];
|
250 | 278 |
|
251 |
| - let genVerifyDecl = 1; |
252 |
| - |
253 |
| - let skipDefaultBuilders = 1; |
254 |
| - |
255 | 279 | let extraClassDeclaration = [{
|
256 | 280 | template <typename ...Types>
|
257 | 281 | bool isPtrTo() const {
|
|
0 commit comments