LLVM 19.0.0git
TypedPointerType.cpp
Go to the documentation of this file.
1//===- TypedPointerType.cpp - 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
13#include "LLVMContextImpl.h"
14
15using namespace llvm;
16
18 assert(EltTy && "Can't get a pointer to <null> type!");
19 assert(isValidElementType(EltTy) && "Invalid type for pointer element!");
20
21 LLVMContextImpl *CImpl = EltTy->getContext().pImpl;
22
23 // Since AddressSpace #0 is the common case, we special case it.
24 TypedPointerType *&Entry =
25 CImpl->ASTypedPointerTypes[std::make_pair(EltTy, AddressSpace)];
26
27 if (!Entry)
28 Entry = new (CImpl->Alloc) TypedPointerType(EltTy, AddressSpace);
29 return Entry;
30}
31
32TypedPointerType::TypedPointerType(Type *E, unsigned AddrSpace)
33 : Type(E->getContext(), TypedPointerTyID), PointeeTy(E) {
34 ContainedTys = &PointeeTy;
36 setSubclassData(AddrSpace);
37}
38
40 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
41 !ElemTy->isMetadataTy() && !ElemTy->isTokenTy() &&
42 !ElemTy->isX86_AMXTy();
43}
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
DenseMap< std::pair< Type *, unsigned >, TypedPointerType * > ASTypedPointerTypes
BumpPtrAllocator Alloc
LLVMContextImpl *const pImpl
Definition: LLVMContext.h:69
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
bool isLabelTy() const
Return true if this is 'label'.
Definition: Type.h:219
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
Definition: Type.h:107
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:129
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
Definition: Type.h:114
void setSubclassData(unsigned val)
Definition: Type.h:100
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition: Type.h:204
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:225
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:140
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:222
A few GPU targets, such as DXIL and SPIR-V, have typed pointers.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
static TypedPointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
AddressSpace
Definition: NVPTXBaseInfo.h:21