LLVM 17.0.0git
MachineValueType.h
Go to the documentation of this file.
1//===- Support/MachineValueType.h - Machine-Level types ---------*- C++ -*-===//
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// This file defines the set of machine-level target independent types which
10// legal values in the code generator use.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_SUPPORT_MACHINEVALUETYPE_H
15#define LLVM_SUPPORT_MACHINEVALUETYPE_H
16
17#include "llvm/ADT/Sequence.h"
22#include <cassert>
23
24namespace llvm {
25
26 class Type;
27
28 /// Machine Value Type. Every type that is supported natively by some
29 /// processor targeted by LLVM occurs here. This means that any legal value
30 /// type can be represented by an MVT.
31 class MVT {
32 public:
33 enum SimpleValueType : uint8_t {
34 // clang-format off
35
36 // Simple value types that aren't explicitly part of this enumeration
37 // are considered extended value types.
39
40 // If you change this numbering, you must change the values in
41 // ValueTypes.td as well!
42 Other = 1, // This is a non-standard value
43 i1 = 2, // This is a 1 bit integer value
44 i2 = 3, // This is a 2 bit integer value
45 i4 = 4, // This is a 4 bit integer value
46 i8 = 5, // This is an 8 bit integer value
47 i16 = 6, // This is a 16 bit integer value
48 i32 = 7, // This is a 32 bit integer value
49 i64 = 8, // This is a 64 bit integer value
50 i128 = 9, // This is a 128 bit integer value
51
54
55 bf16 = 10, // This is a 16 bit brain floating point value
56 f16 = 11, // This is a 16 bit floating point value
57 f32 = 12, // This is a 32 bit floating point value
58 f64 = 13, // This is a 64 bit floating point value
59 f80 = 14, // This is a 80 bit floating point value
60 f128 = 15, // This is a 128 bit floating point value
61 ppcf128 = 16, // This is a PPC 128-bit floating point value
62
65
66 v1i1 = 17, // 1 x i1
67 v2i1 = 18, // 2 x i1
68 v4i1 = 19, // 4 x i1
69 v8i1 = 20, // 8 x i1
70 v16i1 = 21, // 16 x i1
71 v32i1 = 22, // 32 x i1
72 v64i1 = 23, // 64 x i1
73 v128i1 = 24, // 128 x i1
74 v256i1 = 25, // 256 x i1
75 v512i1 = 26, // 512 x i1
76 v1024i1 = 27, // 1024 x i1
77 v2048i1 = 28, // 2048 x i1
78
79 v128i2 = 29, // 128 x i2
80 v256i2 = 30, // 256 x i2
81
82 v64i4 = 31, // 64 x i4
83 v128i4 = 32, // 128 x i4
84
85 v1i8 = 33, // 1 x i8
86 v2i8 = 34, // 2 x i8
87 v4i8 = 35, // 4 x i8
88 v8i8 = 36, // 8 x i8
89 v16i8 = 37, // 16 x i8
90 v32i8 = 38, // 32 x i8
91 v64i8 = 39, // 64 x i8
92 v128i8 = 40, // 128 x i8
93 v256i8 = 41, // 256 x i8
94 v512i8 = 42, // 512 x i8
95 v1024i8 = 43, // 1024 x i8
96
97 v1i16 = 44, // 1 x i16
98 v2i16 = 45, // 2 x i16
99 v3i16 = 46, // 3 x i16
100 v4i16 = 47, // 4 x i16
101 v8i16 = 48, // 8 x i16
102 v16i16 = 49, // 16 x i16
103 v32i16 = 50, // 32 x i16
104 v64i16 = 51, // 64 x i16
105 v128i16 = 52, // 128 x i16
106 v256i16 = 53, // 256 x i16
107 v512i16 = 54, // 512 x i16
108
109 v1i32 = 55, // 1 x i32
110 v2i32 = 56, // 2 x i32
111 v3i32 = 57, // 3 x i32
112 v4i32 = 58, // 4 x i32
113 v5i32 = 59, // 5 x i32
114 v6i32 = 60, // 6 x i32
115 v7i32 = 61, // 7 x i32
116 v8i32 = 62, // 8 x i32
117 v9i32 = 63, // 9 x i32
118 v10i32 = 64, // 10 x i32
119 v11i32 = 65, // 11 x i32
120 v12i32 = 66, // 12 x i32
121 v16i32 = 67, // 16 x i32
122 v32i32 = 68, // 32 x i32
123 v64i32 = 69, // 64 x i32
124 v128i32 = 70, // 128 x i32
125 v256i32 = 71, // 256 x i32
126 v512i32 = 72, // 512 x i32
127 v1024i32 = 73, // 1024 x i32
128 v2048i32 = 74, // 2048 x i32
129
130 v1i64 = 75, // 1 x i64
131 v2i64 = 76, // 2 x i64
132 v3i64 = 77, // 3 x i64
133 v4i64 = 78, // 4 x i64
134 v8i64 = 79, // 8 x i64
135 v16i64 = 80, // 16 x i64
136 v32i64 = 81, // 32 x i64
137 v64i64 = 82, // 64 x i64
138 v128i64 = 83, // 128 x i64
139 v256i64 = 84, // 256 x i64
140
141 v1i128 = 85, // 1 x i128
142
145
146 v1f16 = 86, // 1 x f16
147 v2f16 = 87, // 2 x f16
148 v3f16 = 88, // 3 x f16
149 v4f16 = 89, // 4 x f16
150 v8f16 = 90, // 8 x f16
151 v16f16 = 91, // 16 x f16
152 v32f16 = 92, // 32 x f16
153 v64f16 = 93, // 64 x f16
154 v128f16 = 94, // 128 x f16
155 v256f16 = 95, // 256 x f16
156 v512f16 = 96, // 512 x f16
157
158 v2bf16 = 97, // 2 x bf16
159 v3bf16 = 98, // 3 x bf16
160 v4bf16 = 99, // 4 x bf16
161 v8bf16 = 100, // 8 x bf16
162 v16bf16 = 101, // 16 x bf16
163 v32bf16 = 102, // 32 x bf16
164 v64bf16 = 103, // 64 x bf16
165 v128bf16 = 104, // 128 x bf16
166
167 v1f32 = 105, // 1 x f32
168 v2f32 = 106, // 2 x f32
169 v3f32 = 107, // 3 x f32
170 v4f32 = 108, // 4 x f32
171 v5f32 = 109, // 5 x f32
172 v6f32 = 110, // 6 x f32
173 v7f32 = 111, // 7 x f32
174 v8f32 = 112, // 8 x f32
175 v9f32 = 113, // 9 x f32
176 v10f32 = 114, // 10 x f32
177 v11f32 = 115, // 11 x f32
178 v12f32 = 116, // 12 x f32
179 v16f32 = 117, // 16 x f32
180
181 v32f32 = 118, // 32 x f32
182 v64f32 = 119, // 64 x f32
183 v128f32 = 120, // 128 x f32
184 v256f32 = 121, // 256 x f32
185 v512f32 = 122, // 512 x f32
186 v1024f32 = 123, // 1024 x f32
187 v2048f32 = 124, // 2048 x f32
188
189 v1f64 = 125, // 1 x f64
190 v2f64 = 126, // 2 x f64
191 v3f64 = 127, // 3 x f64
192 v4f64 = 128, // 4 x f64
193 v8f64 = 129, // 8 x f64
194 v16f64 = 130, // 16 x f64
195 v32f64 = 131, // 32 x f64
196 v64f64 = 132, // 64 x f64
197 v128f64 = 133, // 128 x f64
198 v256f64 = 134, // 256 x f64
199
202
205
206 nxv1i1 = 135, // n x 1 x i1
207 nxv2i1 = 136, // n x 2 x i1
208 nxv4i1 = 137, // n x 4 x i1
209 nxv8i1 = 138, // n x 8 x i1
210 nxv16i1 = 139, // n x 16 x i1
211 nxv32i1 = 140, // n x 32 x i1
212 nxv64i1 = 141, // n x 64 x i1
213
214 nxv1i8 = 142, // n x 1 x i8
215 nxv2i8 = 143, // n x 2 x i8
216 nxv4i8 = 144, // n x 4 x i8
217 nxv8i8 = 145, // n x 8 x i8
218 nxv16i8 = 146, // n x 16 x i8
219 nxv32i8 = 147, // n x 32 x i8
220 nxv64i8 = 148, // n x 64 x i8
221
222 nxv1i16 = 149, // n x 1 x i16
223 nxv2i16 = 150, // n x 2 x i16
224 nxv4i16 = 151, // n x 4 x i16
225 nxv8i16 = 152, // n x 8 x i16
226 nxv16i16 = 153, // n x 16 x i16
227 nxv32i16 = 154, // n x 32 x i16
228
229 nxv1i32 = 155, // n x 1 x i32
230 nxv2i32 = 156, // n x 2 x i32
231 nxv4i32 = 157, // n x 4 x i32
232 nxv8i32 = 158, // n x 8 x i32
233 nxv16i32 = 159, // n x 16 x i32
234 nxv32i32 = 160, // n x 32 x i32
235
236 nxv1i64 = 161, // n x 1 x i64
237 nxv2i64 = 162, // n x 2 x i64
238 nxv4i64 = 163, // n x 4 x i64
239 nxv8i64 = 164, // n x 8 x i64
240 nxv16i64 = 165, // n x 16 x i64
241 nxv32i64 = 166, // n x 32 x i64
242
245
246 nxv1f16 = 167, // n x 1 x f16
247 nxv2f16 = 168, // n x 2 x f16
248 nxv4f16 = 169, // n x 4 x f16
249 nxv8f16 = 170, // n x 8 x f16
250 nxv16f16 = 171, // n x 16 x f16
251 nxv32f16 = 172, // n x 32 x f16
252
253 nxv1bf16 = 173, // n x 1 x bf16
254 nxv2bf16 = 174, // n x 2 x bf16
255 nxv4bf16 = 175, // n x 4 x bf16
256 nxv8bf16 = 176, // n x 8 x bf16
257 nxv16bf16 = 177, // n x 16 x bf16
258 nxv32bf16 = 178, // n x 32 x bf16
259
260 nxv1f32 = 179, // n x 1 x f32
261 nxv2f32 = 180, // n x 2 x f32
262 nxv4f32 = 181, // n x 4 x f32
263 nxv8f32 = 182, // n x 8 x f32
264 nxv16f32 = 183, // n x 16 x f32
265
266 nxv1f64 = 184, // n x 1 x f64
267 nxv2f64 = 185, // n x 2 x f64
268 nxv4f64 = 186, // n x 4 x f64
269 nxv8f64 = 187, // n x 8 x f64
270
273
276
279
280 x86mmx = 188, // This is an X86 MMX value
281
282 Glue = 189, // This glues nodes together during pre-RA sched
283
284 isVoid = 190, // This has no value
285
286 Untyped = 191, // This value takes a register, but has
287 // unspecified type. The register class
288 // will be determined by the opcode.
289
290 funcref = 192, // WebAssembly's funcref type
291 externref = 193, // WebAssembly's externref type
292 x86amx = 194, // This is an X86 AMX value
293 i64x8 = 195, // 8 Consecutive GPRs (AArch64)
294
295 FIRST_VALUETYPE = 1, // This is always the beginning of the list.
296 LAST_VALUETYPE = i64x8, // This always remains at the end of the list.
298
299 // This is the current maximum for LAST_VALUETYPE.
300 // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
301 // This value must be a multiple of 32.
303
304 // A value of type llvm::TokenTy
305 token = 248,
306
307 // This is MDNode or MDString.
308 Metadata = 249,
309
310 // An int value the size of the pointer of the current
311 // target to any address space. This must only be used internal to
312 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
313 iPTRAny = 250,
314
315 // A vector with any length and element size. This is used
316 // for intrinsics that have overloadings based on vector types.
317 // This is only for tblgen's consumption!
318 vAny = 251,
319
320 // Any floating-point or vector floating-point value. This is used
321 // for intrinsics that have overloadings based on floating-point types.
322 // This is only for tblgen's consumption!
323 fAny = 252,
324
325 // An integer or vector integer value of any bit width. This is
326 // used for intrinsics that have overloadings based on integer bit widths.
327 // This is only for tblgen's consumption!
328 iAny = 253,
329
330 // An int value the size of the pointer of the current
331 // target. This should only be used internal to tblgen!
332 iPTR = 254,
333
334 // Any type. This is used for intrinsics that have overloadings.
335 // This is only for tblgen's consumption!
336 Any = 255
337
338 // clang-format on
339 };
340
342
343 constexpr MVT() = default;
344 constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {}
345
346 bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; }
347 bool operator<(const MVT& S) const { return SimpleTy < S.SimpleTy; }
348 bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; }
349 bool operator!=(const MVT& S) const { return SimpleTy != S.SimpleTy; }
350 bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
351 bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
352
353 /// Support for debugging, callable in GDB: VT.dump()
354 void dump() const;
355
356 /// Implement operator<<.
357 void print(raw_ostream &OS) const;
358
359 /// Return true if this is a valid simple valuetype.
360 bool isValid() const {
361 return (SimpleTy >= MVT::FIRST_VALUETYPE &&
363 }
364
365 /// Return true if this is a FP or a vector FP type.
366 bool isFloatingPoint() const {
367 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
373 }
374
375 /// Return true if this is an integer or a vector integer type.
376 bool isInteger() const {
383 }
384
385 /// Return true if this is an integer, not including vectors.
386 bool isScalarInteger() const {
389 }
390
391 /// Return true if this is a vector value type.
392 bool isVector() const {
395 }
396
397 /// Return true if this is a vector value type where the
398 /// runtime length is machine dependent
399 bool isScalableVector() const {
402 }
403
404 bool isFixedLengthVector() const {
407 }
408
409 /// Return true if this is a 16-bit vector type.
410 bool is16BitVector() const {
411 return (SimpleTy == MVT::v2i8 || SimpleTy == MVT::v1i16 ||
413 }
414
415 /// Return true if this is a 32-bit vector type.
416 bool is32BitVector() const {
417 return (SimpleTy == MVT::v32i1 || SimpleTy == MVT::v4i8 ||
421 }
422
423 /// Return true if this is a 64-bit vector type.
424 bool is64BitVector() const {
425 return (SimpleTy == MVT::v64i1 || SimpleTy == MVT::v8i8 ||
430 }
431
432 /// Return true if this is a 128-bit vector type.
433 bool is128BitVector() const {
434 return (SimpleTy == MVT::v128i1 || SimpleTy == MVT::v16i8 ||
439 }
440
441 /// Return true if this is a 256-bit vector type.
442 bool is256BitVector() const {
443 return (SimpleTy == MVT::v16f16 || SimpleTy == MVT::v16bf16 ||
449 }
450
451 /// Return true if this is a 512-bit vector type.
452 bool is512BitVector() const {
453 return (SimpleTy == MVT::v32f16 || SimpleTy == MVT::v32bf16 ||
459 }
460
461 /// Return true if this is a 1024-bit vector type.
462 bool is1024BitVector() const {
463 return (SimpleTy == MVT::v1024i1 || SimpleTy == MVT::v128i8 ||
468 }
469
470 /// Return true if this is a 2048-bit vector type.
471 bool is2048BitVector() const {
472 return (SimpleTy == MVT::v256i8 || SimpleTy == MVT::v128i16 ||
477 }
478
479 /// Return true if this is an overloaded type for TableGen.
480 bool isOverloaded() const {
481 return (SimpleTy == MVT::Any || SimpleTy == MVT::iAny ||
484 }
485
486 /// Return a vector with the same number of elements as this vector, but
487 /// with the element type converted to an integer type with the same
488 /// bitwidth.
490 MVT EltTy = getVectorElementType();
491 MVT IntTy = MVT::getIntegerVT(EltTy.getSizeInBits());
494 "Simple vector VT not representable by simple integer vector VT!");
495 return VecTy;
496 }
497
498 /// Return a VT for a vector type whose attributes match ourselves
499 /// with the exception of the element type that is chosen by the caller.
503 "Simple vector VT not representable by simple integer vector VT!");
504 return VecTy;
505 }
506
507 /// Return the type converted to an equivalently sized integer or vector
508 /// with integer element type. Similar to changeVectorElementTypeToInteger,
509 /// but also handles scalars.
511 if (isVector())
514 }
515
516 /// Return a VT for a vector type with the same element type but
517 /// half the number of elements.
519 MVT EltVT = getVectorElementType();
520 auto EltCnt = getVectorElementCount();
521 assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!");
522 return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2));
523 }
524
525 /// Returns true if the given vector is a power of 2.
526 bool isPow2VectorType() const {
527 unsigned NElts = getVectorMinNumElements();
528 return !(NElts & (NElts - 1));
529 }
530
531 /// Widens the length of the given vector MVT up to the nearest power of 2
532 /// and returns that type.
534 if (isPow2VectorType())
535 return *this;
536
538 unsigned NewMinCount = 1 << Log2_32_Ceil(NElts.getKnownMinValue());
539 NElts = ElementCount::get(NewMinCount, NElts.isScalable());
540 return MVT::getVectorVT(getVectorElementType(), NElts);
541 }
542
543 /// If this is a vector, return the element type, otherwise return this.
545 return isVector() ? getVectorElementType() : *this;
546 }
547
549 // clang-format off
550 switch (SimpleTy) {
551 default:
552 llvm_unreachable("Not a vector MVT!");
553 case v1i1:
554 case v2i1:
555 case v4i1:
556 case v8i1:
557 case v16i1:
558 case v32i1:
559 case v64i1:
560 case v128i1:
561 case v256i1:
562 case v512i1:
563 case v1024i1:
564 case v2048i1:
565 case nxv1i1:
566 case nxv2i1:
567 case nxv4i1:
568 case nxv8i1:
569 case nxv16i1:
570 case nxv32i1:
571 case nxv64i1: return i1;
572 case v128i2:
573 case v256i2: return i2;
574 case v64i4:
575 case v128i4: return i4;
576 case v1i8:
577 case v2i8:
578 case v4i8:
579 case v8i8:
580 case v16i8:
581 case v32i8:
582 case v64i8:
583 case v128i8:
584 case v256i8:
585 case v512i8:
586 case v1024i8:
587 case nxv1i8:
588 case nxv2i8:
589 case nxv4i8:
590 case nxv8i8:
591 case nxv16i8:
592 case nxv32i8:
593 case nxv64i8: return i8;
594 case v1i16:
595 case v2i16:
596 case v3i16:
597 case v4i16:
598 case v8i16:
599 case v16i16:
600 case v32i16:
601 case v64i16:
602 case v128i16:
603 case v256i16:
604 case v512i16:
605 case nxv1i16:
606 case nxv2i16:
607 case nxv4i16:
608 case nxv8i16:
609 case nxv16i16:
610 case nxv32i16: return i16;
611 case v1i32:
612 case v2i32:
613 case v3i32:
614 case v4i32:
615 case v5i32:
616 case v6i32:
617 case v7i32:
618 case v8i32:
619 case v9i32:
620 case v10i32:
621 case v11i32:
622 case v12i32:
623 case v16i32:
624 case v32i32:
625 case v64i32:
626 case v128i32:
627 case v256i32:
628 case v512i32:
629 case v1024i32:
630 case v2048i32:
631 case nxv1i32:
632 case nxv2i32:
633 case nxv4i32:
634 case nxv8i32:
635 case nxv16i32:
636 case nxv32i32: return i32;
637 case v1i64:
638 case v2i64:
639 case v3i64:
640 case v4i64:
641 case v8i64:
642 case v16i64:
643 case v32i64:
644 case v64i64:
645 case v128i64:
646 case v256i64:
647 case nxv1i64:
648 case nxv2i64:
649 case nxv4i64:
650 case nxv8i64:
651 case nxv16i64:
652 case nxv32i64: return i64;
653 case v1i128: return i128;
654 case v1f16:
655 case v2f16:
656 case v3f16:
657 case v4f16:
658 case v8f16:
659 case v16f16:
660 case v32f16:
661 case v64f16:
662 case v128f16:
663 case v256f16:
664 case v512f16:
665 case nxv1f16:
666 case nxv2f16:
667 case nxv4f16:
668 case nxv8f16:
669 case nxv16f16:
670 case nxv32f16: return f16;
671 case v2bf16:
672 case v3bf16:
673 case v4bf16:
674 case v8bf16:
675 case v16bf16:
676 case v32bf16:
677 case v64bf16:
678 case v128bf16:
679 case nxv1bf16:
680 case nxv2bf16:
681 case nxv4bf16:
682 case nxv8bf16:
683 case nxv16bf16:
684 case nxv32bf16: return bf16;
685 case v1f32:
686 case v2f32:
687 case v3f32:
688 case v4f32:
689 case v5f32:
690 case v6f32:
691 case v7f32:
692 case v8f32:
693 case v9f32:
694 case v10f32:
695 case v11f32:
696 case v12f32:
697 case v16f32:
698 case v32f32:
699 case v64f32:
700 case v128f32:
701 case v256f32:
702 case v512f32:
703 case v1024f32:
704 case v2048f32:
705 case nxv1f32:
706 case nxv2f32:
707 case nxv4f32:
708 case nxv8f32:
709 case nxv16f32: return f32;
710 case v1f64:
711 case v2f64:
712 case v3f64:
713 case v4f64:
714 case v8f64:
715 case v16f64:
716 case v32f64:
717 case v64f64:
718 case v128f64:
719 case v256f64:
720 case nxv1f64:
721 case nxv2f64:
722 case nxv4f64:
723 case nxv8f64: return f64;
724 }
725 // clang-format on
726 }
727
728 /// Given a vector type, return the minimum number of elements it contains.
729 unsigned getVectorMinNumElements() const {
730 switch (SimpleTy) {
731 default:
732 llvm_unreachable("Not a vector MVT!");
733 case v2048i1:
734 case v2048i32:
735 case v2048f32: return 2048;
736 case v1024i1:
737 case v1024i8:
738 case v1024i32:
739 case v1024f32: return 1024;
740 case v512i1:
741 case v512i8:
742 case v512i16:
743 case v512i32:
744 case v512f16:
745 case v512f32: return 512;
746 case v256i1:
747 case v256i2:
748 case v256i8:
749 case v256i16:
750 case v256f16:
751 case v256i32:
752 case v256i64:
753 case v256f32:
754 case v256f64: return 256;
755 case v128i1:
756 case v128i2:
757 case v128i4:
758 case v128i8:
759 case v128i16:
760 case v128i32:
761 case v128i64:
762 case v128f16:
763 case v128bf16:
764 case v128f32:
765 case v128f64: return 128;
766 case v64i1:
767 case v64i4:
768 case v64i8:
769 case v64i16:
770 case v64i32:
771 case v64i64:
772 case v64f16:
773 case v64bf16:
774 case v64f32:
775 case v64f64:
776 case nxv64i1:
777 case nxv64i8: return 64;
778 case v32i1:
779 case v32i8:
780 case v32i16:
781 case v32i32:
782 case v32i64:
783 case v32f16:
784 case v32bf16:
785 case v32f32:
786 case v32f64:
787 case nxv32i1:
788 case nxv32i8:
789 case nxv32i16:
790 case nxv32i32:
791 case nxv32i64:
792 case nxv32f16:
793 case nxv32bf16: return 32;
794 case v16i1:
795 case v16i8:
796 case v16i16:
797 case v16i32:
798 case v16i64:
799 case v16f16:
800 case v16bf16:
801 case v16f32:
802 case v16f64:
803 case nxv16i1:
804 case nxv16i8:
805 case nxv16i16:
806 case nxv16i32:
807 case nxv16i64:
808 case nxv16f16:
809 case nxv16bf16:
810 case nxv16f32: return 16;
811 case v12i32:
812 case v12f32: return 12;
813 case v11i32:
814 case v11f32: return 11;
815 case v10i32:
816 case v10f32: return 10;
817 case v9i32:
818 case v9f32: return 9;
819 case v8i1:
820 case v8i8:
821 case v8i16:
822 case v8i32:
823 case v8i64:
824 case v8f16:
825 case v8bf16:
826 case v8f32:
827 case v8f64:
828 case nxv8i1:
829 case nxv8i8:
830 case nxv8i16:
831 case nxv8i32:
832 case nxv8i64:
833 case nxv8f16:
834 case nxv8bf16:
835 case nxv8f32:
836 case nxv8f64: return 8;
837 case v7i32:
838 case v7f32: return 7;
839 case v6i32:
840 case v6f32: return 6;
841 case v5i32:
842 case v5f32: return 5;
843 case v4i1:
844 case v4i8:
845 case v4i16:
846 case v4i32:
847 case v4i64:
848 case v4f16:
849 case v4bf16:
850 case v4f32:
851 case v4f64:
852 case nxv4i1:
853 case nxv4i8:
854 case nxv4i16:
855 case nxv4i32:
856 case nxv4i64:
857 case nxv4f16:
858 case nxv4bf16:
859 case nxv4f32:
860 case nxv4f64: return 4;
861 case v3i16:
862 case v3i32:
863 case v3i64:
864 case v3f16:
865 case v3bf16:
866 case v3f32:
867 case v3f64: return 3;
868 case v2i1:
869 case v2i8:
870 case v2i16:
871 case v2i32:
872 case v2i64:
873 case v2f16:
874 case v2bf16:
875 case v2f32:
876 case v2f64:
877 case nxv2i1:
878 case nxv2i8:
879 case nxv2i16:
880 case nxv2i32:
881 case nxv2i64:
882 case nxv2f16:
883 case nxv2bf16:
884 case nxv2f32:
885 case nxv2f64: return 2;
886 case v1i1:
887 case v1i8:
888 case v1i16:
889 case v1i32:
890 case v1i64:
891 case v1i128:
892 case v1f16:
893 case v1f32:
894 case v1f64:
895 case nxv1i1:
896 case nxv1i8:
897 case nxv1i16:
898 case nxv1i32:
899 case nxv1i64:
900 case nxv1f16:
901 case nxv1bf16:
902 case nxv1f32:
903 case nxv1f64: return 1;
904 }
905 }
906
909 }
910
911 unsigned getVectorNumElements() const {
912 if (isScalableVector())
914 "Possible incorrect use of MVT::getVectorNumElements() for "
915 "scalable vector. Scalable flag may be dropped, use "
916 "MVT::getVectorElementCount() instead");
918 }
919
920 /// Returns the size of the specified MVT in bits.
921 ///
922 /// If the value type is a scalable vector type, the scalable property will
923 /// be set and the runtime size will be a positive integer multiple of the
924 /// base size.
926 switch (SimpleTy) {
927 default:
928 llvm_unreachable("getSizeInBits called on extended MVT.");
929 case Other:
930 llvm_unreachable("Value type is non-standard value, Other.");
931 case iPTR:
932 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
933 case iPTRAny:
934 case iAny:
935 case fAny:
936 case vAny:
937 case Any:
938 llvm_unreachable("Value type is overloaded.");
939 case token:
940 llvm_unreachable("Token type is a sentinel that cannot be used "
941 "in codegen and has no size");
942 case Metadata:
943 llvm_unreachable("Value type is metadata.");
944 case i1:
945 case v1i1: return TypeSize::Fixed(1);
946 case nxv1i1: return TypeSize::Scalable(1);
947 case i2:
948 case v2i1: return TypeSize::Fixed(2);
949 case nxv2i1: return TypeSize::Scalable(2);
950 case i4:
951 case v4i1: return TypeSize::Fixed(4);
952 case nxv4i1: return TypeSize::Scalable(4);
953 case i8 :
954 case v1i8:
955 case v8i1: return TypeSize::Fixed(8);
956 case nxv1i8:
957 case nxv8i1: return TypeSize::Scalable(8);
958 case i16 :
959 case f16:
960 case bf16:
961 case v16i1:
962 case v2i8:
963 case v1i16:
964 case v1f16: return TypeSize::Fixed(16);
965 case nxv16i1:
966 case nxv2i8:
967 case nxv1i16:
968 case nxv1bf16:
969 case nxv1f16: return TypeSize::Scalable(16);
970 case f32 :
971 case i32 :
972 case v32i1:
973 case v4i8:
974 case v2i16:
975 case v2f16:
976 case v2bf16:
977 case v1f32:
978 case v1i32: return TypeSize::Fixed(32);
979 case nxv32i1:
980 case nxv4i8:
981 case nxv2i16:
982 case nxv1i32:
983 case nxv2f16:
984 case nxv2bf16:
985 case nxv1f32: return TypeSize::Scalable(32);
986 case v3i16:
987 case v3f16:
988 case v3bf16: return TypeSize::Fixed(48);
989 case x86mmx:
990 case f64 :
991 case i64 :
992 case v64i1:
993 case v8i8:
994 case v4i16:
995 case v2i32:
996 case v1i64:
997 case v4f16:
998 case v4bf16:
999 case v2f32:
1000 case v1f64: return TypeSize::Fixed(64);
1001 case nxv64i1:
1002 case nxv8i8:
1003 case nxv4i16:
1004 case nxv2i32:
1005 case nxv1i64:
1006 case nxv4f16:
1007 case nxv4bf16:
1008 case nxv2f32:
1009 case nxv1f64: return TypeSize::Scalable(64);
1010 case f80 : return TypeSize::Fixed(80);
1011 case v3i32:
1012 case v3f32: return TypeSize::Fixed(96);
1013 case f128:
1014 case ppcf128:
1015 case i128:
1016 case v128i1:
1017 case v16i8:
1018 case v8i16:
1019 case v4i32:
1020 case v2i64:
1021 case v1i128:
1022 case v8f16:
1023 case v8bf16:
1024 case v4f32:
1025 case v2f64: return TypeSize::Fixed(128);
1026 case nxv16i8:
1027 case nxv8i16:
1028 case nxv4i32:
1029 case nxv2i64:
1030 case nxv8f16:
1031 case nxv8bf16:
1032 case nxv4f32:
1033 case nxv2f64: return TypeSize::Scalable(128);
1034 case v5i32:
1035 case v5f32: return TypeSize::Fixed(160);
1036 case v6i32:
1037 case v3i64:
1038 case v6f32:
1039 case v3f64: return TypeSize::Fixed(192);
1040 case v7i32:
1041 case v7f32: return TypeSize::Fixed(224);
1042 case v256i1:
1043 case v128i2:
1044 case v64i4:
1045 case v32i8:
1046 case v16i16:
1047 case v8i32:
1048 case v4i64:
1049 case v16f16:
1050 case v16bf16:
1051 case v8f32:
1052 case v4f64: return TypeSize::Fixed(256);
1053 case nxv32i8:
1054 case nxv16i16:
1055 case nxv8i32:
1056 case nxv4i64:
1057 case nxv16f16:
1058 case nxv16bf16:
1059 case nxv8f32:
1060 case nxv4f64: return TypeSize::Scalable(256);
1061 case v9i32:
1062 case v9f32: return TypeSize::Fixed(288);
1063 case v10i32:
1064 case v10f32: return TypeSize::Fixed(320);
1065 case v11i32:
1066 case v11f32: return TypeSize::Fixed(352);
1067 case v12i32:
1068 case v12f32: return TypeSize::Fixed(384);
1069 case i64x8:
1070 case v512i1:
1071 case v256i2:
1072 case v128i4:
1073 case v64i8:
1074 case v32i16:
1075 case v16i32:
1076 case v8i64:
1077 case v32f16:
1078 case v32bf16:
1079 case v16f32:
1080 case v8f64: return TypeSize::Fixed(512);
1081 case nxv64i8:
1082 case nxv32i16:
1083 case nxv16i32:
1084 case nxv8i64:
1085 case nxv32f16:
1086 case nxv32bf16:
1087 case nxv16f32:
1088 case nxv8f64: return TypeSize::Scalable(512);
1089 case v1024i1:
1090 case v128i8:
1091 case v64i16:
1092 case v32i32:
1093 case v16i64:
1094 case v64f16:
1095 case v64bf16:
1096 case v32f32:
1097 case v16f64: return TypeSize::Fixed(1024);
1098 case nxv32i32:
1099 case nxv16i64: return TypeSize::Scalable(1024);
1100 case v2048i1:
1101 case v256i8:
1102 case v128i16:
1103 case v64i32:
1104 case v32i64:
1105 case v128f16:
1106 case v128bf16:
1107 case v64f32:
1108 case v32f64: return TypeSize::Fixed(2048);
1109 case nxv32i64: return TypeSize::Scalable(2048);
1110 case v512i8:
1111 case v256i16:
1112 case v128i32:
1113 case v64i64:
1114 case v256f16:
1115 case v128f32:
1116 case v64f64: return TypeSize::Fixed(4096);
1117 case v1024i8:
1118 case v512i16:
1119 case v256i32:
1120 case v128i64:
1121 case v512f16:
1122 case v256f32:
1123 case x86amx:
1124 case v128f64: return TypeSize::Fixed(8192);
1125 case v512i32:
1126 case v256i64:
1127 case v512f32:
1128 case v256f64: return TypeSize::Fixed(16384);
1129 case v1024i32:
1130 case v1024f32: return TypeSize::Fixed(32768);
1131 case v2048i32:
1132 case v2048f32: return TypeSize::Fixed(65536);
1133 case funcref:
1134 case externref: return TypeSize::Fixed(0); // opaque type
1135 }
1136 }
1137
1138 /// Return the size of the specified fixed width value type in bits. The
1139 /// function will assert if the type is scalable.
1141 return getSizeInBits().getFixedValue();
1142 }
1143
1146 }
1147
1148 /// Return the number of bytes overwritten by a store of the specified value
1149 /// type.
1150 ///
1151 /// If the value type is a scalable vector type, the scalable property will
1152 /// be set and the runtime size will be a positive integer multiple of the
1153 /// base size.
1155 TypeSize BaseSize = getSizeInBits();
1156 return {(BaseSize.getKnownMinValue() + 7) / 8, BaseSize.isScalable()};
1157 }
1158
1159 // Return the number of bytes overwritten by a store of this value type or
1160 // this value type's element type in the case of a vector.
1163 }
1164
1165 /// Return the number of bits overwritten by a store of the specified value
1166 /// type.
1167 ///
1168 /// If the value type is a scalable vector type, the scalable property will
1169 /// be set and the runtime size will be a positive integer multiple of the
1170 /// base size.
1172 return getStoreSize() * 8;
1173 }
1174
1175 /// Returns true if the number of bits for the type is a multiple of an
1176 /// 8-bit byte.
1177 bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); }
1178
1179 /// Return true if we know at compile time this has more bits than VT.
1180 bool knownBitsGT(MVT VT) const {
1182 }
1183
1184 /// Return true if we know at compile time this has more than or the same
1185 /// bits as VT.
1186 bool knownBitsGE(MVT VT) const {
1188 }
1189
1190 /// Return true if we know at compile time this has fewer bits than VT.
1191 bool knownBitsLT(MVT VT) const {
1193 }
1194
1195 /// Return true if we know at compile time this has fewer than or the same
1196 /// bits as VT.
1197 bool knownBitsLE(MVT VT) const {
1199 }
1200
1201 /// Return true if this has more bits than VT.
1202 bool bitsGT(MVT VT) const {
1204 "Comparison between scalable and fixed types");
1205 return knownBitsGT(VT);
1206 }
1207
1208 /// Return true if this has no less bits than VT.
1209 bool bitsGE(MVT VT) const {
1211 "Comparison between scalable and fixed types");
1212 return knownBitsGE(VT);
1213 }
1214
1215 /// Return true if this has less bits than VT.
1216 bool bitsLT(MVT VT) const {
1218 "Comparison between scalable and fixed types");
1219 return knownBitsLT(VT);
1220 }
1221
1222 /// Return true if this has no more bits than VT.
1223 bool bitsLE(MVT VT) const {
1225 "Comparison between scalable and fixed types");
1226 return knownBitsLE(VT);
1227 }
1228
1230 switch (BitWidth) {
1231 default:
1232 llvm_unreachable("Bad bit width!");
1233 case 16:
1234 return MVT::f16;
1235 case 32:
1236 return MVT::f32;
1237 case 64:
1238 return MVT::f64;
1239 case 80:
1240 return MVT::f80;
1241 case 128:
1242 return MVT::f128;
1243 }
1244 }
1245
1246 static MVT getIntegerVT(unsigned BitWidth) {
1247 switch (BitWidth) {
1248 default:
1250 case 1:
1251 return MVT::i1;
1252 case 2:
1253 return MVT::i2;
1254 case 4:
1255 return MVT::i4;
1256 case 8:
1257 return MVT::i8;
1258 case 16:
1259 return MVT::i16;
1260 case 32:
1261 return MVT::i32;
1262 case 64:
1263 return MVT::i64;
1264 case 128:
1265 return MVT::i128;
1266 }
1267 }
1268
1269 static MVT getVectorVT(MVT VT, unsigned NumElements) {
1270 // clang-format off
1271 switch (VT.SimpleTy) {
1272 default:
1273 break;
1274 case MVT::i1:
1275 if (NumElements == 1) return MVT::v1i1;
1276 if (NumElements == 2) return MVT::v2i1;
1277 if (NumElements == 4) return MVT::v4i1;
1278 if (NumElements == 8) return MVT::v8i1;
1279 if (NumElements == 16) return MVT::v16i1;
1280 if (NumElements == 32) return MVT::v32i1;
1281 if (NumElements == 64) return MVT::v64i1;
1282 if (NumElements == 128) return MVT::v128i1;
1283 if (NumElements == 256) return MVT::v256i1;
1284 if (NumElements == 512) return MVT::v512i1;
1285 if (NumElements == 1024) return MVT::v1024i1;
1286 if (NumElements == 2048) return MVT::v2048i1;
1287 break;
1288 case MVT::i2:
1289 if (NumElements == 128) return MVT::v128i2;
1290 if (NumElements == 256) return MVT::v256i2;
1291 break;
1292 case MVT::i4:
1293 if (NumElements == 64) return MVT::v64i4;
1294 if (NumElements == 128) return MVT::v128i4;
1295 break;
1296 case MVT::i8:
1297 if (NumElements == 1) return MVT::v1i8;
1298 if (NumElements == 2) return MVT::v2i8;
1299 if (NumElements == 4) return MVT::v4i8;
1300 if (NumElements == 8) return MVT::v8i8;
1301 if (NumElements == 16) return MVT::v16i8;
1302 if (NumElements == 32) return MVT::v32i8;
1303 if (NumElements == 64) return MVT::v64i8;
1304 if (NumElements == 128) return MVT::v128i8;
1305 if (NumElements == 256) return MVT::v256i8;
1306 if (NumElements == 512) return MVT::v512i8;
1307 if (NumElements == 1024) return MVT::v1024i8;
1308 break;
1309 case MVT::i16:
1310 if (NumElements == 1) return MVT::v1i16;
1311 if (NumElements == 2) return MVT::v2i16;
1312 if (NumElements == 3) return MVT::v3i16;
1313 if (NumElements == 4) return MVT::v4i16;
1314 if (NumElements == 8) return MVT::v8i16;
1315 if (NumElements == 16) return MVT::v16i16;
1316 if (NumElements == 32) return MVT::v32i16;
1317 if (NumElements == 64) return MVT::v64i16;
1318 if (NumElements == 128) return MVT::v128i16;
1319 if (NumElements == 256) return MVT::v256i16;
1320 if (NumElements == 512) return MVT::v512i16;
1321 break;
1322 case MVT::i32:
1323 if (NumElements == 1) return MVT::v1i32;
1324 if (NumElements == 2) return MVT::v2i32;
1325 if (NumElements == 3) return MVT::v3i32;
1326 if (NumElements == 4) return MVT::v4i32;
1327 if (NumElements == 5) return MVT::v5i32;
1328 if (NumElements == 6) return MVT::v6i32;
1329 if (NumElements == 7) return MVT::v7i32;
1330 if (NumElements == 8) return MVT::v8i32;
1331 if (NumElements == 9) return MVT::v9i32;
1332 if (NumElements == 10) return MVT::v10i32;
1333 if (NumElements == 11) return MVT::v11i32;
1334 if (NumElements == 12) return MVT::v12i32;
1335 if (NumElements == 16) return MVT::v16i32;
1336 if (NumElements == 32) return MVT::v32i32;
1337 if (NumElements == 64) return MVT::v64i32;
1338 if (NumElements == 128) return MVT::v128i32;
1339 if (NumElements == 256) return MVT::v256i32;
1340 if (NumElements == 512) return MVT::v512i32;
1341 if (NumElements == 1024) return MVT::v1024i32;
1342 if (NumElements == 2048) return MVT::v2048i32;
1343 break;
1344 case MVT::i64:
1345 if (NumElements == 1) return MVT::v1i64;
1346 if (NumElements == 2) return MVT::v2i64;
1347 if (NumElements == 3) return MVT::v3i64;
1348 if (NumElements == 4) return MVT::v4i64;
1349 if (NumElements == 8) return MVT::v8i64;
1350 if (NumElements == 16) return MVT::v16i64;
1351 if (NumElements == 32) return MVT::v32i64;
1352 if (NumElements == 64) return MVT::v64i64;
1353 if (NumElements == 128) return MVT::v128i64;
1354 if (NumElements == 256) return MVT::v256i64;
1355 break;
1356 case MVT::i128:
1357 if (NumElements == 1) return MVT::v1i128;
1358 break;
1359 case MVT::f16:
1360 if (NumElements == 1) return MVT::v1f16;
1361 if (NumElements == 2) return MVT::v2f16;
1362 if (NumElements == 3) return MVT::v3f16;
1363 if (NumElements == 4) return MVT::v4f16;
1364 if (NumElements == 8) return MVT::v8f16;
1365 if (NumElements == 16) return MVT::v16f16;
1366 if (NumElements == 32) return MVT::v32f16;
1367 if (NumElements == 64) return MVT::v64f16;
1368 if (NumElements == 128) return MVT::v128f16;
1369 if (NumElements == 256) return MVT::v256f16;
1370 if (NumElements == 512) return MVT::v512f16;
1371 break;
1372 case MVT::bf16:
1373 if (NumElements == 2) return MVT::v2bf16;
1374 if (NumElements == 3) return MVT::v3bf16;
1375 if (NumElements == 4) return MVT::v4bf16;
1376 if (NumElements == 8) return MVT::v8bf16;
1377 if (NumElements == 16) return MVT::v16bf16;
1378 if (NumElements == 32) return MVT::v32bf16;
1379 if (NumElements == 64) return MVT::v64bf16;
1380 if (NumElements == 128) return MVT::v128bf16;
1381 break;
1382 case MVT::f32:
1383 if (NumElements == 1) return MVT::v1f32;
1384 if (NumElements == 2) return MVT::v2f32;
1385 if (NumElements == 3) return MVT::v3f32;
1386 if (NumElements == 4) return MVT::v4f32;
1387 if (NumElements == 5) return MVT::v5f32;
1388 if (NumElements == 6) return MVT::v6f32;
1389 if (NumElements == 7) return MVT::v7f32;
1390 if (NumElements == 8) return MVT::v8f32;
1391 if (NumElements == 9) return MVT::v9f32;
1392 if (NumElements == 10) return MVT::v10f32;
1393 if (NumElements == 11) return MVT::v11f32;
1394 if (NumElements == 12) return MVT::v12f32;
1395 if (NumElements == 16) return MVT::v16f32;
1396 if (NumElements == 32) return MVT::v32f32;
1397 if (NumElements == 64) return MVT::v64f32;
1398 if (NumElements == 128) return MVT::v128f32;
1399 if (NumElements == 256) return MVT::v256f32;
1400 if (NumElements == 512) return MVT::v512f32;
1401 if (NumElements == 1024) return MVT::v1024f32;
1402 if (NumElements == 2048) return MVT::v2048f32;
1403 break;
1404 case MVT::f64:
1405 if (NumElements == 1) return MVT::v1f64;
1406 if (NumElements == 2) return MVT::v2f64;
1407 if (NumElements == 3) return MVT::v3f64;
1408 if (NumElements == 4) return MVT::v4f64;
1409 if (NumElements == 8) return MVT::v8f64;
1410 if (NumElements == 16) return MVT::v16f64;
1411 if (NumElements == 32) return MVT::v32f64;
1412 if (NumElements == 64) return MVT::v64f64;
1413 if (NumElements == 128) return MVT::v128f64;
1414 if (NumElements == 256) return MVT::v256f64;
1415 break;
1416 }
1418 // clang-format on
1419 }
1420
1421 static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
1422 switch(VT.SimpleTy) {
1423 default:
1424 break;
1425 case MVT::i1:
1426 if (NumElements == 1) return MVT::nxv1i1;
1427 if (NumElements == 2) return MVT::nxv2i1;
1428 if (NumElements == 4) return MVT::nxv4i1;
1429 if (NumElements == 8) return MVT::nxv8i1;
1430 if (NumElements == 16) return MVT::nxv16i1;
1431 if (NumElements == 32) return MVT::nxv32i1;
1432 if (NumElements == 64) return MVT::nxv64i1;
1433 break;
1434 case MVT::i8:
1435 if (NumElements == 1) return MVT::nxv1i8;
1436 if (NumElements == 2) return MVT::nxv2i8;
1437 if (NumElements == 4) return MVT::nxv4i8;
1438 if (NumElements == 8) return MVT::nxv8i8;
1439 if (NumElements == 16) return MVT::nxv16i8;
1440 if (NumElements == 32) return MVT::nxv32i8;
1441 if (NumElements == 64) return MVT::nxv64i8;
1442 break;
1443 case MVT::i16:
1444 if (NumElements == 1) return MVT::nxv1i16;
1445 if (NumElements == 2) return MVT::nxv2i16;
1446 if (NumElements == 4) return MVT::nxv4i16;
1447 if (NumElements == 8) return MVT::nxv8i16;
1448 if (NumElements == 16) return MVT::nxv16i16;
1449 if (NumElements == 32) return MVT::nxv32i16;
1450 break;
1451 case MVT::i32:
1452 if (NumElements == 1) return MVT::nxv1i32;
1453 if (NumElements == 2) return MVT::nxv2i32;
1454 if (NumElements == 4) return MVT::nxv4i32;
1455 if (NumElements == 8) return MVT::nxv8i32;
1456 if (NumElements == 16) return MVT::nxv16i32;
1457 if (NumElements == 32) return MVT::nxv32i32;
1458 break;
1459 case MVT::i64:
1460 if (NumElements == 1) return MVT::nxv1i64;
1461 if (NumElements == 2) return MVT::nxv2i64;
1462 if (NumElements == 4) return MVT::nxv4i64;
1463 if (NumElements == 8) return MVT::nxv8i64;
1464 if (NumElements == 16) return MVT::nxv16i64;
1465 if (NumElements == 32) return MVT::nxv32i64;
1466 break;
1467 case MVT::f16:
1468 if (NumElements == 1) return MVT::nxv1f16;
1469 if (NumElements == 2) return MVT::nxv2f16;
1470 if (NumElements == 4) return MVT::nxv4f16;
1471 if (NumElements == 8) return MVT::nxv8f16;
1472 if (NumElements == 16) return MVT::nxv16f16;
1473 if (NumElements == 32) return MVT::nxv32f16;
1474 break;
1475 case MVT::bf16:
1476 if (NumElements == 1) return MVT::nxv1bf16;
1477 if (NumElements == 2) return MVT::nxv2bf16;
1478 if (NumElements == 4) return MVT::nxv4bf16;
1479 if (NumElements == 8) return MVT::nxv8bf16;
1480 if (NumElements == 16) return MVT::nxv16bf16;
1481 if (NumElements == 32) return MVT::nxv32bf16;
1482 break;
1483 case MVT::f32:
1484 if (NumElements == 1) return MVT::nxv1f32;
1485 if (NumElements == 2) return MVT::nxv2f32;
1486 if (NumElements == 4) return MVT::nxv4f32;
1487 if (NumElements == 8) return MVT::nxv8f32;
1488 if (NumElements == 16) return MVT::nxv16f32;
1489 break;
1490 case MVT::f64:
1491 if (NumElements == 1) return MVT::nxv1f64;
1492 if (NumElements == 2) return MVT::nxv2f64;
1493 if (NumElements == 4) return MVT::nxv4f64;
1494 if (NumElements == 8) return MVT::nxv8f64;
1495 break;
1496 }
1498 }
1499
1500 static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
1501 if (IsScalable)
1502 return getScalableVectorVT(VT, NumElements);
1503 return getVectorVT(VT, NumElements);
1504 }
1505
1507 if (EC.isScalable())
1508 return getScalableVectorVT(VT, EC.getKnownMinValue());
1509 return getVectorVT(VT, EC.getKnownMinValue());
1510 }
1511
1512 /// Return the value type corresponding to the specified type. This returns
1513 /// all pointers as iPTR. If HandleUnknown is true, unknown types are
1514 /// returned as Other, otherwise they are invalid.
1515 static MVT getVT(Type *Ty, bool HandleUnknown = false);
1516
1517 public:
1518 /// SimpleValueType Iteration
1519 /// @{
1520 static auto all_valuetypes() {
1523 }
1524
1525 static auto integer_valuetypes() {
1529 }
1530
1531 static auto fp_valuetypes() {
1534 }
1535
1536 static auto vector_valuetypes() {
1540 }
1541
1546 }
1547
1552 }
1553
1558 }
1559
1564 }
1565
1570 }
1571
1576 }
1577 /// @}
1578 };
1579
1580 inline raw_ostream &operator<<(raw_ostream &OS, const MVT &VT) {
1581 VT.print(OS);
1582 return OS;
1583 }
1584
1585} // end namespace llvm
1586
1587#endif // LLVM_SUPPORT_MACHINEVALUETYPE_H
RelocType Type
Definition: COFFYAML.cpp:390
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Provides some synthesis utilities to produce sequences of values.
Definition: Any.h:28
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
Definition: TypeSize.h:297
Machine Value Type.
void dump() const
Support for debugging, callable in GDB: VT.dump()
Definition: ValueTypes.cpp:620
static MVT getFloatingPointVT(unsigned BitWidth)
bool isByteSized() const
Returns true if the number of bits for the type is a multiple of an 8-bit byte.
bool is128BitVector() const
Return true if this is a 128-bit vector type.
bool knownBitsGT(MVT VT) const
Return true if we know at compile time this has more bits than VT.
static auto integer_fixedlen_vector_valuetypes()
unsigned getVectorMinNumElements() const
Given a vector type, return the minimum number of elements it contains.
bool operator>(const MVT &S) const
SimpleValueType SimpleTy
bool isOverloaded() const
Return true if this is an overloaded type for TableGen.
uint64_t getScalarSizeInBits() const
MVT changeVectorElementType(MVT EltVT) const
Return a VT for a vector type whose attributes match ourselves with the exception of the element type...
bool operator<=(const MVT &S) const
@ LAST_FIXEDLEN_VECTOR_VALUETYPE
@ LAST_FP_SCALABLE_VECTOR_VALUETYPE
@ FIRST_FP_FIXEDLEN_VECTOR_VALUETYPE
@ LAST_INTEGER_VALUETYPE
@ LAST_FP_FIXEDLEN_VECTOR_VALUETYPE
@ LAST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE
@ FIRST_FIXEDLEN_VECTOR_VALUETYPE
@ FIRST_INTEGER_FIXEDLEN_VECTOR_VALUETYPE
@ FIRST_INTEGER_SCALABLE_VECTOR_VALUETYPE
@ LAST_SCALABLE_VECTOR_VALUETYPE
@ FIRST_INTEGER_VALUETYPE
@ FIRST_SCALABLE_VECTOR_VALUETYPE
@ LAST_INTEGER_SCALABLE_VECTOR_VALUETYPE
@ FIRST_FP_SCALABLE_VECTOR_VALUETYPE
@ INVALID_SIMPLE_VALUE_TYPE
constexpr MVT()=default
static MVT getVectorVT(MVT VT, ElementCount EC)
bool bitsLE(MVT VT) const
Return true if this has no more bits than VT.
unsigned getVectorNumElements() const
bool knownBitsLT(MVT VT) const
Return true if we know at compile time this has fewer bits than VT.
bool isVector() const
Return true if this is a vector value type.
bool isInteger() const
Return true if this is an integer or a vector integer type.
bool isScalableVector() const
Return true if this is a vector value type where the runtime length is machine dependent.
static MVT getScalableVectorVT(MVT VT, unsigned NumElements)
bool is16BitVector() const
Return true if this is a 16-bit vector type.
bool is32BitVector() const
Return true if this is a 32-bit vector type.
MVT changeTypeToInteger()
Return the type converted to an equivalently sized integer or vector with integer element type.
static MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
Definition: ValueTypes.cpp:571
bool bitsLT(MVT VT) const
Return true if this has less bits than VT.
static auto all_valuetypes()
SimpleValueType Iteration.
bool operator<(const MVT &S) const
static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable)
bool is512BitVector() const
Return true if this is a 512-bit vector type.
bool operator==(const MVT &S) const
static auto integer_valuetypes()
bool is1024BitVector() const
Return true if this is a 1024-bit vector type.
TypeSize getSizeInBits() const
Returns the size of the specified MVT in bits.
bool isPow2VectorType() const
Returns true if the given vector is a power of 2.
uint64_t getScalarStoreSize() const
static auto scalable_vector_valuetypes()
static auto fixedlen_vector_valuetypes()
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
bool bitsGT(MVT VT) const
Return true if this has more bits than VT.
bool isFixedLengthVector() const
static auto vector_valuetypes()
bool is256BitVector() const
Return true if this is a 256-bit vector type.
ElementCount getVectorElementCount() const
TypeSize getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
bool bitsGE(MVT VT) const
Return true if this has no less bits than VT.
bool isScalarInteger() const
Return true if this is an integer, not including vectors.
TypeSize getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
static MVT getVectorVT(MVT VT, unsigned NumElements)
bool knownBitsGE(MVT VT) const
Return true if we know at compile time this has more than or the same bits as VT.
static auto fp_scalable_vector_valuetypes()
MVT getVectorElementType() const
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
bool operator>=(const MVT &S) const
bool isValid() const
Return true if this is a valid simple valuetype.
static MVT getIntegerVT(unsigned BitWidth)
static auto fp_valuetypes()
MVT getHalfNumVectorElementsVT() const
Return a VT for a vector type with the same element type but half the number of elements.
bool knownBitsLE(MVT VT) const
Return true if we know at compile time this has fewer than or the same bits as VT.
bool operator!=(const MVT &S) const
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
static auto integer_scalable_vector_valuetypes()
void print(raw_ostream &OS) const
Implement operator<<.
Definition: ValueTypes.cpp:626
bool is64BitVector() const
Return true if this is a 64-bit vector type.
MVT changeVectorElementTypeToInteger() const
Return a vector with the same number of elements as this vector, but with the element type converted ...
MVT getPow2VectorType() const
Widens the length of the given vector MVT up to the nearest power of 2 and returns that type.
static auto fp_fixedlen_vector_valuetypes()
constexpr MVT(SimpleValueType SVT)
bool is2048BitVector() const
Return true if this is a 2048-bit vector type.
Root of the metadata hierarchy.
Definition: Metadata.h:61
static constexpr TypeSize Fixed(ScalarTy ExactSize)
Definition: TypeSize.h:331
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
constexpr bool isKnownMultipleOf(ScalarTy RHS) const
This function tells the caller whether the element count is known at compile time to be a multiple of...
Definition: TypeSize.h:175
constexpr ScalarTy getFixedValue() const
Definition: TypeSize.h:182
static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition: TypeSize.h:212
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition: TypeSize.h:198
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
Definition: TypeSize.h:166
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
Definition: TypeSize.h:163
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition: TypeSize.h:205
static constexpr bool isKnownGE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
Definition: TypeSize.h:219
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
Definition: MathExtras.h:386
auto enum_seq_inclusive(EnumT Begin, EnumT End)
Iterate over an enum type from Begin to End inclusive.
Definition: Sequence.h:354
constexpr force_iteration_on_noniterable_enum_t force_iteration_on_noniterable_enum
Definition: Sequence.h:108
void reportInvalidSizeRequest(const char *Msg)
Reports a diagnostic message to indicate an invalid size request has been done on a scalable vector.
Definition: TypeSize.cpp:38
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:292
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:147