LLVM 20.0.0git
TypedPointerType.h
Go to the documentation of this file.
1//===- llvm/IR/TypedPointerType.h - Typed Pointer Type --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains typed pointer type information. It is separated out into
10// a separate file to make it less likely to accidentally use this type.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_IR_TYPEDPOINTERTYPE_H
15#define LLVM_IR_TYPEDPOINTERTYPE_H
16
17#include "llvm/IR/Type.h"
18
19namespace llvm {
20
21/// A few GPU targets, such as DXIL and SPIR-V, have typed pointers. This
22/// pointer type abstraction is used for tracking the types of these pointers.
23/// It is not legal to use this type, or derived types containing this type, in
24/// LLVM IR.
25class TypedPointerType : public Type {
26 explicit TypedPointerType(Type *ElType, unsigned AddrSpace);
27
28 Type *PointeeTy;
29
30public:
33
34 /// This constructs a pointer to an object of the specified type in a numbered
35 /// address space.
36 static TypedPointerType *get(Type *ElementType, unsigned AddressSpace);
37
38 /// Return true if the specified type is valid as a element type.
39 static bool isValidElementType(Type *ElemTy);
40
41 /// Return the address space of the Pointer type.
42 unsigned getAddressSpace() const { return getSubclassData(); }
43
44 Type *getElementType() const { return PointeeTy; }
45
46 /// Implement support type inquiry through isa, cast, and dyn_cast.
47 static bool classof(const Type *T) {
48 return T->getTypeID() == TypedPointerTyID;
49 }
50};
51
52} // namespace llvm
53
54#endif // LLVM_IR_TYPEDPOINTERTYPE_H
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
@ TypedPointerTyID
Typed pointer used by some GPU targets.
Definition: Type.h:77
unsigned getSubclassData() const
Definition: Type.h:97
A few GPU targets, such as DXIL and SPIR-V, have typed pointers.
static bool classof(const Type *T)
Implement support type inquiry through isa, cast, and dyn_cast.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
TypedPointerType & operator=(const TypedPointerType &)=delete
Type * getElementType() const
static TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
TypedPointerType(const TypedPointerType &)=delete
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AddressSpace
Definition: NVPTXBaseInfo.h:21