LLVM 20.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 TypedPointerType *&Entry =
24 CImpl->ASTypedPointerTypes[std::make_pair(EltTy, AddressSpace)];
25
26 if (!Entry)
27 Entry = new (CImpl->Alloc) TypedPointerType(EltTy, AddressSpace);
28 return Entry;
29}
30
31TypedPointerType::TypedPointerType(Type *E, unsigned AddrSpace)
32 : Type(E->getContext(), TypedPointerTyID), PointeeTy(E) {
33 ContainedTys = &PointeeTy;
35 setSubclassData(AddrSpace);
36}
37
39 return !ElemTy->isVoidTy() && !ElemTy->isLabelTy() &&
40 !ElemTy->isMetadataTy() && !ElemTy->isTokenTy() &&
41 !ElemTy->isX86_AMXTy();
42}
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:215
unsigned NumContainedTys
Keeps track of how many Type*'s there are in the ContainedTys list.
Definition: Type.h:106
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:128
Type *const * ContainedTys
A pointer to the array of Types contained by this Type.
Definition: Type.h:113
void setSubclassData(unsigned val)
Definition: Type.h:99
bool isX86_AMXTy() const
Return true if this is X86 AMX.
Definition: Type.h:200
bool isTokenTy() const
Return true if this is 'token'.
Definition: Type.h:221
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
bool isMetadataTy() const
Return true if this is 'metadata'.
Definition: Type.h:218
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