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 aarch64svcount = 196, // AArch64 predicate-as-counter
295 spirvbuiltin = 197, // SPIR-V's builtin type
296
297 FIRST_VALUETYPE = 1, // This is always the beginning of the list.
298 LAST_VALUETYPE = spirvbuiltin, // This always remains at the end of the list.
300
301 // This is the current maximum for LAST_VALUETYPE.
302 // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
303 // This value must be a multiple of 32.
305
306 // A value of type llvm::TokenTy
307 token = 248,
308
309 // This is MDNode or MDString.
310 Metadata = 249,
311
312 // An int value the size of the pointer of the current
313 // target to any address space. This must only be used internal to
314 // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
315 iPTRAny = 250,
316
317 // A vector with any length and element size. This is used
318 // for intrinsics that have overloadings based on vector types.
319 // This is only for tblgen's consumption!
320 vAny = 251,
321
322 // Any floating-point or vector floating-point value. This is used
323 // for intrinsics that have overloadings based on floating-point types.
324 // This is only for tblgen's consumption!
325 fAny = 252,
326
327 // An integer or vector integer value of any bit width. This is
328 // used for intrinsics that have overloadings based on integer bit widths.
329 // This is only for tblgen's consumption!
330 iAny = 253,
331
332 // An int value the size of the pointer of the current
333 // target. This should only be used internal to tblgen!
334 iPTR = 254,
335
336 // Any type. This is used for intrinsics that have overloadings.
337 // This is only for tblgen's consumption!
338 Any = 255
339
340 // clang-format on
341 };
342
344
345 constexpr MVT() = default;
346 constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {}
347
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 bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
353 bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
354
355 /// Support for debugging, callable in GDB: VT.dump()
356 void dump() const;
357
358 /// Implement operator<<.
359 void print(raw_ostream &OS) const;
360
361 /// Return true if this is a valid simple valuetype.
362 bool isValid() const {
363 return (SimpleTy >= MVT::FIRST_VALUETYPE &&
365 }
366
367 /// Return true if this is a FP or a vector FP type.
368 bool isFloatingPoint() const {
369 return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
375 }
376
377 /// Return true if this is an integer or a vector integer type.
378 bool isInteger() const {
385 }
386
387 /// Return true if this is an integer, not including vectors.
388 bool isScalarInteger() const {
391 }
392
393 /// Return true if this is a vector value type.
394 bool isVector() const {
397 }
398
399 /// Return true if this is a vector value type where the
400 /// runtime length is machine dependent
401 bool isScalableVector() const {
404 }
405
406 /// Return true if this is a custom target type that has a scalable size.
409 }
410
411 /// Return true if the type is a scalable type.
412 bool isScalableVT() const {
414 }
415
416 bool isFixedLengthVector() const {
419 }
420
421 /// Return true if this is a 16-bit vector type.
422 bool is16BitVector() const {
423 return (SimpleTy == MVT::v2i8 || SimpleTy == MVT::v1i16 ||
425 }
426
427 /// Return true if this is a 32-bit vector type.
428 bool is32BitVector() const {
429 return (SimpleTy == MVT::v32i1 || SimpleTy == MVT::v4i8 ||
433 }
434
435 /// Return true if this is a 64-bit vector type.
436 bool is64BitVector() const {
437 return (SimpleTy == MVT::v64i1 || SimpleTy == MVT::v8i8 ||
442 }
443
444 /// Return true if this is a 128-bit vector type.
445 bool is128BitVector() const {
446 return (SimpleTy == MVT::v128i1 || SimpleTy == MVT::v16i8 ||
451 }
452
453 /// Return true if this is a 256-bit vector type.
454 bool is256BitVector() const {
455 return (SimpleTy == MVT::v16f16 || SimpleTy == MVT::v16bf16 ||
461 }
462
463 /// Return true if this is a 512-bit vector type.
464 bool is512BitVector() const {
465 return (SimpleTy == MVT::v32f16 || SimpleTy == MVT::v32bf16 ||
471 }
472
473 /// Return true if this is a 1024-bit vector type.
474 bool is1024BitVector() const {
475 return (SimpleTy == MVT::v1024i1 || SimpleTy == MVT::v128i8 ||
480 }
481
482 /// Return true if this is a 2048-bit vector type.
483 bool is2048BitVector() const {
484 return (SimpleTy == MVT::v256i8 || SimpleTy == MVT::v128i16 ||
489 }
490
491 /// Return true if this is an overloaded type for TableGen.
492 bool isOverloaded() const {
493 return (SimpleTy == MVT::Any || SimpleTy == MVT::iAny ||
496 }
497
498 /// Return a vector with the same number of elements as this vector, but
499 /// with the element type converted to an integer type with the same
500 /// bitwidth.
502 MVT EltTy = getVectorElementType();
503 MVT IntTy = MVT::getIntegerVT(EltTy.getSizeInBits());
506 "Simple vector VT not representable by simple integer vector VT!");
507 return VecTy;
508 }
509
510 /// Return a VT for a vector type whose attributes match ourselves
511 /// with the exception of the element type that is chosen by the caller.
515 "Simple vector VT not representable by simple integer vector VT!");
516 return VecTy;
517 }
518
519 /// Return the type converted to an equivalently sized integer or vector
520 /// with integer element type. Similar to changeVectorElementTypeToInteger,
521 /// but also handles scalars.
523 if (isVector())
526 }
527
528 /// Return a VT for a vector type with the same element type but
529 /// half the number of elements.
531 MVT EltVT = getVectorElementType();
532 auto EltCnt = getVectorElementCount();
533 assert(EltCnt.isKnownEven() && "Splitting vector, but not in half!");
534 return getVectorVT(EltVT, EltCnt.divideCoefficientBy(2));
535 }
536
537 /// Returns true if the given vector is a power of 2.
538 bool isPow2VectorType() const {
539 unsigned NElts = getVectorMinNumElements();
540 return !(NElts & (NElts - 1));
541 }
542
543 /// Widens the length of the given vector MVT up to the nearest power of 2
544 /// and returns that type.
546 if (isPow2VectorType())
547 return *this;
548
550 unsigned NewMinCount = 1 << Log2_32_Ceil(NElts.getKnownMinValue());
551 NElts = ElementCount::get(NewMinCount, NElts.isScalable());
552 return MVT::getVectorVT(getVectorElementType(), NElts);
553 }
554
555 /// If this is a vector, return the element type, otherwise return this.
557 return isVector() ? getVectorElementType() : *this;
558 }
559
561 // clang-format off
562 switch (SimpleTy) {
563 default:
564 llvm_unreachable("Not a vector MVT!");
565 case v1i1:
566 case v2i1:
567 case v4i1:
568 case v8i1:
569 case v16i1:
570 case v32i1:
571 case v64i1:
572 case v128i1:
573 case v256i1:
574 case v512i1:
575 case v1024i1:
576 case v2048i1:
577 case nxv1i1:
578 case nxv2i1:
579 case nxv4i1:
580 case nxv8i1:
581 case nxv16i1:
582 case nxv32i1:
583 case nxv64i1: return i1;
584 case v128i2:
585 case v256i2: return i2;
586 case v64i4:
587 case v128i4: return i4;
588 case v1i8:
589 case v2i8:
590 case v4i8:
591 case v8i8:
592 case v16i8:
593 case v32i8:
594 case v64i8:
595 case v128i8:
596 case v256i8:
597 case v512i8:
598 case v1024i8:
599 case nxv1i8:
600 case nxv2i8:
601 case nxv4i8:
602 case nxv8i8:
603 case nxv16i8:
604 case nxv32i8:
605 case nxv64i8: return i8;
606 case v1i16:
607 case v2i16:
608 case v3i16:
609 case v4i16:
610 case v8i16:
611 case v16i16:
612 case v32i16:
613 case v64i16:
614 case v128i16:
615 case v256i16:
616 case v512i16:
617 case nxv1i16:
618 case nxv2i16:
619 case nxv4i16:
620 case nxv8i16:
621 case nxv16i16:
622 case nxv32i16: return i16;
623 case v1i32:
624 case v2i32:
625 case v3i32:
626 case v4i32:
627 case v5i32:
628 case v6i32:
629 case v7i32:
630 case v8i32:
631 case v9i32:
632 case v10i32:
633 case v11i32:
634 case v12i32:
635 case v16i32:
636 case v32i32:
637 case v64i32:
638 case v128i32:
639 case v256i32:
640 case v512i32:
641 case v1024i32:
642 case v2048i32:
643 case nxv1i32:
644 case nxv2i32:
645 case nxv4i32:
646 case nxv8i32:
647 case nxv16i32:
648 case nxv32i32: return i32;
649 case v1i64:
650 case v2i64:
651 case v3i64:
652 case v4i64:
653 case v8i64:
654 case v16i64:
655 case v32i64:
656 case v64i64:
657 case v128i64:
658 case v256i64:
659 case nxv1i64:
660 case nxv2i64:
661 case nxv4i64:
662 case nxv8i64:
663 case nxv16i64:
664 case nxv32i64: return i64;
665 case v1i128: return i128;
666 case v1f16:
667 case v2f16:
668 case v3f16:
669 case v4f16:
670 case v8f16:
671 case v16f16:
672 case v32f16:
673 case v64f16:
674 case v128f16:
675 case v256f16:
676 case v512f16:
677 case nxv1f16:
678 case nxv2f16:
679 case nxv4f16:
680 case nxv8f16:
681 case nxv16f16:
682 case nxv32f16: return f16;
683 case v2bf16:
684 case v3bf16:
685 case v4bf16:
686 case v8bf16:
687 case v16bf16:
688 case v32bf16:
689 case v64bf16:
690 case v128bf16:
691 case nxv1bf16:
692 case nxv2bf16:
693 case nxv4bf16:
694 case nxv8bf16:
695 case nxv16bf16:
696 case nxv32bf16: return bf16;
697 case v1f32:
698 case v2f32:
699 case v3f32:
700 case v4f32:
701 case v5f32:
702 case v6f32:
703 case v7f32:
704 case v8f32:
705 case v9f32:
706 case v10f32:
707 case v11f32:
708 case v12f32:
709 case v16f32:
710 case v32f32:
711 case v64f32:
712 case v128f32:
713 case v256f32:
714 case v512f32:
715 case v1024f32:
716 case v2048f32:
717 case nxv1f32:
718 case nxv2f32:
719 case nxv4f32:
720 case nxv8f32:
721 case nxv16f32: return f32;
722 case v1f64:
723 case v2f64:
724 case v3f64:
725 case v4f64:
726 case v8f64:
727 case v16f64:
728 case v32f64:
729 case v64f64:
730 case v128f64:
731 case v256f64:
732 case nxv1f64:
733 case nxv2f64:
734 case nxv4f64:
735 case nxv8f64: return f64;
736 }
737 // clang-format on
738 }
739
740 /// Given a vector type, return the minimum number of elements it contains.
741 unsigned getVectorMinNumElements() const {
742 switch (SimpleTy) {
743 default:
744 llvm_unreachable("Not a vector MVT!");
745 case v2048i1:
746 case v2048i32:
747 case v2048f32: return 2048;
748 case v1024i1:
749 case v1024i8:
750 case v1024i32:
751 case v1024f32: return 1024;
752 case v512i1:
753 case v512i8:
754 case v512i16:
755 case v512i32:
756 case v512f16:
757 case v512f32: return 512;
758 case v256i1:
759 case v256i2:
760 case v256i8:
761 case v256i16:
762 case v256f16:
763 case v256i32:
764 case v256i64:
765 case v256f32:
766 case v256f64: return 256;
767 case v128i1:
768 case v128i2:
769 case v128i4:
770 case v128i8:
771 case v128i16:
772 case v128i32:
773 case v128i64:
774 case v128f16:
775 case v128bf16:
776 case v128f32:
777 case v128f64: return 128;
778 case v64i1:
779 case v64i4:
780 case v64i8:
781 case v64i16:
782 case v64i32:
783 case v64i64:
784 case v64f16:
785 case v64bf16:
786 case v64f32:
787 case v64f64:
788 case nxv64i1:
789 case nxv64i8: return 64;
790 case v32i1:
791 case v32i8:
792 case v32i16:
793 case v32i32:
794 case v32i64:
795 case v32f16:
796 case v32bf16:
797 case v32f32:
798 case v32f64:
799 case nxv32i1:
800 case nxv32i8:
801 case nxv32i16:
802 case nxv32i32:
803 case nxv32i64:
804 case nxv32f16:
805 case nxv32bf16: return 32;
806 case v16i1:
807 case v16i8:
808 case v16i16:
809 case v16i32:
810 case v16i64:
811 case v16f16:
812 case v16bf16:
813 case v16f32:
814 case v16f64:
815 case nxv16i1:
816 case nxv16i8:
817 case nxv16i16:
818 case nxv16i32:
819 case nxv16i64:
820 case nxv16f16:
821 case nxv16bf16:
822 case nxv16f32: return 16;
823 case v12i32:
824 case v12f32: return 12;
825 case v11i32:
826 case v11f32: return 11;
827 case v10i32:
828 case v10f32: return 10;
829 case v9i32:
830 case v9f32: return 9;
831 case v8i1:
832 case v8i8:
833 case v8i16:
834 case v8i32:
835 case v8i64:
836 case v8f16:
837 case v8bf16:
838 case v8f32:
839 case v8f64:
840 case nxv8i1:
841 case nxv8i8:
842 case nxv8i16:
843 case nxv8i32:
844 case nxv8i64:
845 case nxv8f16:
846 case nxv8bf16:
847 case nxv8f32:
848 case nxv8f64: return 8;
849 case v7i32:
850 case v7f32: return 7;
851 case v6i32:
852 case v6f32: return 6;
853 case v5i32:
854 case v5f32: return 5;
855 case v4i1:
856 case v4i8:
857 case v4i16:
858 case v4i32:
859 case v4i64:
860 case v4f16:
861 case v4bf16:
862 case v4f32:
863 case v4f64:
864 case nxv4i1:
865 case nxv4i8:
866 case nxv4i16:
867 case nxv4i32:
868 case nxv4i64:
869 case nxv4f16:
870 case nxv4bf16:
871 case nxv4f32:
872 case nxv4f64: return 4;
873 case v3i16:
874 case v3i32:
875 case v3i64:
876 case v3f16:
877 case v3bf16:
878 case v3f32:
879 case v3f64: return 3;
880 case v2i1:
881 case v2i8:
882 case v2i16:
883 case v2i32:
884 case v2i64:
885 case v2f16:
886 case v2bf16:
887 case v2f32:
888 case v2f64:
889 case nxv2i1:
890 case nxv2i8:
891 case nxv2i16:
892 case nxv2i32:
893 case nxv2i64:
894 case nxv2f16:
895 case nxv2bf16:
896 case nxv2f32:
897 case nxv2f64: return 2;
898 case v1i1:
899 case v1i8:
900 case v1i16:
901 case v1i32:
902 case v1i64:
903 case v1i128:
904 case v1f16:
905 case v1f32:
906 case v1f64:
907 case nxv1i1:
908 case nxv1i8:
909 case nxv1i16:
910 case nxv1i32:
911 case nxv1i64:
912 case nxv1f16:
913 case nxv1bf16:
914 case nxv1f32:
915 case nxv1f64: return 1;
916 }
917 }
918
921 }
922
923 unsigned getVectorNumElements() const {
924 if (isScalableVector())
926 "Possible incorrect use of MVT::getVectorNumElements() for "
927 "scalable vector. Scalable flag may be dropped, use "
928 "MVT::getVectorElementCount() instead");
930 }
931
932 /// Returns the size of the specified MVT in bits.
933 ///
934 /// If the value type is a scalable vector type, the scalable property will
935 /// be set and the runtime size will be a positive integer multiple of the
936 /// base size.
938 switch (SimpleTy) {
939 default:
940 llvm_unreachable("getSizeInBits called on extended MVT.");
941 case Other:
942 llvm_unreachable("Value type is non-standard value, Other.");
943 case iPTR:
944 llvm_unreachable("Value type size is target-dependent. Ask TLI.");
945 case iPTRAny:
946 case iAny:
947 case fAny:
948 case vAny:
949 case Any:
950 llvm_unreachable("Value type is overloaded.");
951 case token:
952 llvm_unreachable("Token type is a sentinel that cannot be used "
953 "in codegen and has no size");
954 case Metadata:
955 llvm_unreachable("Value type is metadata.");
956 case i1:
957 case v1i1: return TypeSize::Fixed(1);
958 case nxv1i1: return TypeSize::Scalable(1);
959 case i2:
960 case v2i1: return TypeSize::Fixed(2);
961 case nxv2i1: return TypeSize::Scalable(2);
962 case i4:
963 case v4i1: return TypeSize::Fixed(4);
964 case nxv4i1: return TypeSize::Scalable(4);
965 case i8 :
966 case v1i8:
967 case v8i1: return TypeSize::Fixed(8);
968 case nxv1i8:
969 case nxv8i1: return TypeSize::Scalable(8);
970 case i16 :
971 case f16:
972 case bf16:
973 case v16i1:
974 case v2i8:
975 case v1i16:
976 case v1f16: return TypeSize::Fixed(16);
977 case aarch64svcount:
978 case nxv16i1:
979 case nxv2i8:
980 case nxv1i16:
981 case nxv1bf16:
982 case nxv1f16: return TypeSize::Scalable(16);
983 case f32 :
984 case i32 :
985 case v32i1:
986 case v4i8:
987 case v2i16:
988 case v2f16:
989 case v2bf16:
990 case v1f32:
991 case v1i32: return TypeSize::Fixed(32);
992 case nxv32i1:
993 case nxv4i8:
994 case nxv2i16:
995 case nxv1i32:
996 case nxv2f16:
997 case nxv2bf16:
998 case nxv1f32: return TypeSize::Scalable(32);
999 case v3i16:
1000 case v3f16:
1001 case v3bf16: return TypeSize::Fixed(48);
1002 case x86mmx:
1003 case f64 :
1004 case i64 :
1005 case v64i1:
1006 case v8i8:
1007 case v4i16:
1008 case v2i32:
1009 case v1i64:
1010 case v4f16:
1011 case v4bf16:
1012 case v2f32:
1013 case v1f64: return TypeSize::Fixed(64);
1014 case nxv64i1:
1015 case nxv8i8:
1016 case nxv4i16:
1017 case nxv2i32:
1018 case nxv1i64:
1019 case nxv4f16:
1020 case nxv4bf16:
1021 case nxv2f32:
1022 case nxv1f64: return TypeSize::Scalable(64);
1023 case f80 : return TypeSize::Fixed(80);
1024 case v3i32:
1025 case v3f32: return TypeSize::Fixed(96);
1026 case f128:
1027 case ppcf128:
1028 case i128:
1029 case v128i1:
1030 case v16i8:
1031 case v8i16:
1032 case v4i32:
1033 case v2i64:
1034 case v1i128:
1035 case v8f16:
1036 case v8bf16:
1037 case v4f32:
1038 case v2f64: return TypeSize::Fixed(128);
1039 case nxv16i8:
1040 case nxv8i16:
1041 case nxv4i32:
1042 case nxv2i64:
1043 case nxv8f16:
1044 case nxv8bf16:
1045 case nxv4f32:
1046 case nxv2f64: return TypeSize::Scalable(128);
1047 case v5i32:
1048 case v5f32: return TypeSize::Fixed(160);
1049 case v6i32:
1050 case v3i64:
1051 case v6f32:
1052 case v3f64: return TypeSize::Fixed(192);
1053 case v7i32:
1054 case v7f32: return TypeSize::Fixed(224);
1055 case v256i1:
1056 case v128i2:
1057 case v64i4:
1058 case v32i8:
1059 case v16i16:
1060 case v8i32:
1061 case v4i64:
1062 case v16f16:
1063 case v16bf16:
1064 case v8f32:
1065 case v4f64: return TypeSize::Fixed(256);
1066 case nxv32i8:
1067 case nxv16i16:
1068 case nxv8i32:
1069 case nxv4i64:
1070 case nxv16f16:
1071 case nxv16bf16:
1072 case nxv8f32:
1073 case nxv4f64: return TypeSize::Scalable(256);
1074 case v9i32:
1075 case v9f32: return TypeSize::Fixed(288);
1076 case v10i32:
1077 case v10f32: return TypeSize::Fixed(320);
1078 case v11i32:
1079 case v11f32: return TypeSize::Fixed(352);
1080 case v12i32:
1081 case v12f32: return TypeSize::Fixed(384);
1082 case i64x8:
1083 case v512i1:
1084 case v256i2:
1085 case v128i4:
1086 case v64i8:
1087 case v32i16:
1088 case v16i32:
1089 case v8i64:
1090 case v32f16:
1091 case v32bf16:
1092 case v16f32:
1093 case v8f64: return TypeSize::Fixed(512);
1094 case nxv64i8:
1095 case nxv32i16:
1096 case nxv16i32:
1097 case nxv8i64:
1098 case nxv32f16:
1099 case nxv32bf16:
1100 case nxv16f32:
1101 case nxv8f64: return TypeSize::Scalable(512);
1102 case v1024i1:
1103 case v128i8:
1104 case v64i16:
1105 case v32i32:
1106 case v16i64:
1107 case v64f16:
1108 case v64bf16:
1109 case v32f32:
1110 case v16f64: return TypeSize::Fixed(1024);
1111 case nxv32i32:
1112 case nxv16i64: return TypeSize::Scalable(1024);
1113 case v2048i1:
1114 case v256i8:
1115 case v128i16:
1116 case v64i32:
1117 case v32i64:
1118 case v128f16:
1119 case v128bf16:
1120 case v64f32:
1121 case v32f64: return TypeSize::Fixed(2048);
1122 case nxv32i64: return TypeSize::Scalable(2048);
1123 case v512i8:
1124 case v256i16:
1125 case v128i32:
1126 case v64i64:
1127 case v256f16:
1128 case v128f32:
1129 case v64f64: return TypeSize::Fixed(4096);
1130 case v1024i8:
1131 case v512i16:
1132 case v256i32:
1133 case v128i64:
1134 case v512f16:
1135 case v256f32:
1136 case x86amx:
1137 case v128f64: return TypeSize::Fixed(8192);
1138 case v512i32:
1139 case v256i64:
1140 case v512f32:
1141 case v256f64: return TypeSize::Fixed(16384);
1142 case v1024i32:
1143 case v1024f32: return TypeSize::Fixed(32768);
1144 case v2048i32:
1145 case v2048f32: return TypeSize::Fixed(65536);
1146 case funcref:
1147 case externref:
1148 case spirvbuiltin:
1149 return TypeSize::Fixed(0); // opaque type
1150 }
1151 }
1152
1153 /// Return the size of the specified fixed width value type in bits. The
1154 /// function will assert if the type is scalable.
1156 return getSizeInBits().getFixedValue();
1157 }
1158
1161 }
1162
1163 /// Return the number of bytes overwritten by a store of the specified value
1164 /// type.
1165 ///
1166 /// If the value type is a scalable vector type, the scalable property will
1167 /// be set and the runtime size will be a positive integer multiple of the
1168 /// base size.
1170 TypeSize BaseSize = getSizeInBits();
1171 return {(BaseSize.getKnownMinValue() + 7) / 8, BaseSize.isScalable()};
1172 }
1173
1174 // Return the number of bytes overwritten by a store of this value type or
1175 // this value type's element type in the case of a vector.
1178 }
1179
1180 /// Return the number of bits overwritten by a store of the specified value
1181 /// type.
1182 ///
1183 /// If the value type is a scalable vector type, the scalable property will
1184 /// be set and the runtime size will be a positive integer multiple of the
1185 /// base size.
1187 return getStoreSize() * 8;
1188 }
1189
1190 /// Returns true if the number of bits for the type is a multiple of an
1191 /// 8-bit byte.
1192 bool isByteSized() const { return getSizeInBits().isKnownMultipleOf(8); }
1193
1194 /// Return true if we know at compile time this has more bits than VT.
1195 bool knownBitsGT(MVT VT) const {
1197 }
1198
1199 /// Return true if we know at compile time this has more than or the same
1200 /// bits as VT.
1201 bool knownBitsGE(MVT VT) const {
1203 }
1204
1205 /// Return true if we know at compile time this has fewer bits than VT.
1206 bool knownBitsLT(MVT VT) const {
1208 }
1209
1210 /// Return true if we know at compile time this has fewer than or the same
1211 /// bits as VT.
1212 bool knownBitsLE(MVT VT) const {
1214 }
1215
1216 /// Return true if this has more bits than VT.
1217 bool bitsGT(MVT VT) const {
1219 "Comparison between scalable and fixed types");
1220 return knownBitsGT(VT);
1221 }
1222
1223 /// Return true if this has no less bits than VT.
1224 bool bitsGE(MVT VT) const {
1226 "Comparison between scalable and fixed types");
1227 return knownBitsGE(VT);
1228 }
1229
1230 /// Return true if this has less bits than VT.
1231 bool bitsLT(MVT VT) const {
1233 "Comparison between scalable and fixed types");
1234 return knownBitsLT(VT);
1235 }
1236
1237 /// Return true if this has no more bits than VT.
1238 bool bitsLE(MVT VT) const {
1240 "Comparison between scalable and fixed types");
1241 return knownBitsLE(VT);
1242 }
1243
1245 switch (BitWidth) {
1246 default:
1247 llvm_unreachable("Bad bit width!");
1248 case 16:
1249 return MVT::f16;
1250 case 32:
1251 return MVT::f32;
1252 case 64:
1253 return MVT::f64;
1254 case 80:
1255 return MVT::f80;
1256 case 128:
1257 return MVT::f128;
1258 }
1259 }
1260
1261 static MVT getIntegerVT(unsigned BitWidth) {
1262 switch (BitWidth) {
1263 default:
1265 case 1:
1266 return MVT::i1;
1267 case 2:
1268 return MVT::i2;
1269 case 4:
1270 return MVT::i4;
1271 case 8:
1272 return MVT::i8;
1273 case 16:
1274 return MVT::i16;
1275 case 32:
1276 return MVT::i32;
1277 case 64:
1278 return MVT::i64;
1279 case 128:
1280 return MVT::i128;
1281 }
1282 }
1283
1284 static MVT getVectorVT(MVT VT, unsigned NumElements) {
1285 // clang-format off
1286 switch (VT.SimpleTy) {
1287 default:
1288 break;
1289 case MVT::i1:
1290 if (NumElements == 1) return MVT::v1i1;
1291 if (NumElements == 2) return MVT::v2i1;
1292 if (NumElements == 4) return MVT::v4i1;
1293 if (NumElements == 8) return MVT::v8i1;
1294 if (NumElements == 16) return MVT::v16i1;
1295 if (NumElements == 32) return MVT::v32i1;
1296 if (NumElements == 64) return MVT::v64i1;
1297 if (NumElements == 128) return MVT::v128i1;
1298 if (NumElements == 256) return MVT::v256i1;
1299 if (NumElements == 512) return MVT::v512i1;
1300 if (NumElements == 1024) return MVT::v1024i1;
1301 if (NumElements == 2048) return MVT::v2048i1;
1302 break;
1303 case MVT::i2:
1304 if (NumElements == 128) return MVT::v128i2;
1305 if (NumElements == 256) return MVT::v256i2;
1306 break;
1307 case MVT::i4:
1308 if (NumElements == 64) return MVT::v64i4;
1309 if (NumElements == 128) return MVT::v128i4;
1310 break;
1311 case MVT::i8:
1312 if (NumElements == 1) return MVT::v1i8;
1313 if (NumElements == 2) return MVT::v2i8;
1314 if (NumElements == 4) return MVT::v4i8;
1315 if (NumElements == 8) return MVT::v8i8;
1316 if (NumElements == 16) return MVT::v16i8;
1317 if (NumElements == 32) return MVT::v32i8;
1318 if (NumElements == 64) return MVT::v64i8;
1319 if (NumElements == 128) return MVT::v128i8;
1320 if (NumElements == 256) return MVT::v256i8;
1321 if (NumElements == 512) return MVT::v512i8;
1322 if (NumElements == 1024) return MVT::v1024i8;
1323 break;
1324 case MVT::i16:
1325 if (NumElements == 1) return MVT::v1i16;
1326 if (NumElements == 2) return MVT::v2i16;
1327 if (NumElements == 3) return MVT::v3i16;
1328 if (NumElements == 4) return MVT::v4i16;
1329 if (NumElements == 8) return MVT::v8i16;
1330 if (NumElements == 16) return MVT::v16i16;
1331 if (NumElements == 32) return MVT::v32i16;
1332 if (NumElements == 64) return MVT::v64i16;
1333 if (NumElements == 128) return MVT::v128i16;
1334 if (NumElements == 256) return MVT::v256i16;
1335 if (NumElements == 512) return MVT::v512i16;
1336 break;
1337 case MVT::i32:
1338 if (NumElements == 1) return MVT::v1i32;
1339 if (NumElements == 2) return MVT::v2i32;
1340 if (NumElements == 3) return MVT::v3i32;
1341 if (NumElements == 4) return MVT::v4i32;
1342 if (NumElements == 5) return MVT::v5i32;
1343 if (NumElements == 6) return MVT::v6i32;
1344 if (NumElements == 7) return MVT::v7i32;
1345 if (NumElements == 8) return MVT::v8i32;
1346 if (NumElements == 9) return MVT::v9i32;
1347 if (NumElements == 10) return MVT::v10i32;
1348 if (NumElements == 11) return MVT::v11i32;
1349 if (NumElements == 12) return MVT::v12i32;
1350 if (NumElements == 16) return MVT::v16i32;
1351 if (NumElements == 32) return MVT::v32i32;
1352 if (NumElements == 64) return MVT::v64i32;
1353 if (NumElements == 128) return MVT::v128i32;
1354 if (NumElements == 256) return MVT::v256i32;
1355 if (NumElements == 512) return MVT::v512i32;
1356 if (NumElements == 1024) return MVT::v1024i32;
1357 if (NumElements == 2048) return MVT::v2048i32;
1358 break;
1359 case MVT::i64:
1360 if (NumElements == 1) return MVT::v1i64;
1361 if (NumElements == 2) return MVT::v2i64;
1362 if (NumElements == 3) return MVT::v3i64;
1363 if (NumElements == 4) return MVT::v4i64;
1364 if (NumElements == 8) return MVT::v8i64;
1365 if (NumElements == 16) return MVT::v16i64;
1366 if (NumElements == 32) return MVT::v32i64;
1367 if (NumElements == 64) return MVT::v64i64;
1368 if (NumElements == 128) return MVT::v128i64;
1369 if (NumElements == 256) return MVT::v256i64;
1370 break;
1371 case MVT::i128:
1372 if (NumElements == 1) return MVT::v1i128;
1373 break;
1374 case MVT::f16:
1375 if (NumElements == 1) return MVT::v1f16;
1376 if (NumElements == 2) return MVT::v2f16;
1377 if (NumElements == 3) return MVT::v3f16;
1378 if (NumElements == 4) return MVT::v4f16;
1379 if (NumElements == 8) return MVT::v8f16;
1380 if (NumElements == 16) return MVT::v16f16;
1381 if (NumElements == 32) return MVT::v32f16;
1382 if (NumElements == 64) return MVT::v64f16;
1383 if (NumElements == 128) return MVT::v128f16;
1384 if (NumElements == 256) return MVT::v256f16;
1385 if (NumElements == 512) return MVT::v512f16;
1386 break;
1387 case MVT::bf16:
1388 if (NumElements == 2) return MVT::v2bf16;
1389 if (NumElements == 3) return MVT::v3bf16;
1390 if (NumElements == 4) return MVT::v4bf16;
1391 if (NumElements == 8) return MVT::v8bf16;
1392 if (NumElements == 16) return MVT::v16bf16;
1393 if (NumElements == 32) return MVT::v32bf16;
1394 if (NumElements == 64) return MVT::v64bf16;
1395 if (NumElements == 128) return MVT::v128bf16;
1396 break;
1397 case MVT::f32:
1398 if (NumElements == 1) return MVT::v1f32;
1399 if (NumElements == 2) return MVT::v2f32;
1400 if (NumElements == 3) return MVT::v3f32;
1401 if (NumElements == 4) return MVT::v4f32;
1402 if (NumElements == 5) return MVT::v5f32;
1403 if (NumElements == 6) return MVT::v6f32;
1404 if (NumElements == 7) return MVT::v7f32;
1405 if (NumElements == 8) return MVT::v8f32;
1406 if (NumElements == 9) return MVT::v9f32;
1407 if (NumElements == 10) return MVT::v10f32;
1408 if (NumElements == 11) return MVT::v11f32;
1409 if (NumElements == 12) return MVT::v12f32;
1410 if (NumElements == 16) return MVT::v16f32;
1411 if (NumElements == 32) return MVT::v32f32;
1412 if (NumElements == 64) return MVT::v64f32;
1413 if (NumElements == 128) return MVT::v128f32;
1414 if (NumElements == 256) return MVT::v256f32;
1415 if (NumElements == 512) return MVT::v512f32;
1416 if (NumElements == 1024) return MVT::v1024f32;
1417 if (NumElements == 2048) return MVT::v2048f32;
1418 break;
1419 case MVT::f64:
1420 if (NumElements == 1) return MVT::v1f64;
1421 if (NumElements == 2) return MVT::v2f64;
1422 if (NumElements == 3) return MVT::v3f64;
1423 if (NumElements == 4) return MVT::v4f64;
1424 if (NumElements == 8) return MVT::v8f64;
1425 if (NumElements == 16) return MVT::v16f64;
1426 if (NumElements == 32) return MVT::v32f64;
1427 if (NumElements == 64) return MVT::v64f64;
1428 if (NumElements == 128) return MVT::v128f64;
1429 if (NumElements == 256) return MVT::v256f64;
1430 break;
1431 }
1433 // clang-format on
1434 }
1435
1436 static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
1437 switch(VT.SimpleTy) {
1438 default:
1439 break;
1440 case MVT::i1:
1441 if (NumElements == 1) return MVT::nxv1i1;
1442 if (NumElements == 2) return MVT::nxv2i1;
1443 if (NumElements == 4) return MVT::nxv4i1;
1444 if (NumElements == 8) return MVT::nxv8i1;
1445 if (NumElements == 16) return MVT::nxv16i1;
1446 if (NumElements == 32) return MVT::nxv32i1;
1447 if (NumElements == 64) return MVT::nxv64i1;
1448 break;
1449 case MVT::i8:
1450 if (NumElements == 1) return MVT::nxv1i8;
1451 if (NumElements == 2) return MVT::nxv2i8;
1452 if (NumElements == 4) return MVT::nxv4i8;
1453 if (NumElements == 8) return MVT::nxv8i8;
1454 if (NumElements == 16) return MVT::nxv16i8;
1455 if (NumElements == 32) return MVT::nxv32i8;
1456 if (NumElements == 64) return MVT::nxv64i8;
1457 break;
1458 case MVT::i16:
1459 if (NumElements == 1) return MVT::nxv1i16;
1460 if (NumElements == 2) return MVT::nxv2i16;
1461 if (NumElements == 4) return MVT::nxv4i16;
1462 if (NumElements == 8) return MVT::nxv8i16;
1463 if (NumElements == 16) return MVT::nxv16i16;
1464 if (NumElements == 32) return MVT::nxv32i16;
1465 break;
1466 case MVT::i32:
1467 if (NumElements == 1) return MVT::nxv1i32;
1468 if (NumElements == 2) return MVT::nxv2i32;
1469 if (NumElements == 4) return MVT::nxv4i32;
1470 if (NumElements == 8) return MVT::nxv8i32;
1471 if (NumElements == 16) return MVT::nxv16i32;
1472 if (NumElements == 32) return MVT::nxv32i32;
1473 break;
1474 case MVT::i64:
1475 if (NumElements == 1) return MVT::nxv1i64;
1476 if (NumElements == 2) return MVT::nxv2i64;
1477 if (NumElements == 4) return MVT::nxv4i64;
1478 if (NumElements == 8) return MVT::nxv8i64;
1479 if (NumElements == 16) return MVT::nxv16i64;
1480 if (NumElements == 32) return MVT::nxv32i64;
1481 break;
1482 case MVT::f16:
1483 if (NumElements == 1) return MVT::nxv1f16;
1484 if (NumElements == 2) return MVT::nxv2f16;
1485 if (NumElements == 4) return MVT::nxv4f16;
1486 if (NumElements == 8) return MVT::nxv8f16;
1487 if (NumElements == 16) return MVT::nxv16f16;
1488 if (NumElements == 32) return MVT::nxv32f16;
1489 break;
1490 case MVT::bf16:
1491 if (NumElements == 1) return MVT::nxv1bf16;
1492 if (NumElements == 2) return MVT::nxv2bf16;
1493 if (NumElements == 4) return MVT::nxv4bf16;
1494 if (NumElements == 8) return MVT::nxv8bf16;
1495 if (NumElements == 16) return MVT::nxv16bf16;
1496 if (NumElements == 32) return MVT::nxv32bf16;
1497 break;
1498 case MVT::f32:
1499 if (NumElements == 1) return MVT::nxv1f32;
1500 if (NumElements == 2) return MVT::nxv2f32;
1501 if (NumElements == 4) return MVT::nxv4f32;
1502 if (NumElements == 8) return MVT::nxv8f32;
1503 if (NumElements == 16) return MVT::nxv16f32;
1504 break;
1505 case MVT::f64:
1506 if (NumElements == 1) return MVT::nxv1f64;
1507 if (NumElements == 2) return MVT::nxv2f64;
1508 if (NumElements == 4) return MVT::nxv4f64;
1509 if (NumElements == 8) return MVT::nxv8f64;
1510 break;
1511 }
1513 }
1514
1515 static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
1516 if (IsScalable)
1517 return getScalableVectorVT(VT, NumElements);
1518 return getVectorVT(VT, NumElements);
1519 }
1520
1522 if (EC.isScalable())
1523 return getScalableVectorVT(VT, EC.getKnownMinValue());
1524 return getVectorVT(VT, EC.getKnownMinValue());
1525 }
1526
1527 /// Return the value type corresponding to the specified type. This returns
1528 /// all pointers as iPTR. If HandleUnknown is true, unknown types are
1529 /// returned as Other, otherwise they are invalid.
1530 static MVT getVT(Type *Ty, bool HandleUnknown = false);
1531
1532 public:
1533 /// SimpleValueType Iteration
1534 /// @{
1535 static auto all_valuetypes() {
1538 }
1539
1540 static auto integer_valuetypes() {
1544 }
1545
1546 static auto fp_valuetypes() {
1549 }
1550
1551 static auto vector_valuetypes() {
1555 }
1556
1561 }
1562
1567 }
1568
1573 }
1574
1579 }
1580
1585 }
1586
1591 }
1592 /// @}
1593 };
1594
1595 inline raw_ostream &operator<<(raw_ostream &OS, const MVT &VT) {
1596 VT.print(OS);
1597 return OS;
1598 }
1599
1600} // end namespace llvm
1601
1602#endif // LLVM_SUPPORT_MACHINEVALUETYPE_H
RelocType Type
Definition: COFFYAML.cpp:390
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
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:632
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.
bool isScalableTargetExtVT() const
Return true if this is a custom target type that has a scalable size.
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:573
bool isScalableVT() const
Return true if the type is a scalable type.
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:638
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:395
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:184