1 //===- Target/DirectX/DXILPointerType.h - DXIL 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 // 10 //===----------------------------------------------------------------------===// 11 12 #ifndef LLVM_TARGET_DIRECTX_DXILPOINTERTYPE_H 13 #define LLVM_TARGET_DIRECTX_DXILPOINTERTYPE_H 14 15 #include "llvm/IR/Type.h" 16 17 namespace llvm { 18 namespace dxil { 19 20 // DXIL has typed pointers, this pointer type abstraction is used for tracking 21 // in PointerTypeAnalysis and for the bitcode ValueEnumerator 22 class TypedPointerType : public Type { 23 explicit TypedPointerType(Type *ElType, unsigned AddrSpace); 24 25 Type *PointeeTy; 26 27 public: 28 TypedPointerType(const TypedPointerType &) = delete; 29 TypedPointerType &operator=(const TypedPointerType &) = delete; 30 31 /// This constructs a pointer to an object of the specified type in a numbered 32 /// address space. 33 static TypedPointerType *get(Type *ElementType, unsigned AddressSpace); 34 35 /// Return true if the specified type is valid as a element type. 36 static bool isValidElementType(Type *ElemTy); 37 38 /// Return the address space of the Pointer type. getAddressSpace()39 unsigned getAddressSpace() const { return getSubclassData(); } 40 getElementType()41 Type *getElementType() const { return PointeeTy; } 42 43 /// Implement support type inquiry through isa, cast, and dyn_cast. classof(const Type * T)44 static bool classof(const Type *T) { 45 return T->getTypeID() == DXILPointerTyID; 46 } 47 }; 48 49 } // namespace dxil 50 } // namespace llvm 51 52 #endif // LLVM_TARGET_DIRECTX_DXILPOINTERTYPE_H 53