annotate llvm/lib/CodeGen/ValueTypes.cpp @ 174:f935e5e0dbe7

merged
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 12:28:41 +0900
parents e8a9b4f4d755 0572611fdcc8
children dd44ba33042e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 //===----------- ValueTypes.cpp - Implementation of EVT methods -----------===//
anatofuz
parents:
diff changeset
2 //
anatofuz
parents:
diff changeset
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
anatofuz
parents:
diff changeset
4 // See https://llvm.org/LICENSE.txt for license information.
anatofuz
parents:
diff changeset
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
anatofuz
parents:
diff changeset
6 //
anatofuz
parents:
diff changeset
7 //===----------------------------------------------------------------------===//
anatofuz
parents:
diff changeset
8
anatofuz
parents:
diff changeset
9 #include "llvm/CodeGen/ValueTypes.h"
anatofuz
parents:
diff changeset
10 #include "llvm/ADT/StringExtras.h"
anatofuz
parents:
diff changeset
11 #include "llvm/IR/DerivedTypes.h"
anatofuz
parents:
diff changeset
12 #include "llvm/IR/Type.h"
anatofuz
parents:
diff changeset
13 #include "llvm/Support/ErrorHandling.h"
anatofuz
parents:
diff changeset
14 #include "llvm/Support/TypeSize.h"
anatofuz
parents:
diff changeset
15 using namespace llvm;
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 EVT EVT::changeExtendedTypeToInteger() const {
anatofuz
parents:
diff changeset
18 LLVMContext &Context = LLVMTy->getContext();
anatofuz
parents:
diff changeset
19 return getIntegerVT(Context, getSizeInBits());
anatofuz
parents:
diff changeset
20 }
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 EVT EVT::changeExtendedVectorElementTypeToInteger() const {
anatofuz
parents:
diff changeset
23 LLVMContext &Context = LLVMTy->getContext();
anatofuz
parents:
diff changeset
24 EVT IntTy = getIntegerVT(Context, getScalarSizeInBits());
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
25 return getVectorVT(Context, IntTy, getVectorNumElements(),
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
26 isScalableVector());
150
anatofuz
parents:
diff changeset
27 }
anatofuz
parents:
diff changeset
28
anatofuz
parents:
diff changeset
29 EVT EVT::getExtendedIntegerVT(LLVMContext &Context, unsigned BitWidth) {
anatofuz
parents:
diff changeset
30 EVT VT;
anatofuz
parents:
diff changeset
31 VT.LLVMTy = IntegerType::get(Context, BitWidth);
anatofuz
parents:
diff changeset
32 assert(VT.isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
33 return VT;
anatofuz
parents:
diff changeset
34 }
anatofuz
parents:
diff changeset
35
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
36 EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements,
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
37 bool IsScalable) {
150
anatofuz
parents:
diff changeset
38 EVT ResultVT;
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
39 ResultVT.LLVMTy =
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
40 VectorType::get(VT.getTypeForEVT(Context), NumElements, IsScalable);
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
41 assert(ResultVT.isExtended() && "Type is not extended!");
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
42 return ResultVT;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
43 }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
44
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
45 EVT EVT::getExtendedVectorVT(LLVMContext &Context, EVT VT, ElementCount EC) {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
46 EVT ResultVT;
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
47 ResultVT.LLVMTy =
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
48 VectorType::get(VT.getTypeForEVT(Context), {EC.Min, EC.Scalable});
150
anatofuz
parents:
diff changeset
49 assert(ResultVT.isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
50 return ResultVT;
anatofuz
parents:
diff changeset
51 }
anatofuz
parents:
diff changeset
52
anatofuz
parents:
diff changeset
53 bool EVT::isExtendedFloatingPoint() const {
anatofuz
parents:
diff changeset
54 assert(isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
55 return LLVMTy->isFPOrFPVectorTy();
anatofuz
parents:
diff changeset
56 }
anatofuz
parents:
diff changeset
57
anatofuz
parents:
diff changeset
58 bool EVT::isExtendedInteger() const {
anatofuz
parents:
diff changeset
59 assert(isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
60 return LLVMTy->isIntOrIntVectorTy();
anatofuz
parents:
diff changeset
61 }
anatofuz
parents:
diff changeset
62
anatofuz
parents:
diff changeset
63 bool EVT::isExtendedScalarInteger() const {
anatofuz
parents:
diff changeset
64 assert(isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
65 return LLVMTy->isIntegerTy();
anatofuz
parents:
diff changeset
66 }
anatofuz
parents:
diff changeset
67
anatofuz
parents:
diff changeset
68 bool EVT::isExtendedVector() const {
anatofuz
parents:
diff changeset
69 assert(isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
70 return LLVMTy->isVectorTy();
anatofuz
parents:
diff changeset
71 }
anatofuz
parents:
diff changeset
72
anatofuz
parents:
diff changeset
73 bool EVT::isExtended16BitVector() const {
anatofuz
parents:
diff changeset
74 return isExtendedVector() && getExtendedSizeInBits() == 16;
anatofuz
parents:
diff changeset
75 }
anatofuz
parents:
diff changeset
76
anatofuz
parents:
diff changeset
77 bool EVT::isExtended32BitVector() const {
anatofuz
parents:
diff changeset
78 return isExtendedVector() && getExtendedSizeInBits() == 32;
anatofuz
parents:
diff changeset
79 }
anatofuz
parents:
diff changeset
80
anatofuz
parents:
diff changeset
81 bool EVT::isExtended64BitVector() const {
anatofuz
parents:
diff changeset
82 return isExtendedVector() && getExtendedSizeInBits() == 64;
anatofuz
parents:
diff changeset
83 }
anatofuz
parents:
diff changeset
84
anatofuz
parents:
diff changeset
85 bool EVT::isExtended128BitVector() const {
anatofuz
parents:
diff changeset
86 return isExtendedVector() && getExtendedSizeInBits() == 128;
anatofuz
parents:
diff changeset
87 }
anatofuz
parents:
diff changeset
88
anatofuz
parents:
diff changeset
89 bool EVT::isExtended256BitVector() const {
anatofuz
parents:
diff changeset
90 return isExtendedVector() && getExtendedSizeInBits() == 256;
anatofuz
parents:
diff changeset
91 }
anatofuz
parents:
diff changeset
92
anatofuz
parents:
diff changeset
93 bool EVT::isExtended512BitVector() const {
anatofuz
parents:
diff changeset
94 return isExtendedVector() && getExtendedSizeInBits() == 512;
anatofuz
parents:
diff changeset
95 }
anatofuz
parents:
diff changeset
96
anatofuz
parents:
diff changeset
97 bool EVT::isExtended1024BitVector() const {
anatofuz
parents:
diff changeset
98 return isExtendedVector() && getExtendedSizeInBits() == 1024;
anatofuz
parents:
diff changeset
99 }
anatofuz
parents:
diff changeset
100
anatofuz
parents:
diff changeset
101 bool EVT::isExtended2048BitVector() const {
anatofuz
parents:
diff changeset
102 return isExtendedVector() && getExtendedSizeInBits() == 2048;
anatofuz
parents:
diff changeset
103 }
anatofuz
parents:
diff changeset
104
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
105 bool EVT::isExtendedFixedLengthVector() const {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
106 return isExtendedVector() && isa<FixedVectorType>(LLVMTy);
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
107 }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
108
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
109 bool EVT::isExtendedScalableVector() const {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
110 return isExtendedVector() && isa<ScalableVectorType>(LLVMTy);
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
111 }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
112
150
anatofuz
parents:
diff changeset
113 EVT EVT::getExtendedVectorElementType() const {
anatofuz
parents:
diff changeset
114 assert(isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
115 return EVT::getEVT(cast<VectorType>(LLVMTy)->getElementType());
anatofuz
parents:
diff changeset
116 }
anatofuz
parents:
diff changeset
117
anatofuz
parents:
diff changeset
118 unsigned EVT::getExtendedVectorNumElements() const {
anatofuz
parents:
diff changeset
119 assert(isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
120 return cast<VectorType>(LLVMTy)->getNumElements();
anatofuz
parents:
diff changeset
121 }
anatofuz
parents:
diff changeset
122
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
123 ElementCount EVT::getExtendedVectorElementCount() const {
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
124 assert(isExtended() && "Type is not extended!");
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
125 return cast<VectorType>(LLVMTy)->getElementCount();
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
126 }
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
127
150
anatofuz
parents:
diff changeset
128 TypeSize EVT::getExtendedSizeInBits() const {
anatofuz
parents:
diff changeset
129 assert(isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
130 if (IntegerType *ITy = dyn_cast<IntegerType>(LLVMTy))
anatofuz
parents:
diff changeset
131 return TypeSize::Fixed(ITy->getBitWidth());
anatofuz
parents:
diff changeset
132 if (VectorType *VTy = dyn_cast<VectorType>(LLVMTy))
anatofuz
parents:
diff changeset
133 return VTy->getPrimitiveSizeInBits();
anatofuz
parents:
diff changeset
134 llvm_unreachable("Unrecognized extended type!");
anatofuz
parents:
diff changeset
135 }
anatofuz
parents:
diff changeset
136
anatofuz
parents:
diff changeset
137 /// getEVTString - This function returns value type as a string, e.g. "i32".
anatofuz
parents:
diff changeset
138 std::string EVT::getEVTString() const {
anatofuz
parents:
diff changeset
139 switch (V.SimpleTy) {
anatofuz
parents:
diff changeset
140 default:
anatofuz
parents:
diff changeset
141 if (isVector())
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
142 return (isScalableVector() ? "nxv" : "v")
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
143 + utostr(getVectorElementCount().Min)
150
anatofuz
parents:
diff changeset
144 + getVectorElementType().getEVTString();
anatofuz
parents:
diff changeset
145 if (isInteger())
anatofuz
parents:
diff changeset
146 return "i" + utostr(getSizeInBits());
anatofuz
parents:
diff changeset
147 if (isFloatingPoint())
anatofuz
parents:
diff changeset
148 return "f" + utostr(getSizeInBits());
anatofuz
parents:
diff changeset
149 llvm_unreachable("Invalid EVT!");
anatofuz
parents:
diff changeset
150 case MVT::ppcf128: return "ppcf128";
anatofuz
parents:
diff changeset
151 case MVT::isVoid: return "isVoid";
anatofuz
parents:
diff changeset
152 case MVT::Other: return "ch";
anatofuz
parents:
diff changeset
153 case MVT::Glue: return "glue";
anatofuz
parents:
diff changeset
154 case MVT::x86mmx: return "x86mmx";
anatofuz
parents:
diff changeset
155 case MVT::Metadata:return "Metadata";
anatofuz
parents:
diff changeset
156 case MVT::Untyped: return "Untyped";
anatofuz
parents:
diff changeset
157 case MVT::exnref : return "exnref";
anatofuz
parents:
diff changeset
158 }
anatofuz
parents:
diff changeset
159 }
anatofuz
parents:
diff changeset
160
anatofuz
parents:
diff changeset
161 /// getTypeForEVT - This method returns an LLVM type corresponding to the
anatofuz
parents:
diff changeset
162 /// specified EVT. For integer types, this returns an unsigned type. Note
anatofuz
parents:
diff changeset
163 /// that this will abort for types that cannot be represented.
anatofuz
parents:
diff changeset
164 Type *EVT::getTypeForEVT(LLVMContext &Context) const {
anatofuz
parents:
diff changeset
165 switch (V.SimpleTy) {
anatofuz
parents:
diff changeset
166 default:
anatofuz
parents:
diff changeset
167 assert(isExtended() && "Type is not extended!");
anatofuz
parents:
diff changeset
168 return LLVMTy;
anatofuz
parents:
diff changeset
169 case MVT::isVoid: return Type::getVoidTy(Context);
anatofuz
parents:
diff changeset
170 case MVT::i1: return Type::getInt1Ty(Context);
anatofuz
parents:
diff changeset
171 case MVT::i8: return Type::getInt8Ty(Context);
anatofuz
parents:
diff changeset
172 case MVT::i16: return Type::getInt16Ty(Context);
anatofuz
parents:
diff changeset
173 case MVT::i32: return Type::getInt32Ty(Context);
anatofuz
parents:
diff changeset
174 case MVT::i64: return Type::getInt64Ty(Context);
anatofuz
parents:
diff changeset
175 case MVT::i128: return IntegerType::get(Context, 128);
anatofuz
parents:
diff changeset
176 case MVT::f16: return Type::getHalfTy(Context);
anatofuz
parents:
diff changeset
177 case MVT::f32: return Type::getFloatTy(Context);
anatofuz
parents:
diff changeset
178 case MVT::f64: return Type::getDoubleTy(Context);
anatofuz
parents:
diff changeset
179 case MVT::f80: return Type::getX86_FP80Ty(Context);
anatofuz
parents:
diff changeset
180 case MVT::f128: return Type::getFP128Ty(Context);
anatofuz
parents:
diff changeset
181 case MVT::ppcf128: return Type::getPPC_FP128Ty(Context);
anatofuz
parents:
diff changeset
182 case MVT::x86mmx: return Type::getX86_MMXTy(Context);
anatofuz
parents:
diff changeset
183 case MVT::v1i1: return VectorType::get(Type::getInt1Ty(Context), 1);
anatofuz
parents:
diff changeset
184 case MVT::v2i1: return VectorType::get(Type::getInt1Ty(Context), 2);
anatofuz
parents:
diff changeset
185 case MVT::v4i1: return VectorType::get(Type::getInt1Ty(Context), 4);
anatofuz
parents:
diff changeset
186 case MVT::v8i1: return VectorType::get(Type::getInt1Ty(Context), 8);
anatofuz
parents:
diff changeset
187 case MVT::v16i1: return VectorType::get(Type::getInt1Ty(Context), 16);
anatofuz
parents:
diff changeset
188 case MVT::v32i1: return VectorType::get(Type::getInt1Ty(Context), 32);
anatofuz
parents:
diff changeset
189 case MVT::v64i1: return VectorType::get(Type::getInt1Ty(Context), 64);
anatofuz
parents:
diff changeset
190 case MVT::v128i1: return VectorType::get(Type::getInt1Ty(Context), 128);
anatofuz
parents:
diff changeset
191 case MVT::v256i1: return VectorType::get(Type::getInt1Ty(Context), 256);
anatofuz
parents:
diff changeset
192 case MVT::v512i1: return VectorType::get(Type::getInt1Ty(Context), 512);
anatofuz
parents:
diff changeset
193 case MVT::v1024i1: return VectorType::get(Type::getInt1Ty(Context), 1024);
anatofuz
parents:
diff changeset
194 case MVT::v1i8: return VectorType::get(Type::getInt8Ty(Context), 1);
anatofuz
parents:
diff changeset
195 case MVT::v2i8: return VectorType::get(Type::getInt8Ty(Context), 2);
anatofuz
parents:
diff changeset
196 case MVT::v4i8: return VectorType::get(Type::getInt8Ty(Context), 4);
anatofuz
parents:
diff changeset
197 case MVT::v8i8: return VectorType::get(Type::getInt8Ty(Context), 8);
anatofuz
parents:
diff changeset
198 case MVT::v16i8: return VectorType::get(Type::getInt8Ty(Context), 16);
anatofuz
parents:
diff changeset
199 case MVT::v32i8: return VectorType::get(Type::getInt8Ty(Context), 32);
anatofuz
parents:
diff changeset
200 case MVT::v64i8: return VectorType::get(Type::getInt8Ty(Context), 64);
anatofuz
parents:
diff changeset
201 case MVT::v128i8: return VectorType::get(Type::getInt8Ty(Context), 128);
anatofuz
parents:
diff changeset
202 case MVT::v256i8: return VectorType::get(Type::getInt8Ty(Context), 256);
anatofuz
parents:
diff changeset
203 case MVT::v1i16: return VectorType::get(Type::getInt16Ty(Context), 1);
anatofuz
parents:
diff changeset
204 case MVT::v2i16: return VectorType::get(Type::getInt16Ty(Context), 2);
anatofuz
parents:
diff changeset
205 case MVT::v3i16: return VectorType::get(Type::getInt16Ty(Context), 3);
anatofuz
parents:
diff changeset
206 case MVT::v4i16: return VectorType::get(Type::getInt16Ty(Context), 4);
anatofuz
parents:
diff changeset
207 case MVT::v8i16: return VectorType::get(Type::getInt16Ty(Context), 8);
anatofuz
parents:
diff changeset
208 case MVT::v16i16: return VectorType::get(Type::getInt16Ty(Context), 16);
anatofuz
parents:
diff changeset
209 case MVT::v32i16: return VectorType::get(Type::getInt16Ty(Context), 32);
anatofuz
parents:
diff changeset
210 case MVT::v64i16: return VectorType::get(Type::getInt16Ty(Context), 64);
anatofuz
parents:
diff changeset
211 case MVT::v128i16: return VectorType::get(Type::getInt16Ty(Context), 128);
anatofuz
parents:
diff changeset
212 case MVT::v1i32: return VectorType::get(Type::getInt32Ty(Context), 1);
anatofuz
parents:
diff changeset
213 case MVT::v2i32: return VectorType::get(Type::getInt32Ty(Context), 2);
anatofuz
parents:
diff changeset
214 case MVT::v3i32: return VectorType::get(Type::getInt32Ty(Context), 3);
anatofuz
parents:
diff changeset
215 case MVT::v4i32: return VectorType::get(Type::getInt32Ty(Context), 4);
anatofuz
parents:
diff changeset
216 case MVT::v5i32: return VectorType::get(Type::getInt32Ty(Context), 5);
anatofuz
parents:
diff changeset
217 case MVT::v8i32: return VectorType::get(Type::getInt32Ty(Context), 8);
anatofuz
parents:
diff changeset
218 case MVT::v16i32: return VectorType::get(Type::getInt32Ty(Context), 16);
anatofuz
parents:
diff changeset
219 case MVT::v32i32: return VectorType::get(Type::getInt32Ty(Context), 32);
anatofuz
parents:
diff changeset
220 case MVT::v64i32: return VectorType::get(Type::getInt32Ty(Context), 64);
anatofuz
parents:
diff changeset
221 case MVT::v128i32: return VectorType::get(Type::getInt32Ty(Context), 128);
anatofuz
parents:
diff changeset
222 case MVT::v256i32: return VectorType::get(Type::getInt32Ty(Context), 256);
anatofuz
parents:
diff changeset
223 case MVT::v512i32: return VectorType::get(Type::getInt32Ty(Context), 512);
anatofuz
parents:
diff changeset
224 case MVT::v1024i32:return VectorType::get(Type::getInt32Ty(Context), 1024);
anatofuz
parents:
diff changeset
225 case MVT::v2048i32:return VectorType::get(Type::getInt32Ty(Context), 2048);
anatofuz
parents:
diff changeset
226 case MVT::v1i64: return VectorType::get(Type::getInt64Ty(Context), 1);
anatofuz
parents:
diff changeset
227 case MVT::v2i64: return VectorType::get(Type::getInt64Ty(Context), 2);
anatofuz
parents:
diff changeset
228 case MVT::v4i64: return VectorType::get(Type::getInt64Ty(Context), 4);
anatofuz
parents:
diff changeset
229 case MVT::v8i64: return VectorType::get(Type::getInt64Ty(Context), 8);
anatofuz
parents:
diff changeset
230 case MVT::v16i64: return VectorType::get(Type::getInt64Ty(Context), 16);
anatofuz
parents:
diff changeset
231 case MVT::v32i64: return VectorType::get(Type::getInt64Ty(Context), 32);
anatofuz
parents:
diff changeset
232 case MVT::v1i128: return VectorType::get(Type::getInt128Ty(Context), 1);
anatofuz
parents:
diff changeset
233 case MVT::v2f16: return VectorType::get(Type::getHalfTy(Context), 2);
anatofuz
parents:
diff changeset
234 case MVT::v3f16: return VectorType::get(Type::getHalfTy(Context), 3);
anatofuz
parents:
diff changeset
235 case MVT::v4f16: return VectorType::get(Type::getHalfTy(Context), 4);
anatofuz
parents:
diff changeset
236 case MVT::v8f16: return VectorType::get(Type::getHalfTy(Context), 8);
anatofuz
parents:
diff changeset
237 case MVT::v16f16: return VectorType::get(Type::getHalfTy(Context), 16);
anatofuz
parents:
diff changeset
238 case MVT::v32f16: return VectorType::get(Type::getHalfTy(Context), 32);
anatofuz
parents:
diff changeset
239 case MVT::v1f32: return VectorType::get(Type::getFloatTy(Context), 1);
anatofuz
parents:
diff changeset
240 case MVT::v2f32: return VectorType::get(Type::getFloatTy(Context), 2);
anatofuz
parents:
diff changeset
241 case MVT::v3f32: return VectorType::get(Type::getFloatTy(Context), 3);
anatofuz
parents:
diff changeset
242 case MVT::v4f32: return VectorType::get(Type::getFloatTy(Context), 4);
anatofuz
parents:
diff changeset
243 case MVT::v5f32: return VectorType::get(Type::getFloatTy(Context), 5);
anatofuz
parents:
diff changeset
244 case MVT::v8f32: return VectorType::get(Type::getFloatTy(Context), 8);
anatofuz
parents:
diff changeset
245 case MVT::v16f32: return VectorType::get(Type::getFloatTy(Context), 16);
anatofuz
parents:
diff changeset
246 case MVT::v32f32: return VectorType::get(Type::getFloatTy(Context), 32);
anatofuz
parents:
diff changeset
247 case MVT::v64f32: return VectorType::get(Type::getFloatTy(Context), 64);
anatofuz
parents:
diff changeset
248 case MVT::v128f32: return VectorType::get(Type::getFloatTy(Context), 128);
anatofuz
parents:
diff changeset
249 case MVT::v256f32: return VectorType::get(Type::getFloatTy(Context), 256);
anatofuz
parents:
diff changeset
250 case MVT::v512f32: return VectorType::get(Type::getFloatTy(Context), 512);
anatofuz
parents:
diff changeset
251 case MVT::v1024f32:return VectorType::get(Type::getFloatTy(Context), 1024);
anatofuz
parents:
diff changeset
252 case MVT::v2048f32:return VectorType::get(Type::getFloatTy(Context), 2048);
anatofuz
parents:
diff changeset
253 case MVT::v1f64: return VectorType::get(Type::getDoubleTy(Context), 1);
anatofuz
parents:
diff changeset
254 case MVT::v2f64: return VectorType::get(Type::getDoubleTy(Context), 2);
anatofuz
parents:
diff changeset
255 case MVT::v4f64: return VectorType::get(Type::getDoubleTy(Context), 4);
anatofuz
parents:
diff changeset
256 case MVT::v8f64: return VectorType::get(Type::getDoubleTy(Context), 8);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
257 case MVT::v16f64: return VectorType::get(Type::getDoubleTy(Context), 16);
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
258 case MVT::nxv1i1:
150
anatofuz
parents:
diff changeset
259 return VectorType::get(Type::getInt1Ty(Context), 1, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
260 case MVT::nxv2i1:
150
anatofuz
parents:
diff changeset
261 return VectorType::get(Type::getInt1Ty(Context), 2, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
262 case MVT::nxv4i1:
150
anatofuz
parents:
diff changeset
263 return VectorType::get(Type::getInt1Ty(Context), 4, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
264 case MVT::nxv8i1:
150
anatofuz
parents:
diff changeset
265 return VectorType::get(Type::getInt1Ty(Context), 8, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
266 case MVT::nxv16i1:
150
anatofuz
parents:
diff changeset
267 return VectorType::get(Type::getInt1Ty(Context), 16, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
268 case MVT::nxv32i1:
150
anatofuz
parents:
diff changeset
269 return VectorType::get(Type::getInt1Ty(Context), 32, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
270 case MVT::nxv1i8:
150
anatofuz
parents:
diff changeset
271 return VectorType::get(Type::getInt8Ty(Context), 1, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
272 case MVT::nxv2i8:
150
anatofuz
parents:
diff changeset
273 return VectorType::get(Type::getInt8Ty(Context), 2, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
274 case MVT::nxv4i8:
150
anatofuz
parents:
diff changeset
275 return VectorType::get(Type::getInt8Ty(Context), 4, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
276 case MVT::nxv8i8:
150
anatofuz
parents:
diff changeset
277 return VectorType::get(Type::getInt8Ty(Context), 8, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
278 case MVT::nxv16i8:
150
anatofuz
parents:
diff changeset
279 return VectorType::get(Type::getInt8Ty(Context), 16, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
280 case MVT::nxv32i8:
150
anatofuz
parents:
diff changeset
281 return VectorType::get(Type::getInt8Ty(Context), 32, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
282 case MVT::nxv1i16:
150
anatofuz
parents:
diff changeset
283 return VectorType::get(Type::getInt16Ty(Context), 1, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
284 case MVT::nxv2i16:
150
anatofuz
parents:
diff changeset
285 return VectorType::get(Type::getInt16Ty(Context), 2, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
286 case MVT::nxv4i16:
150
anatofuz
parents:
diff changeset
287 return VectorType::get(Type::getInt16Ty(Context), 4, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
288 case MVT::nxv8i16:
150
anatofuz
parents:
diff changeset
289 return VectorType::get(Type::getInt16Ty(Context), 8, /*Scalable=*/ true);
anatofuz
parents:
diff changeset
290 case MVT::nxv16i16:
anatofuz
parents:
diff changeset
291 return VectorType::get(Type::getInt16Ty(Context), 16, /*Scalable=*/ true);
anatofuz
parents:
diff changeset
292 case MVT::nxv32i16:
anatofuz
parents:
diff changeset
293 return VectorType::get(Type::getInt16Ty(Context), 32, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
294 case MVT::nxv1i32:
150
anatofuz
parents:
diff changeset
295 return VectorType::get(Type::getInt32Ty(Context), 1, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
296 case MVT::nxv2i32:
150
anatofuz
parents:
diff changeset
297 return VectorType::get(Type::getInt32Ty(Context), 2, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
298 case MVT::nxv4i32:
150
anatofuz
parents:
diff changeset
299 return VectorType::get(Type::getInt32Ty(Context), 4, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
300 case MVT::nxv8i32:
150
anatofuz
parents:
diff changeset
301 return VectorType::get(Type::getInt32Ty(Context), 8, /*Scalable=*/ true);
anatofuz
parents:
diff changeset
302 case MVT::nxv16i32:
anatofuz
parents:
diff changeset
303 return VectorType::get(Type::getInt32Ty(Context), 16,/*Scalable=*/ true);
anatofuz
parents:
diff changeset
304 case MVT::nxv32i32:
anatofuz
parents:
diff changeset
305 return VectorType::get(Type::getInt32Ty(Context), 32,/*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
306 case MVT::nxv1i64:
150
anatofuz
parents:
diff changeset
307 return VectorType::get(Type::getInt64Ty(Context), 1, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
308 case MVT::nxv2i64:
150
anatofuz
parents:
diff changeset
309 return VectorType::get(Type::getInt64Ty(Context), 2, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
310 case MVT::nxv4i64:
150
anatofuz
parents:
diff changeset
311 return VectorType::get(Type::getInt64Ty(Context), 4, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
312 case MVT::nxv8i64:
150
anatofuz
parents:
diff changeset
313 return VectorType::get(Type::getInt64Ty(Context), 8, /*Scalable=*/ true);
anatofuz
parents:
diff changeset
314 case MVT::nxv16i64:
anatofuz
parents:
diff changeset
315 return VectorType::get(Type::getInt64Ty(Context), 16, /*Scalable=*/ true);
anatofuz
parents:
diff changeset
316 case MVT::nxv32i64:
anatofuz
parents:
diff changeset
317 return VectorType::get(Type::getInt64Ty(Context), 32, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
318 case MVT::nxv2f16:
150
anatofuz
parents:
diff changeset
319 return VectorType::get(Type::getHalfTy(Context), 2, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
320 case MVT::nxv4f16:
150
anatofuz
parents:
diff changeset
321 return VectorType::get(Type::getHalfTy(Context), 4, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
322 case MVT::nxv8f16:
150
anatofuz
parents:
diff changeset
323 return VectorType::get(Type::getHalfTy(Context), 8, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
324 case MVT::nxv1f32:
150
anatofuz
parents:
diff changeset
325 return VectorType::get(Type::getFloatTy(Context), 1, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
326 case MVT::nxv2f32:
150
anatofuz
parents:
diff changeset
327 return VectorType::get(Type::getFloatTy(Context), 2, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
328 case MVT::nxv4f32:
150
anatofuz
parents:
diff changeset
329 return VectorType::get(Type::getFloatTy(Context), 4, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
330 case MVT::nxv8f32:
150
anatofuz
parents:
diff changeset
331 return VectorType::get(Type::getFloatTy(Context), 8, /*Scalable=*/ true);
anatofuz
parents:
diff changeset
332 case MVT::nxv16f32:
anatofuz
parents:
diff changeset
333 return VectorType::get(Type::getFloatTy(Context), 16, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
334 case MVT::nxv1f64:
150
anatofuz
parents:
diff changeset
335 return VectorType::get(Type::getDoubleTy(Context), 1, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
336 case MVT::nxv2f64:
150
anatofuz
parents:
diff changeset
337 return VectorType::get(Type::getDoubleTy(Context), 2, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
338 case MVT::nxv4f64:
150
anatofuz
parents:
diff changeset
339 return VectorType::get(Type::getDoubleTy(Context), 4, /*Scalable=*/ true);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
340 case MVT::nxv8f64:
150
anatofuz
parents:
diff changeset
341 return VectorType::get(Type::getDoubleTy(Context), 8, /*Scalable=*/ true);
anatofuz
parents:
diff changeset
342 case MVT::Metadata: return Type::getMetadataTy(Context);
anatofuz
parents:
diff changeset
343 }
anatofuz
parents:
diff changeset
344 }
anatofuz
parents:
diff changeset
345
anatofuz
parents:
diff changeset
346 /// Return the value type corresponding to the specified type. This returns all
anatofuz
parents:
diff changeset
347 /// pointers as MVT::iPTR. If HandleUnknown is true, unknown types are returned
anatofuz
parents:
diff changeset
348 /// as Other, otherwise they are invalid.
anatofuz
parents:
diff changeset
349 MVT MVT::getVT(Type *Ty, bool HandleUnknown){
anatofuz
parents:
diff changeset
350 switch (Ty->getTypeID()) {
anatofuz
parents:
diff changeset
351 default:
anatofuz
parents:
diff changeset
352 if (HandleUnknown) return MVT(MVT::Other);
anatofuz
parents:
diff changeset
353 llvm_unreachable("Unknown type!");
anatofuz
parents:
diff changeset
354 case Type::VoidTyID:
152
e8a9b4f4d755 pull from 146
anatofuz
parents: 150
diff changeset
355 #ifndef noCbC
e8a9b4f4d755 pull from 146
anatofuz
parents: 150
diff changeset
356 case Type::__CodeTyID:
e8a9b4f4d755 pull from 146
anatofuz
parents: 150
diff changeset
357 #endif
150
anatofuz
parents:
diff changeset
358 return MVT::isVoid;
anatofuz
parents:
diff changeset
359 case Type::IntegerTyID:
anatofuz
parents:
diff changeset
360 return getIntegerVT(cast<IntegerType>(Ty)->getBitWidth());
anatofuz
parents:
diff changeset
361 case Type::HalfTyID: return MVT(MVT::f16);
anatofuz
parents:
diff changeset
362 case Type::FloatTyID: return MVT(MVT::f32);
anatofuz
parents:
diff changeset
363 case Type::DoubleTyID: return MVT(MVT::f64);
anatofuz
parents:
diff changeset
364 case Type::X86_FP80TyID: return MVT(MVT::f80);
anatofuz
parents:
diff changeset
365 case Type::X86_MMXTyID: return MVT(MVT::x86mmx);
anatofuz
parents:
diff changeset
366 case Type::FP128TyID: return MVT(MVT::f128);
anatofuz
parents:
diff changeset
367 case Type::PPC_FP128TyID: return MVT(MVT::ppcf128);
anatofuz
parents:
diff changeset
368 case Type::PointerTyID: return MVT(MVT::iPTR);
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
369 case Type::FixedVectorTyID:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
370 case Type::ScalableVectorTyID: {
150
anatofuz
parents:
diff changeset
371 VectorType *VTy = cast<VectorType>(Ty);
anatofuz
parents:
diff changeset
372 return getVectorVT(
anatofuz
parents:
diff changeset
373 getVT(VTy->getElementType(), /*HandleUnknown=*/ false),
anatofuz
parents:
diff changeset
374 VTy->getElementCount());
anatofuz
parents:
diff changeset
375 }
anatofuz
parents:
diff changeset
376 }
anatofuz
parents:
diff changeset
377 }
anatofuz
parents:
diff changeset
378
anatofuz
parents:
diff changeset
379 /// getEVT - Return the value type corresponding to the specified type. This
anatofuz
parents:
diff changeset
380 /// returns all pointers as MVT::iPTR. If HandleUnknown is true, unknown types
anatofuz
parents:
diff changeset
381 /// are returned as Other, otherwise they are invalid.
anatofuz
parents:
diff changeset
382 EVT EVT::getEVT(Type *Ty, bool HandleUnknown){
anatofuz
parents:
diff changeset
383 switch (Ty->getTypeID()) {
anatofuz
parents:
diff changeset
384 default:
anatofuz
parents:
diff changeset
385 return MVT::getVT(Ty, HandleUnknown);
anatofuz
parents:
diff changeset
386 case Type::IntegerTyID:
anatofuz
parents:
diff changeset
387 return getIntegerVT(Ty->getContext(), cast<IntegerType>(Ty)->getBitWidth());
173
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
388 case Type::FixedVectorTyID:
0572611fdcc8 reorgnization done
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 150
diff changeset
389 case Type::ScalableVectorTyID: {
150
anatofuz
parents:
diff changeset
390 VectorType *VTy = cast<VectorType>(Ty);
anatofuz
parents:
diff changeset
391 return getVectorVT(Ty->getContext(),
anatofuz
parents:
diff changeset
392 getEVT(VTy->getElementType(), /*HandleUnknown=*/ false),
anatofuz
parents:
diff changeset
393 VTy->getElementCount());
anatofuz
parents:
diff changeset
394 }
anatofuz
parents:
diff changeset
395 }
anatofuz
parents:
diff changeset
396 }