LLVM 22.0.0git
Type.cpp
Go to the documentation of this file.
1//===- Type.cpp - Sandbox IR 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
11
12using namespace llvm::sandboxir;
13
15 return Ctx.getType(LLVMTy->getScalarType());
16}
17
19 return Ctx.getType(llvm::Type::getInt64Ty(Ctx.LLVMCtx));
20}
22 return Ctx.getType(llvm::Type::getInt32Ty(Ctx.LLVMCtx));
23}
25 return Ctx.getType(llvm::Type::getInt16Ty(Ctx.LLVMCtx));
26}
28 return Ctx.getType(llvm::Type::getInt8Ty(Ctx.LLVMCtx));
29}
31 return Ctx.getType(llvm::Type::getInt1Ty(Ctx.LLVMCtx));
32}
35}
37 return Ctx.getType(llvm::Type::getFloatTy(Ctx.LLVMCtx));
38}
40 return Ctx.getType(llvm::Type::getHalfTy(Ctx.LLVMCtx));
41}
42
43#ifndef NDEBUG
44void Type::dumpOS(raw_ostream &OS) { LLVMTy->print(OS); }
45void Type::dump() {
46 dumpOS(dbgs());
47 dbgs() << "\n";
48}
49#endif
50
52 return cast<PointerType>(
54}
55
56ArrayType *ArrayType::get(Type *ElementType, uint64_t NumElements) {
57 return cast<ArrayType>(ElementType->getContext().getType(
58 llvm::ArrayType::get(ElementType->LLVMTy, NumElements)));
59}
60
62 bool IsPacked) {
63 SmallVector<llvm::Type *> LLVMElements;
64 LLVMElements.reserve(Elements.size());
65 for (Type *Elm : Elements)
66 LLVMElements.push_back(Elm->LLVMTy);
67 return cast<StructType>(
68 Ctx.getType(llvm::StructType::get(Ctx.LLVMCtx, LLVMElements, IsPacked)));
69}
70
72 return cast<VectorType>(ElementType->getContext().getType(
73 llvm::VectorType::get(ElementType->LLVMTy, EC)));
74}
75
77 return Ctx.getType(cast<llvm::VectorType>(LLVMTy)->getElementType());
78}
80 return cast<VectorType>(VTy->getContext().getType(
81 llvm::VectorType::getInteger(cast<llvm::VectorType>(VTy->LLVMTy))));
82}
84 return cast<VectorType>(
86 cast<llvm::VectorType>(VTy->LLVMTy))));
87}
89 return cast<VectorType>(
91 cast<llvm::VectorType>(VTy->LLVMTy))));
92}
94 int NumSubdivs) {
95 return cast<VectorType>(
97 cast<llvm::VectorType>(VTy->LLVMTy), NumSubdivs)));
98}
100 return cast<VectorType>(
102 cast<llvm::VectorType>(VTy->LLVMTy))));
103}
105 return cast<VectorType>(
107 cast<llvm::VectorType>(VTy->LLVMTy))));
108}
111}
112
113FixedVectorType *FixedVectorType::get(Type *ElementType, unsigned NumElts) {
114 return cast<FixedVectorType>(ElementType->getContext().getType(
115 llvm::FixedVectorType::get(ElementType->LLVMTy, NumElts)));
116}
117
119 unsigned NumElts) {
120 return cast<ScalableVectorType>(ElementType->getContext().getType(
121 llvm::ScalableVectorType::get(ElementType->LLVMTy, NumElts)));
122}
123
124IntegerType *IntegerType::get(Context &Ctx, unsigned NumBits) {
125 return cast<IntegerType>(
126 Ctx.getType(llvm::IntegerType::get(Ctx.LLVMCtx, NumBits)));
127}
raw_pwrite_stream & OS
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
static LLVM_ABI ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
Class to represent fixed width SIMD vectors.
Definition: DerivedTypes.h:592
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
Definition: Type.cpp:803
Class to represent integer types.
Definition: DerivedTypes.h:42
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Definition: Type.cpp:319
static LLVM_ABI PointerType * get(Type *ElementType, unsigned AddressSpace)
This constructs a pointer to an object of the specified type in a numbered address space.
Class to represent scalable SIMD vectors.
Definition: DerivedTypes.h:639
static LLVM_ABI ScalableVectorType * get(Type *ElementType, unsigned MinNumElts)
Definition: Type.cpp:825
void reserve(size_type N)
Definition: SmallVector.h:664
void push_back(const T &Elt)
Definition: SmallVector.h:414
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
Definition: Type.cpp:414
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
static LLVM_ABI Type * getFloatTy(LLVMContext &C)
static LLVM_ABI Type * getDoubleTy(LLVMContext &C)
LLVM_ABI void dump() const
static LLVM_ABI IntegerType * getInt8Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
static LLVM_ABI Type * getHalfTy(LLVMContext &C)
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt16Ty(LLVMContext &C)
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition: Type.h:352
static VectorType * getHalfElementsVectorType(VectorType *VTy)
This static method returns a VectorType with half as many elements as the input type and the same ele...
Definition: DerivedTypes.h:534
static VectorType * getExtendedElementVectorType(VectorType *VTy)
This static method is like getInteger except that the element types are twice as wide as the elements...
Definition: DerivedTypes.h:490
static VectorType * getSubdividedVectorType(VectorType *VTy, int NumSubdivs)
Definition: DerivedTypes.h:524
static VectorType * getInteger(VectorType *VTy)
This static method gets a VectorType with the same number of elements as the input type,...
Definition: DerivedTypes.h:481
static VectorType * getTruncatedElementVectorType(VectorType *VTy)
Definition: DerivedTypes.h:499
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static VectorType * getDoubleElementsVectorType(VectorType *VTy)
This static method returns a VectorType with twice as many elements as the input type and the same el...
Definition: DerivedTypes.h:553
static LLVM_ABI bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
Type * getElementType() const
Definition: DerivedTypes.h:463
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
Type * getType(llvm::Type *LLVMTy)
Definition: Context.h:262
LLVMContext & LLVMCtx
Definition: Context.h:70
Just like llvm::Type these are immutable, unique, never get freed and can only be created via static ...
Definition: Type.h:47
llvm::Type * LLVMTy
Definition: Type.h:49
void dumpOS(raw_ostream &OS)
Context & getContext() const
Definition: Type.h:94
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:207