clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name ValueTypes.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/gnu/usr.bin/clang/libLLVM/obj -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Analysis -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ASMParser -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/BinaryFormat -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Bitcode -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Bitcode -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Bitstream -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /include/llvm/CodeGen -I /include/llvm/CodeGen/PBQP -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/IR -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/IR -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/Coroutines -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ProfileData/Coverage -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/CodeView -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/DWARF -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/MSF -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/PDB -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Demangle -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ExecutionEngine -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ExecutionEngine/JITLink -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ExecutionEngine/Orc -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Frontend -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Frontend/OpenACC -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Frontend -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Frontend/OpenMP -I /include/llvm/CodeGen/GlobalISel -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/IRReader -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/InstCombine -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/Transforms/InstCombine -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/LTO -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Linker -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/MC -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/MC/MCParser -I /include/llvm/CodeGen/MIRParser -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Object -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Option -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Passes -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ProfileData -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/Scalar -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ADT -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Support -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/Symbolize -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Target -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/Utils -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/Vectorize -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/IPO -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include -I /usr/src/gnu/usr.bin/clang/libLLVM/../include -I /usr/src/gnu/usr.bin/clang/libLLVM/obj -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include -D NDEBUG -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D LLVM_PREFIX="/usr" -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-comment -std=c++14 -fdeprecated-macro -fdebug-compilation-dir=/usr/src/gnu/usr.bin/clang/libLLVM/obj -ferror-limit 19 -fvisibility-inlines-hidden -fwrapv -stack-protector 2 -fno-rtti -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c++ /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/CodeGen/ValueTypes.cpp
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #include "llvm/CodeGen/ValueTypes.h" |
10 | #include "llvm/ADT/StringExtras.h" |
11 | #include "llvm/IR/DerivedTypes.h" |
12 | #include "llvm/IR/Type.h" |
13 | #include "llvm/Support/ErrorHandling.h" |
14 | #include "llvm/Support/TypeSize.h" |
15 | using namespace llvm; |
16 | |
17 | EVT EVT::changeExtendedTypeToInteger() const { |
18 | assert(isExtended() && "Type is not extended!"); |
19 | LLVMContext &Context = LLVMTy->getContext(); |
20 | return getIntegerVT(Context, getSizeInBits()); |
21 | } |
22 | |
23 | EVT EVT::changeExtendedVectorElementTypeToInteger() const { |
24 | assert(isExtended() && "Type is not extended!"); |
25 | LLVMContext &Context = LLVMTy->getContext(); |
26 | EVT IntTy = getIntegerVT(Context, getScalarSizeInBits()); |
27 | return getVectorVT(Context, IntTy, getVectorElementCount()); |
28 | } |
29 | |
30 | EVT EVT::changeExtendedVectorElementType(EVT EltVT) const { |
31 | assert(isExtended() && "Type is not extended!"); |
32 | LLVMContext &Context = LLVMTy->getContext(); |
33 | return getVectorVT(Context, EltVT, getVectorElementCount()); |
34 | } |
35 | |
36 | EVT EVT::getExtendedIntegerVT(LLVMContext &Context, unsigned BitWidth) { |
37 | EVT VT; |
38 | VT.LLVMTy = IntegerType::get(Context, BitWidth); |
39 | assert(VT.isExtended() && "Type is not extended!"); |
40 | return VT; |
41 | } |
42 | |
43 | EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, |
44 | bool IsScalable) { |
45 | EVT ResultVT; |
46 | ResultVT.LLVMTy = |
47 | VectorType::get(VT.getTypeForEVT(Context), NumElements, IsScalable); |
48 | assert(ResultVT.isExtended() && "Type is not extended!"); |
49 | return ResultVT; |
50 | } |
51 | |
52 | EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT, ElementCount EC) { |
53 | EVT ResultVT; |
54 | ResultVT.LLVMTy = VectorType::get(VT.getTypeForEVT(Context), EC); |
55 | assert(ResultVT.isExtended() && "Type is not extended!"); |
56 | return ResultVT; |
57 | } |
58 | |
59 | bool EVT::isExtendedFloatingPoint() const { |
60 | assert(isExtended() && "Type is not extended!"); |
61 | return LLVMTy->isFPOrFPVectorTy(); |
62 | } |
63 | |
64 | bool EVT::isExtendedInteger() const { |
65 | assert(isExtended() && "Type is not extended!"); |
66 | return LLVMTy->isIntOrIntVectorTy(); |
67 | } |
68 | |
69 | bool EVT::isExtendedScalarInteger() const { |
70 | assert(isExtended() && "Type is not extended!"); |
71 | return LLVMTy->isIntegerTy(); |
72 | } |
73 | |
74 | bool EVT::isExtendedVector() const { |
75 | assert(isExtended() && "Type is not extended!"); |
76 | return LLVMTy->isVectorTy(); |
| 20 | | Called C++ object pointer is null |
|
77 | } |
78 | |
79 | bool EVT::isExtended16BitVector() const { |
80 | return isExtendedVector() && getExtendedSizeInBits() == 16; |
81 | } |
82 | |
83 | bool EVT::isExtended32BitVector() const { |
84 | return isExtendedVector() && getExtendedSizeInBits() == 32; |
85 | } |
86 | |
87 | bool EVT::isExtended64BitVector() const { |
88 | return isExtendedVector() && getExtendedSizeInBits() == 64; |
89 | } |
90 | |
91 | bool EVT::isExtended128BitVector() const { |
92 | return isExtendedVector() && getExtendedSizeInBits() == 128; |
93 | } |
94 | |
95 | bool EVT::isExtended256BitVector() const { |
96 | return isExtendedVector() && getExtendedSizeInBits() == 256; |
97 | } |
98 | |
99 | bool EVT::isExtended512BitVector() const { |
100 | return isExtendedVector() && getExtendedSizeInBits() == 512; |
101 | } |
102 | |
103 | bool EVT::isExtended1024BitVector() const { |
104 | return isExtendedVector() && getExtendedSizeInBits() == 1024; |
105 | } |
106 | |
107 | bool EVT::isExtended2048BitVector() const { |
108 | return isExtendedVector() && getExtendedSizeInBits() == 2048; |
109 | } |
110 | |
111 | bool EVT::isExtendedFixedLengthVector() const { |
112 | return isExtendedVector() && isa<FixedVectorType>(LLVMTy); |
113 | } |
114 | |
115 | bool EVT::isExtendedScalableVector() const { |
116 | return isExtendedVector() && isa<ScalableVectorType>(LLVMTy); |
117 | } |
118 | |
119 | EVT EVT::getExtendedVectorElementType() const { |
120 | assert(isExtended() && "Type is not extended!"); |
121 | return EVT::getEVT(cast<VectorType>(LLVMTy)->getElementType()); |
122 | } |
123 | |
124 | unsigned EVT::getExtendedVectorNumElements() const { |
125 | assert(isExtended() && "Type is not extended!"); |
126 | ElementCount EC = cast<VectorType>(LLVMTy)->getElementCount(); |
127 | if (EC.isScalable()) { |
128 | WithColor::warning() |
129 | << "The code that requested the fixed number of elements has made the " |
130 | "assumption that this vector is not scalable. This assumption was " |
131 | "not correct, and this may lead to broken code\n"; |
132 | } |
133 | return EC.getKnownMinValue(); |
134 | } |
135 | |
136 | ElementCount EVT::getExtendedVectorElementCount() const { |
137 | assert(isExtended() && "Type is not extended!"); |
138 | return cast<VectorType>(LLVMTy)->getElementCount(); |
139 | } |
140 | |
141 | TypeSize EVT::getExtendedSizeInBits() const { |
142 | assert(isExtended() && "Type is not extended!"); |
143 | if (IntegerType *ITy = dyn_cast<IntegerType>(LLVMTy)) |
144 | return TypeSize::Fixed(ITy->getBitWidth()); |
145 | if (VectorType *VTy = dyn_cast<VectorType>(LLVMTy)) |
146 | return VTy->getPrimitiveSizeInBits(); |
147 | llvm_unreachable("Unrecognized extended type!"); |
148 | } |
149 | |
150 | |
151 | std::string EVT::getEVTString() const { |
152 | switch (V.SimpleTy) { |
| 1 | Control jumps to the 'default' case at line 153 | |
|
| 5 | | Control jumps to the 'default' case at line 153 | |
|
| 16 | | Control jumps to the 'default' case at line 153 | |
|
153 | default: |
154 | if (isVector()) |
| |
| |
| 17 | | Calling 'EVT::isVector' | |
|
155 | return (isScalableVector() ? "nxv" : "v") + |
| |
| |
156 | utostr(getVectorElementCount().getKnownMinValue()) + |
157 | getVectorElementType().getEVTString(); |
| 4 | | Calling 'EVT::getEVTString' | |
|
| 8 | | Calling 'EVT::getVectorElementType' | |
|
| 14 | | Returning from 'EVT::getVectorElementType' | |
|
| 15 | | Calling 'EVT::getEVTString' | |
|
158 | if (isInteger()) |
159 | return "i" + utostr(getSizeInBits()); |
160 | if (isFloatingPoint()) |
161 | return "f" + utostr(getSizeInBits()); |
162 | llvm_unreachable("Invalid EVT!"); |
163 | case MVT::bf16: return "bf16"; |
164 | case MVT::ppcf128: return "ppcf128"; |
165 | case MVT::isVoid: return "isVoid"; |
166 | case MVT::Other: return "ch"; |
167 | case MVT::Glue: return "glue"; |
168 | case MVT::x86mmx: return "x86mmx"; |
169 | case MVT::x86amx: return "x86amx"; |
170 | case MVT::i64x8: return "i64x8"; |
171 | case MVT::Metadata: return "Metadata"; |
172 | case MVT::Untyped: return "Untyped"; |
173 | case MVT::funcref: return "funcref"; |
174 | case MVT::externref: return "externref"; |
175 | } |
176 | } |
177 | |
178 | |
179 | |
180 | |
181 | Type *EVT::getTypeForEVT(LLVMContext &Context) const { |
182 | switch (V.SimpleTy) { |
183 | default: |
184 | assert(isExtended() && "Type is not extended!"); |
185 | return LLVMTy; |
186 | case MVT::isVoid: return Type::getVoidTy(Context); |
187 | case MVT::i1: return Type::getInt1Ty(Context); |
188 | case MVT::i8: return Type::getInt8Ty(Context); |
189 | case MVT::i16: return Type::getInt16Ty(Context); |
190 | case MVT::i32: return Type::getInt32Ty(Context); |
191 | case MVT::i64: return Type::getInt64Ty(Context); |
192 | case MVT::i128: return IntegerType::get(Context, 128); |
193 | case MVT::f16: return Type::getHalfTy(Context); |
194 | case MVT::bf16: return Type::getBFloatTy(Context); |
195 | case MVT::f32: return Type::getFloatTy(Context); |
196 | case MVT::f64: return Type::getDoubleTy(Context); |
197 | case MVT::f80: return Type::getX86_FP80Ty(Context); |
198 | case MVT::f128: return Type::getFP128Ty(Context); |
199 | case MVT::ppcf128: return Type::getPPC_FP128Ty(Context); |
200 | case MVT::x86mmx: return Type::getX86_MMXTy(Context); |
201 | case MVT::x86amx: return Type::getX86_AMXTy(Context); |
202 | case MVT::i64x8: return IntegerType::get(Context, 512); |
203 | case MVT::externref: |
204 | return PointerType::get(StructType::create(Context), 10); |
205 | case MVT::funcref: |
206 | return PointerType::get(StructType::create(Context), 20); |
207 | case MVT::v1i1: |
208 | return FixedVectorType::get(Type::getInt1Ty(Context), 1); |
209 | case MVT::v2i1: |
210 | return FixedVectorType::get(Type::getInt1Ty(Context), 2); |
211 | case MVT::v4i1: |
212 | return FixedVectorType::get(Type::getInt1Ty(Context), 4); |
213 | case MVT::v8i1: |
214 | return FixedVectorType::get(Type::getInt1Ty(Context), 8); |
215 | case MVT::v16i1: |
216 | return FixedVectorType::get(Type::getInt1Ty(Context), 16); |
217 | case MVT::v32i1: |
218 | return FixedVectorType::get(Type::getInt1Ty(Context), 32); |
219 | case MVT::v64i1: |
220 | return FixedVectorType::get(Type::getInt1Ty(Context), 64); |
221 | case MVT::v128i1: |
222 | return FixedVectorType::get(Type::getInt1Ty(Context), 128); |
223 | case MVT::v256i1: |
224 | return FixedVectorType::get(Type::getInt1Ty(Context), 256); |
225 | case MVT::v512i1: |
226 | return FixedVectorType::get(Type::getInt1Ty(Context), 512); |
227 | case MVT::v1024i1: |
228 | return FixedVectorType::get(Type::getInt1Ty(Context), 1024); |
229 | case MVT::v1i8: |
230 | return FixedVectorType::get(Type::getInt8Ty(Context), 1); |
231 | case MVT::v2i8: |
232 | return FixedVectorType::get(Type::getInt8Ty(Context), 2); |
233 | case MVT::v4i8: |
234 | return FixedVectorType::get(Type::getInt8Ty(Context), 4); |
235 | case MVT::v8i8: |
236 | return FixedVectorType::get(Type::getInt8Ty(Context), 8); |
237 | case MVT::v16i8: |
238 | return FixedVectorType::get(Type::getInt8Ty(Context), 16); |
239 | case MVT::v32i8: |
240 | return FixedVectorType::get(Type::getInt8Ty(Context), 32); |
241 | case MVT::v64i8: |
242 | return FixedVectorType::get(Type::getInt8Ty(Context), 64); |
243 | case MVT::v128i8: |
244 | return FixedVectorType::get(Type::getInt8Ty(Context), 128); |
245 | case MVT::v256i8: |
246 | return FixedVectorType::get(Type::getInt8Ty(Context), 256); |
247 | case MVT::v512i8: |
248 | return FixedVectorType::get(Type::getInt8Ty(Context), 512); |
249 | case MVT::v1024i8: |
250 | return FixedVectorType::get(Type::getInt8Ty(Context), 1024); |
251 | case MVT::v1i16: |
252 | return FixedVectorType::get(Type::getInt16Ty(Context), 1); |
253 | case MVT::v2i16: |
254 | return FixedVectorType::get(Type::getInt16Ty(Context), 2); |
255 | case MVT::v3i16: |
256 | return FixedVectorType::get(Type::getInt16Ty(Context), 3); |
257 | case MVT::v4i16: |
258 | return FixedVectorType::get(Type::getInt16Ty(Context), 4); |
259 | case MVT::v8i16: |
260 | return FixedVectorType::get(Type::getInt16Ty(Context), 8); |
261 | case MVT::v16i16: |
262 | return FixedVectorType::get(Type::getInt16Ty(Context), 16); |
263 | case MVT::v32i16: |
264 | return FixedVectorType::get(Type::getInt16Ty(Context), 32); |
265 | case MVT::v64i16: |
266 | return FixedVectorType::get(Type::getInt16Ty(Context), 64); |
267 | case MVT::v128i16: |
268 | return FixedVectorType::get(Type::getInt16Ty(Context), 128); |
269 | case MVT::v256i16: |
270 | return FixedVectorType::get(Type::getInt16Ty(Context), 256); |
271 | case MVT::v512i16: |
272 | return FixedVectorType::get(Type::getInt16Ty(Context), 512); |
273 | case MVT::v1i32: |
274 | return FixedVectorType::get(Type::getInt32Ty(Context), 1); |
275 | case MVT::v2i32: |
276 | return FixedVectorType::get(Type::getInt32Ty(Context), 2); |
277 | case MVT::v3i32: |
278 | return FixedVectorType::get(Type::getInt32Ty(Context), 3); |
279 | case MVT::v4i32: |
280 | return FixedVectorType::get(Type::getInt32Ty(Context), 4); |
281 | case MVT::v5i32: |
282 | return FixedVectorType::get(Type::getInt32Ty(Context), 5); |
283 | case MVT::v6i32: |
284 | return FixedVectorType::get(Type::getInt32Ty(Context), 6); |
285 | case MVT::v7i32: |
286 | return FixedVectorType::get(Type::getInt32Ty(Context), 7); |
287 | case MVT::v8i32: |
288 | return FixedVectorType::get(Type::getInt32Ty(Context), 8); |
289 | case MVT::v16i32: |
290 | return FixedVectorType::get(Type::getInt32Ty(Context), 16); |
291 | case MVT::v32i32: |
292 | return FixedVectorType::get(Type::getInt32Ty(Context), 32); |
293 | case MVT::v64i32: |
294 | return FixedVectorType::get(Type::getInt32Ty(Context), 64); |
295 | case MVT::v128i32: |
296 | return FixedVectorType::get(Type::getInt32Ty(Context), 128); |
297 | case MVT::v256i32: |
298 | return FixedVectorType::get(Type::getInt32Ty(Context), 256); |
299 | case MVT::v512i32: |
300 | return FixedVectorType::get(Type::getInt32Ty(Context), 512); |
301 | case MVT::v1024i32: |
302 | return FixedVectorType::get(Type::getInt32Ty(Context), 1024); |
303 | case MVT::v2048i32: |
304 | return FixedVectorType::get(Type::getInt32Ty(Context), 2048); |
305 | case MVT::v1i64: |
306 | return FixedVectorType::get(Type::getInt64Ty(Context), 1); |
307 | case MVT::v2i64: |
308 | return FixedVectorType::get(Type::getInt64Ty(Context), 2); |
309 | case MVT::v3i64: |
310 | return FixedVectorType::get(Type::getInt64Ty(Context), 3); |
311 | case MVT::v4i64: |
312 | return FixedVectorType::get(Type::getInt64Ty(Context), 4); |
313 | case MVT::v8i64: |
314 | return FixedVectorType::get(Type::getInt64Ty(Context), 8); |
315 | case MVT::v16i64: |
316 | return FixedVectorType::get(Type::getInt64Ty(Context), 16); |
317 | case MVT::v32i64: |
318 | return FixedVectorType::get(Type::getInt64Ty(Context), 32); |
319 | case MVT::v64i64: |
320 | return FixedVectorType::get(Type::getInt64Ty(Context), 64); |
321 | case MVT::v128i64: |
322 | return FixedVectorType::get(Type::getInt64Ty(Context), 128); |
323 | case MVT::v256i64: |
324 | return FixedVectorType::get(Type::getInt64Ty(Context), 256); |
325 | case MVT::v1i128: |
326 | return FixedVectorType::get(Type::getInt128Ty(Context), 1); |
327 | case MVT::v1f16: |
328 | return FixedVectorType::get(Type::getHalfTy(Context), 1); |
329 | case MVT::v2f16: |
330 | return FixedVectorType::get(Type::getHalfTy(Context), 2); |
331 | case MVT::v3f16: |
332 | return FixedVectorType::get(Type::getHalfTy(Context), 3); |
333 | case MVT::v4f16: |
334 | return FixedVectorType::get(Type::getHalfTy(Context), 4); |
335 | case MVT::v8f16: |
336 | return FixedVectorType::get(Type::getHalfTy(Context), 8); |
337 | case MVT::v16f16: |
338 | return FixedVectorType::get(Type::getHalfTy(Context), 16); |
339 | case MVT::v32f16: |
340 | return FixedVectorType::get(Type::getHalfTy(Context), 32); |
341 | case MVT::v64f16: |
342 | return FixedVectorType::get(Type::getHalfTy(Context), 64); |
343 | case MVT::v128f16: |
344 | return FixedVectorType::get(Type::getHalfTy(Context), 128); |
345 | case MVT::v256f16: |
346 | return FixedVectorType::get(Type::getHalfTy(Context), 256); |
347 | case MVT::v512f16: |
348 | return FixedVectorType::get(Type::getHalfTy(Context), 512); |
349 | case MVT::v2bf16: |
350 | return FixedVectorType::get(Type::getBFloatTy(Context), 2); |
351 | case MVT::v3bf16: |
352 | return FixedVectorType::get(Type::getBFloatTy(Context), 3); |
353 | case MVT::v4bf16: |
354 | return FixedVectorType::get(Type::getBFloatTy(Context), 4); |
355 | case MVT::v8bf16: |
356 | return FixedVectorType::get(Type::getBFloatTy(Context), 8); |
357 | case MVT::v16bf16: |
358 | return FixedVectorType::get(Type::getBFloatTy(Context), 16); |
359 | case MVT::v32bf16: |
360 | return FixedVectorType::get(Type::getBFloatTy(Context), 32); |
361 | case MVT::v64bf16: |
362 | return FixedVectorType::get(Type::getBFloatTy(Context), 64); |
363 | case MVT::v128bf16: |
364 | return FixedVectorType::get(Type::getBFloatTy(Context), 128); |
365 | case MVT::v1f32: |
366 | return FixedVectorType::get(Type::getFloatTy(Context), 1); |
367 | case MVT::v2f32: |
368 | return FixedVectorType::get(Type::getFloatTy(Context), 2); |
369 | case MVT::v3f32: |
370 | return FixedVectorType::get(Type::getFloatTy(Context), 3); |
371 | case MVT::v4f32: |
372 | return FixedVectorType::get(Type::getFloatTy(Context), 4); |
373 | case MVT::v5f32: |
374 | return FixedVectorType::get(Type::getFloatTy(Context), 5); |
375 | case MVT::v6f32: |
376 | return FixedVectorType::get(Type::getFloatTy(Context), 6); |
377 | case MVT::v7f32: |
378 | return FixedVectorType::get(Type::getFloatTy(Context), 7); |
379 | case MVT::v8f32: |
380 | return FixedVectorType::get(Type::getFloatTy(Context), 8); |
381 | case MVT::v16f32: |
382 | return FixedVectorType::get(Type::getFloatTy(Context), 16); |
383 | case MVT::v32f32: |
384 | return FixedVectorType::get(Type::getFloatTy(Context), 32); |
385 | case MVT::v64f32: |
386 | return FixedVectorType::get(Type::getFloatTy(Context), 64); |
387 | case MVT::v128f32: |
388 | return FixedVectorType::get(Type::getFloatTy(Context), 128); |
389 | case MVT::v256f32: |
390 | return FixedVectorType::get(Type::getFloatTy(Context), 256); |
391 | case MVT::v512f32: |
392 | return FixedVectorType::get(Type::getFloatTy(Context), 512); |
393 | case MVT::v1024f32: |
394 | return FixedVectorType::get(Type::getFloatTy(Context), 1024); |
395 | case MVT::v2048f32: |
396 | return FixedVectorType::get(Type::getFloatTy(Context), 2048); |
397 | case MVT::v1f64: |
398 | return FixedVectorType::get(Type::getDoubleTy(Context), 1); |
399 | case MVT::v2f64: |
400 | return FixedVectorType::get(Type::getDoubleTy(Context), 2); |
401 | case MVT::v3f64: |
402 | return FixedVectorType::get(Type::getDoubleTy(Context), 3); |
403 | case MVT::v4f64: |
404 | return FixedVectorType::get(Type::getDoubleTy(Context), 4); |
405 | case MVT::v8f64: |
406 | return FixedVectorType::get(Type::getDoubleTy(Context), 8); |
407 | case MVT::v16f64: |
408 | return FixedVectorType::get(Type::getDoubleTy(Context), 16); |
409 | case MVT::v32f64: |
410 | return FixedVectorType::get(Type::getDoubleTy(Context), 32); |
411 | case MVT::v64f64: |
412 | return FixedVectorType::get(Type::getDoubleTy(Context), 64); |
413 | case MVT::v128f64: |
414 | return FixedVectorType::get(Type::getDoubleTy(Context), 128); |
415 | case MVT::v256f64: |
416 | return FixedVectorType::get(Type::getDoubleTy(Context), 256); |
417 | case MVT::nxv1i1: |
418 | return ScalableVectorType::get(Type::getInt1Ty(Context), 1); |
419 | case MVT::nxv2i1: |
420 | return ScalableVectorType::get(Type::getInt1Ty(Context), 2); |
421 | case MVT::nxv4i1: |
422 | return ScalableVectorType::get(Type::getInt1Ty(Context), 4); |
423 | case MVT::nxv8i1: |
424 | return ScalableVectorType::get(Type::getInt1Ty(Context), 8); |
425 | case MVT::nxv16i1: |
426 | return ScalableVectorType::get(Type::getInt1Ty(Context), 16); |
427 | case MVT::nxv32i1: |
428 | return ScalableVectorType::get(Type::getInt1Ty(Context), 32); |
429 | case MVT::nxv64i1: |
430 | return ScalableVectorType::get(Type::getInt1Ty(Context), 64); |
431 | case MVT::nxv1i8: |
432 | return ScalableVectorType::get(Type::getInt8Ty(Context), 1); |
433 | case MVT::nxv2i8: |
434 | return ScalableVectorType::get(Type::getInt8Ty(Context), 2); |
435 | case MVT::nxv4i8: |
436 | return ScalableVectorType::get(Type::getInt8Ty(Context), 4); |
437 | case MVT::nxv8i8: |
438 | return ScalableVectorType::get(Type::getInt8Ty(Context), 8); |
439 | case MVT::nxv16i8: |
440 | return ScalableVectorType::get(Type::getInt8Ty(Context), 16); |
441 | case MVT::nxv32i8: |
442 | return ScalableVectorType::get(Type::getInt8Ty(Context), 32); |
443 | case MVT::nxv64i8: |
444 | return ScalableVectorType::get(Type::getInt8Ty(Context), 64); |
445 | case MVT::nxv1i16: |
446 | return ScalableVectorType::get(Type::getInt16Ty(Context), 1); |
447 | case MVT::nxv2i16: |
448 | return ScalableVectorType::get(Type::getInt16Ty(Context), 2); |
449 | case MVT::nxv4i16: |
450 | return ScalableVectorType::get(Type::getInt16Ty(Context), 4); |
451 | case MVT::nxv8i16: |
452 | return ScalableVectorType::get(Type::getInt16Ty(Context), 8); |
453 | case MVT::nxv16i16: |
454 | return ScalableVectorType::get(Type::getInt16Ty(Context), 16); |
455 | case MVT::nxv32i16: |
456 | return ScalableVectorType::get(Type::getInt16Ty(Context), 32); |
457 | case MVT::nxv1i32: |
458 | return ScalableVectorType::get(Type::getInt32Ty(Context), 1); |
459 | case MVT::nxv2i32: |
460 | return ScalableVectorType::get(Type::getInt32Ty(Context), 2); |
461 | case MVT::nxv4i32: |
462 | return ScalableVectorType::get(Type::getInt32Ty(Context), 4); |
463 | case MVT::nxv8i32: |
464 | return ScalableVectorType::get(Type::getInt32Ty(Context), 8); |
465 | case MVT::nxv16i32: |
466 | return ScalableVectorType::get(Type::getInt32Ty(Context), 16); |
467 | case MVT::nxv32i32: |
468 | return ScalableVectorType::get(Type::getInt32Ty(Context), 32); |
469 | case MVT::nxv1i64: |
470 | return ScalableVectorType::get(Type::getInt64Ty(Context), 1); |
471 | case MVT::nxv2i64: |
472 | return ScalableVectorType::get(Type::getInt64Ty(Context), 2); |
473 | case MVT::nxv4i64: |
474 | return ScalableVectorType::get(Type::getInt64Ty(Context), 4); |
475 | case MVT::nxv8i64: |
476 | return ScalableVectorType::get(Type::getInt64Ty(Context), 8); |
477 | case MVT::nxv16i64: |
478 | return ScalableVectorType::get(Type::getInt64Ty(Context), 16); |
479 | case MVT::nxv32i64: |
480 | return ScalableVectorType::get(Type::getInt64Ty(Context), 32); |
481 | case MVT::nxv1f16: |
482 | return ScalableVectorType::get(Type::getHalfTy(Context), 1); |
483 | case MVT::nxv2f16: |
484 | return ScalableVectorType::get(Type::getHalfTy(Context), 2); |
485 | case MVT::nxv4f16: |
486 | return ScalableVectorType::get(Type::getHalfTy(Context), 4); |
487 | case MVT::nxv8f16: |
488 | return ScalableVectorType::get(Type::getHalfTy(Context), 8); |
489 | case MVT::nxv16f16: |
490 | return ScalableVectorType::get(Type::getHalfTy(Context), 16); |
491 | case MVT::nxv32f16: |
492 | return ScalableVectorType::get(Type::getHalfTy(Context), 32); |
493 | case MVT::nxv1bf16: |
494 | return ScalableVectorType::get(Type::getBFloatTy(Context), 1); |
495 | case MVT::nxv2bf16: |
496 | return ScalableVectorType::get(Type::getBFloatTy(Context), 2); |
497 | case MVT::nxv4bf16: |
498 | return ScalableVectorType::get(Type::getBFloatTy(Context), 4); |
499 | case MVT::nxv8bf16: |
500 | return ScalableVectorType::get(Type::getBFloatTy(Context), 8); |
501 | case MVT::nxv1f32: |
502 | return ScalableVectorType::get(Type::getFloatTy(Context), 1); |
503 | case MVT::nxv2f32: |
504 | return ScalableVectorType::get(Type::getFloatTy(Context), 2); |
505 | case MVT::nxv4f32: |
506 | return ScalableVectorType::get(Type::getFloatTy(Context), 4); |
507 | case MVT::nxv8f32: |
508 | return ScalableVectorType::get(Type::getFloatTy(Context), 8); |
509 | case MVT::nxv16f32: |
510 | return ScalableVectorType::get(Type::getFloatTy(Context), 16); |
511 | case MVT::nxv1f64: |
512 | return ScalableVectorType::get(Type::getDoubleTy(Context), 1); |
513 | case MVT::nxv2f64: |
514 | return ScalableVectorType::get(Type::getDoubleTy(Context), 2); |
515 | case MVT::nxv4f64: |
516 | return ScalableVectorType::get(Type::getDoubleTy(Context), 4); |
517 | case MVT::nxv8f64: |
518 | return ScalableVectorType::get(Type::getDoubleTy(Context), 8); |
519 | case MVT::Metadata: return Type::getMetadataTy(Context); |
520 | } |
521 | } |
522 | |
523 | |
524 | |
525 | |
526 | MVT MVT::getVT(Type *Ty, bool HandleUnknown){ |
527 | switch (Ty->getTypeID()) { |
528 | default: |
529 | if (HandleUnknown) return MVT(MVT::Other); |
530 | llvm_unreachable("Unknown type!"); |
531 | case Type::VoidTyID: |
532 | return MVT::isVoid; |
533 | case Type::IntegerTyID: |
534 | return getIntegerVT(cast<IntegerType>(Ty)->getBitWidth()); |
535 | case Type::HalfTyID: return MVT(MVT::f16); |
536 | case Type::BFloatTyID: return MVT(MVT::bf16); |
537 | case Type::FloatTyID: return MVT(MVT::f32); |
538 | case Type::DoubleTyID: return MVT(MVT::f64); |
539 | case Type::X86_FP80TyID: return MVT(MVT::f80); |
540 | case Type::X86_MMXTyID: return MVT(MVT::x86mmx); |
541 | case Type::X86_AMXTyID: return MVT(MVT::x86amx); |
542 | case Type::FP128TyID: return MVT(MVT::f128); |
543 | case Type::PPC_FP128TyID: return MVT(MVT::ppcf128); |
544 | case Type::PointerTyID: return MVT(MVT::iPTR); |
545 | case Type::FixedVectorTyID: |
546 | case Type::ScalableVectorTyID: { |
547 | VectorType *VTy = cast<VectorType>(Ty); |
548 | return getVectorVT( |
549 | getVT(VTy->getElementType(), false), |
550 | VTy->getElementCount()); |
551 | } |
552 | } |
553 | } |
554 | |
555 | |
556 | |
557 | |
558 | EVT EVT::getEVT(Type *Ty, bool HandleUnknown){ |
559 | switch (Ty->getTypeID()) { |
560 | default: |
561 | return MVT::getVT(Ty, HandleUnknown); |
562 | case Type::IntegerTyID: |
563 | return getIntegerVT(Ty->getContext(), cast<IntegerType>(Ty)->getBitWidth()); |
564 | case Type::FixedVectorTyID: |
565 | case Type::ScalableVectorTyID: { |
566 | VectorType *VTy = cast<VectorType>(Ty); |
567 | return getVectorVT(Ty->getContext(), |
568 | getEVT(VTy->getElementType(), false), |
569 | VTy->getElementCount()); |
570 | } |
571 | } |
572 | } |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | #ifndef LLVM_CODEGEN_VALUETYPES_H |
16 | #define LLVM_CODEGEN_VALUETYPES_H |
17 | |
18 | #include "llvm/Support/Compiler.h" |
19 | #include "llvm/Support/MachineValueType.h" |
20 | #include "llvm/Support/MathExtras.h" |
21 | #include "llvm/Support/TypeSize.h" |
22 | #include "llvm/Support/WithColor.h" |
23 | #include <cassert> |
24 | #include <cstdint> |
25 | #include <string> |
26 | |
27 | namespace llvm { |
28 | |
29 | class LLVMContext; |
30 | class Type; |
31 | |
32 | |
33 | |
34 | |
35 | struct EVT { |
36 | private: |
37 | MVT V = MVT::INVALID_SIMPLE_VALUE_TYPE; |
38 | Type *LLVMTy = nullptr; |
| 12 | | Null pointer value stored to field 'LLVMTy' | |
|
39 | |
40 | public: |
41 | constexpr EVT() = default; |
42 | constexpr EVT(MVT::SimpleValueType SVT) : V(SVT) {} |
43 | constexpr EVT(MVT S) : V(S) {} |
44 | |
45 | bool operator==(EVT VT) const { |
46 | return !(*this != VT); |
47 | } |
48 | bool operator!=(EVT VT) const { |
49 | if (V.SimpleTy != VT.V.SimpleTy) |
50 | return true; |
51 | if (V.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE) |
52 | return LLVMTy != VT.LLVMTy; |
53 | return false; |
54 | } |
55 | |
56 | |
57 | |
58 | |
59 | static EVT getFloatingPointVT(unsigned BitWidth) { |
60 | return MVT::getFloatingPointVT(BitWidth); |
61 | } |
62 | |
63 | |
64 | |
65 | static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth) { |
66 | MVT M = MVT::getIntegerVT(BitWidth); |
67 | if (M.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE) |
68 | return M; |
69 | return getExtendedIntegerVT(Context, BitWidth); |
70 | } |
71 | |
72 | |
73 | |
74 | static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements, |
75 | bool IsScalable = false) { |
76 | MVT M = MVT::getVectorVT(VT.V, NumElements, IsScalable); |
77 | if (M.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE) |
78 | return M; |
79 | return getExtendedVectorVT(Context, VT, NumElements, IsScalable); |
80 | } |
81 | |
82 | |
83 | |
84 | static EVT getVectorVT(LLVMContext &Context, EVT VT, ElementCount EC) { |
85 | MVT M = MVT::getVectorVT(VT.V, EC); |
86 | if (M.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE) |
87 | return M; |
88 | return getExtendedVectorVT(Context, VT, EC); |
89 | } |
90 | |
91 | |
92 | |
93 | |
94 | EVT changeVectorElementTypeToInteger() const { |
95 | if (isSimple()) |
96 | return getSimpleVT().changeVectorElementTypeToInteger(); |
97 | return changeExtendedVectorElementTypeToInteger(); |
98 | } |
99 | |
100 | |
101 | |
102 | EVT changeVectorElementType(EVT EltVT) const { |
103 | if (isSimple()) { |
104 | assert(EltVT.isSimple() && |
105 | "Can't change simple vector VT to have extended element VT"); |
106 | return getSimpleVT().changeVectorElementType(EltVT.getSimpleVT()); |
107 | } |
108 | return changeExtendedVectorElementType(EltVT); |
109 | } |
110 | |
111 | |
112 | |
113 | |
114 | EVT changeTypeToInteger() { |
115 | if (isVector()) |
116 | return changeVectorElementTypeToInteger(); |
117 | |
118 | if (isSimple()) |
119 | return getSimpleVT().changeTypeToInteger(); |
120 | return changeExtendedTypeToInteger(); |
121 | } |
122 | |
123 | |
124 | |
125 | bool isZeroSized() const { |
126 | return !isScalableVector() && getSizeInBits() == 0; |
127 | } |
128 | |
129 | |
130 | bool isSimple() const { |
131 | return V.SimpleTy != MVT::INVALID_SIMPLE_VALUE_TYPE; |
132 | } |
133 | |
134 | |
135 | bool isExtended() const { |
136 | return !isSimple(); |
137 | } |
138 | |
139 | |
140 | bool isFloatingPoint() const { |
141 | return isSimple() ? V.isFloatingPoint() : isExtendedFloatingPoint(); |
142 | } |
143 | |
144 | |
145 | bool isInteger() const { |
146 | return isSimple() ? V.isInteger() : isExtendedInteger(); |
147 | } |
148 | |
149 | |
150 | bool isScalarInteger() const { |
151 | return isSimple() ? V.isScalarInteger() : isExtendedScalarInteger(); |
152 | } |
153 | |
154 | |
155 | bool isVector() const { |
156 | return isSimple() ? V.isVector() : isExtendedVector(); |
| |
| 19 | | Calling 'EVT::isExtendedVector' | |
|
157 | } |
158 | |
159 | |
160 | |
161 | bool isScalableVector() const { |
162 | return isSimple() ? V.isScalableVector() : isExtendedScalableVector(); |
163 | } |
164 | |
165 | bool isFixedLengthVector() const { |
166 | return isSimple() ? V.isFixedLengthVector() |
167 | : isExtendedFixedLengthVector(); |
168 | } |
169 | |
170 | |
171 | bool is16BitVector() const { |
172 | return isSimple() ? V.is16BitVector() : isExtended16BitVector(); |
173 | } |
174 | |
175 | |
176 | bool is32BitVector() const { |
177 | return isSimple() ? V.is32BitVector() : isExtended32BitVector(); |
178 | } |
179 | |
180 | |
181 | bool is64BitVector() const { |
182 | return isSimple() ? V.is64BitVector() : isExtended64BitVector(); |
183 | } |
184 | |
185 | |
186 | bool is128BitVector() const { |
187 | return isSimple() ? V.is128BitVector() : isExtended128BitVector(); |
188 | } |
189 | |
190 | |
191 | bool is256BitVector() const { |
192 | return isSimple() ? V.is256BitVector() : isExtended256BitVector(); |
193 | } |
194 | |
195 | |
196 | bool is512BitVector() const { |
197 | return isSimple() ? V.is512BitVector() : isExtended512BitVector(); |
198 | } |
199 | |
200 | |
201 | bool is1024BitVector() const { |
202 | return isSimple() ? V.is1024BitVector() : isExtended1024BitVector(); |
203 | } |
204 | |
205 | |
206 | bool is2048BitVector() const { |
207 | return isSimple() ? V.is2048BitVector() : isExtended2048BitVector(); |
208 | } |
209 | |
210 | |
211 | bool isOverloaded() const { |
212 | return (V==MVT::iAny || V==MVT::fAny || V==MVT::vAny || V==MVT::iPTRAny); |
213 | } |
214 | |
215 | |
216 | bool isByteSized() const { |
217 | return !isZeroSized() && getSizeInBits().isKnownMultipleOf(8); |
218 | } |
219 | |
220 | |
221 | bool isRound() const { |
222 | if (isScalableVector()) |
223 | return false; |
224 | unsigned BitSize = getSizeInBits(); |
225 | return BitSize >= 8 && !(BitSize & (BitSize - 1)); |
226 | } |
227 | |
228 | |
229 | bool bitsEq(EVT VT) const { |
230 | if (EVT::operator==(VT)) return true; |
231 | return getSizeInBits() == VT.getSizeInBits(); |
232 | } |
233 | |
234 | |
235 | bool knownBitsGT(EVT VT) const { |
236 | return TypeSize::isKnownGT(getSizeInBits(), VT.getSizeInBits()); |
237 | } |
238 | |
239 | |
240 | |
241 | bool knownBitsGE(EVT VT) const { |
242 | return TypeSize::isKnownGE(getSizeInBits(), VT.getSizeInBits()); |
243 | } |
244 | |
245 | |
246 | bool knownBitsLT(EVT VT) const { |
247 | return TypeSize::isKnownLT(getSizeInBits(), VT.getSizeInBits()); |
248 | } |
249 | |
250 | |
251 | |
252 | bool knownBitsLE(EVT VT) const { |
253 | return TypeSize::isKnownLE(getSizeInBits(), VT.getSizeInBits()); |
254 | } |
255 | |
256 | |
257 | bool bitsGT(EVT VT) const { |
258 | if (EVT::operator==(VT)) return false; |
259 | assert(isScalableVector() == VT.isScalableVector() && |
260 | "Comparison between scalable and fixed types"); |
261 | return knownBitsGT(VT); |
262 | } |
263 | |
264 | |
265 | bool bitsGE(EVT VT) const { |
266 | if (EVT::operator==(VT)) return true; |
267 | assert(isScalableVector() == VT.isScalableVector() && |
268 | "Comparison between scalable and fixed types"); |
269 | return knownBitsGE(VT); |
270 | } |
271 | |
272 | |
273 | bool bitsLT(EVT VT) const { |
274 | if (EVT::operator==(VT)) return false; |
275 | assert(isScalableVector() == VT.isScalableVector() && |
276 | "Comparison between scalable and fixed types"); |
277 | return knownBitsLT(VT); |
278 | } |
279 | |
280 | |
281 | bool bitsLE(EVT VT) const { |
282 | if (EVT::operator==(VT)) return true; |
283 | assert(isScalableVector() == VT.isScalableVector() && |
284 | "Comparison between scalable and fixed types"); |
285 | return knownBitsLE(VT); |
286 | } |
287 | |
288 | |
289 | MVT getSimpleVT() const { |
290 | assert(isSimple() && "Expected a SimpleValueType!"); |
291 | return V; |
292 | } |
293 | |
294 | |
295 | |
296 | EVT getScalarType() const { |
297 | return isVector() ? getVectorElementType() : *this; |
298 | } |
299 | |
300 | |
301 | EVT getVectorElementType() const { |
302 | assert(isVector() && "Invalid vector type!"); |
303 | if (isSimple()) |
| 9 | | Assuming the condition is true | |
|
| |
304 | return V.getVectorElementType(); |
| 11 | | Calling constructor for 'EVT' | |
|
| 13 | | Returning from constructor for 'EVT' | |
|
305 | return getExtendedVectorElementType(); |
306 | } |
307 | |
308 | |
309 | unsigned getVectorNumElements() const { |
310 | assert(isVector() && "Invalid vector type!"); |
311 | |
312 | if (isScalableVector()) |
313 | llvm::reportInvalidSizeRequest( |
314 | "Possible incorrect use of EVT::getVectorNumElements() for " |
315 | "scalable vector. Scalable flag may be dropped, use " |
316 | "EVT::getVectorElementCount() instead"); |
317 | |
318 | return isSimple() ? V.getVectorNumElements() |
319 | : getExtendedVectorNumElements(); |
320 | } |
321 | |
322 | |
323 | ElementCount getVectorElementCount() const { |
324 | assert((isVector()) && "Invalid vector type!"); |
325 | if (isSimple()) |
326 | return V.getVectorElementCount(); |
327 | |
328 | return getExtendedVectorElementCount(); |
329 | } |
330 | |
331 | |
332 | unsigned getVectorMinNumElements() const { |
333 | return getVectorElementCount().getKnownMinValue(); |
334 | } |
335 | |
336 | |
337 | |
338 | |
339 | |
340 | |
341 | TypeSize getSizeInBits() const { |
342 | if (isSimple()) |
343 | return V.getSizeInBits(); |
344 | return getExtendedSizeInBits(); |
345 | } |
346 | |
347 | |
348 | |
349 | uint64_t getFixedSizeInBits() const { |
350 | return getSizeInBits().getFixedSize(); |
351 | } |
352 | |
353 | uint64_t getScalarSizeInBits() const { |
354 | return getScalarType().getSizeInBits().getFixedSize(); |
355 | } |
356 | |
357 | |
358 | |
359 | |
360 | |
361 | |
362 | |
363 | TypeSize getStoreSize() const { |
364 | TypeSize BaseSize = getSizeInBits(); |
365 | return {(BaseSize.getKnownMinSize() + 7) / 8, BaseSize.isScalable()}; |
366 | } |
367 | |
368 | |
369 | |
370 | |
371 | |
372 | |
373 | |
374 | TypeSize getStoreSizeInBits() const { |
375 | return getStoreSize() * 8; |
376 | } |
377 | |
378 | |
379 | |
380 | |
381 | EVT getRoundIntegerType(LLVMContext &Context) const { |
382 | assert(isInteger() && !isVector() && "Invalid integer type!"); |
383 | unsigned BitWidth = getSizeInBits(); |
384 | if (BitWidth <= 8) |
385 | return EVT(MVT::i8); |
386 | return getIntegerVT(Context, 1 << Log2_32_Ceil(BitWidth)); |
387 | } |
388 | |
389 | |
390 | |
391 | |
392 | EVT getHalfSizedIntegerVT(LLVMContext &Context) const { |
393 | assert(isInteger() && !isVector() && "Invalid integer type!"); |
394 | unsigned EVTSize = getSizeInBits(); |
395 | for (unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE; |
396 | IntVT <= MVT::LAST_INTEGER_VALUETYPE; ++IntVT) { |
397 | EVT HalfVT = EVT((MVT::SimpleValueType)IntVT); |
398 | if (HalfVT.getSizeInBits() * 2 >= EVTSize) |
399 | return HalfVT; |
400 | } |
401 | return getIntegerVT(Context, (EVTSize + 1) / 2); |
402 | } |
403 | |
404 | |
405 | |
406 | EVT widenIntegerVectorElementType(LLVMContext &Context) const { |
407 | EVT EltVT = getVectorElementType(); |
408 | EltVT = EVT::getIntegerVT(Context, 2 * EltVT.getSizeInBits()); |
409 | return EVT::getVectorVT(Context, EltVT, getVectorElementCount()); |
410 | } |
411 | |
412 | |
413 | |
414 | |
415 | EVT getHalfNumVectorElementsVT(LLVMContext &Context) const { |
416 | EVT EltVT = getVectorElementType(); |
417 | auto EltCnt = getVectorElementCount(); |
418 | assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!"); |
419 | return EVT::getVectorVT(Context, EltVT, EltCnt.divideCoefficientBy(2)); |
420 | } |
421 | |
422 | |
423 | |
424 | |
425 | EVT getDoubleNumVectorElementsVT(LLVMContext &Context) const { |
426 | EVT EltVT = getVectorElementType(); |
427 | auto EltCnt = getVectorElementCount(); |
428 | return EVT::getVectorVT(Context, EltVT, EltCnt * 2); |
429 | } |
430 | |
431 | |
432 | bool isPow2VectorType() const { |
433 | unsigned NElts = getVectorMinNumElements(); |
434 | return !(NElts & (NElts - 1)); |
435 | } |
436 | |
437 | |
438 | |
439 | EVT getPow2VectorType(LLVMContext &Context) const { |
440 | if (!isPow2VectorType()) { |
441 | ElementCount NElts = getVectorElementCount(); |
442 | unsigned NewMinCount = 1 << Log2_32_Ceil(NElts.getKnownMinValue()); |
443 | NElts = ElementCount::get(NewMinCount, NElts.isScalable()); |
444 | return EVT::getVectorVT(Context, getVectorElementType(), NElts); |
445 | } |
446 | else { |
447 | return *this; |
448 | } |
449 | } |
450 | |
451 | |
452 | std::string getEVTString() const; |
453 | |
454 | |
455 | |
456 | |
457 | Type *getTypeForEVT(LLVMContext &Context) const; |
458 | |
459 | |
460 | |
461 | |
462 | static EVT getEVT(Type *Ty, bool HandleUnknown = false); |
463 | |
464 | intptr_t getRawBits() const { |
465 | if (isSimple()) |
466 | return V.SimpleTy; |
467 | else |
468 | return (intptr_t)(LLVMTy); |
469 | } |
470 | |
471 | |
472 | |
473 | struct compareRawBits { |
474 | bool operator()(EVT L, EVT R) const { |
475 | if (L.V.SimpleTy == R.V.SimpleTy) |
476 | return L.LLVMTy < R.LLVMTy; |
477 | else |
478 | return L.V.SimpleTy < R.V.SimpleTy; |
479 | } |
480 | }; |
481 | |
482 | private: |
483 | |
484 | |
485 | |
486 | EVT changeExtendedTypeToInteger() const; |
487 | EVT changeExtendedVectorElementType(EVT EltVT) const; |
488 | EVT changeExtendedVectorElementTypeToInteger() const; |
489 | static EVT getExtendedIntegerVT(LLVMContext &C, unsigned BitWidth); |
490 | static EVT getExtendedVectorVT(LLVMContext &C, EVT VT, unsigned NumElements, |
491 | bool IsScalable); |
492 | static EVT getExtendedVectorVT(LLVMContext &Context, EVT VT, |
493 | ElementCount EC); |
494 | bool isExtendedFloatingPoint() const LLVM_READONLY; |
495 | bool isExtendedInteger() const LLVM_READONLY; |
496 | bool isExtendedScalarInteger() const LLVM_READONLY; |
497 | bool isExtendedVector() const LLVM_READONLY; |
498 | bool isExtended16BitVector() const LLVM_READONLY; |
499 | bool isExtended32BitVector() const LLVM_READONLY; |
500 | bool isExtended64BitVector() const LLVM_READONLY; |
501 | bool isExtended128BitVector() const LLVM_READONLY; |
502 | bool isExtended256BitVector() const LLVM_READONLY; |
503 | bool isExtended512BitVector() const LLVM_READONLY; |
504 | bool isExtended1024BitVector() const LLVM_READONLY; |
505 | bool isExtended2048BitVector() const LLVM_READONLY; |
506 | bool isExtendedFixedLengthVector() const LLVM_READONLY; |
507 | bool isExtendedScalableVector() const LLVM_READONLY; |
508 | EVT getExtendedVectorElementType() const; |
509 | unsigned getExtendedVectorNumElements() const LLVM_READONLY; |
510 | ElementCount getExtendedVectorElementCount() const LLVM_READONLY; |
511 | TypeSize getExtendedSizeInBits() const LLVM_READONLY; |
512 | }; |
513 | |
514 | } |
515 | |
516 | #endif // LLVM_CODEGEN_VALUETYPES_H |