LLVM  10.0.0svn
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 
21 #include <cassert>
22 
23 namespace llvm {
24 
25  class Type;
26 
27  /// Machine Value Type. Every type that is supported natively by some
28  /// processor targeted by LLVM occurs here. This means that any legal value
29  /// type can be represented by an MVT.
30  class MVT {
31  public:
32  enum SimpleValueType : uint8_t {
33  // Simple value types that aren't explicitly part of this enumeration
34  // are considered extended value types.
36 
37  // If you change this numbering, you must change the values in
38  // ValueTypes.td as well!
39  Other = 1, // This is a non-standard value
40  i1 = 2, // This is a 1 bit integer value
41  i8 = 3, // This is an 8 bit integer value
42  i16 = 4, // This is a 16 bit integer value
43  i32 = 5, // This is a 32 bit integer value
44  i64 = 6, // This is a 64 bit integer value
45  i128 = 7, // This is a 128 bit integer value
46 
49 
50  f16 = 8, // This is a 16 bit floating point value
51  f32 = 9, // This is a 32 bit floating point value
52  f64 = 10, // This is a 64 bit floating point value
53  f80 = 11, // This is a 80 bit floating point value
54  f128 = 12, // This is a 128 bit floating point value
55  ppcf128 = 13, // This is a PPC 128-bit floating point value
56 
59 
60  v1i1 = 14, // 1 x i1
61  v2i1 = 15, // 2 x i1
62  v4i1 = 16, // 4 x i1
63  v8i1 = 17, // 8 x i1
64  v16i1 = 18, // 16 x i1
65  v32i1 = 19, // 32 x i1
66  v64i1 = 20, // 64 x i1
67  v128i1 = 21, // 128 x i1
68  v512i1 = 22, // 512 x i1
69  v1024i1 = 23, // 1024 x i1
70 
71  v1i8 = 24, // 1 x i8
72  v2i8 = 25, // 2 x i8
73  v4i8 = 26, // 4 x i8
74  v8i8 = 27, // 8 x i8
75  v16i8 = 28, // 16 x i8
76  v32i8 = 29, // 32 x i8
77  v64i8 = 30, // 64 x i8
78  v128i8 = 31, //128 x i8
79  v256i8 = 32, //256 x i8
80 
81  v1i16 = 33, // 1 x i16
82  v2i16 = 34, // 2 x i16
83  v3i16 = 35, // 3 x i16
84  v4i16 = 36, // 4 x i16
85  v8i16 = 37, // 8 x i16
86  v16i16 = 38, // 16 x i16
87  v32i16 = 39, // 32 x i16
88  v64i16 = 40, // 64 x i16
89  v128i16 = 41, //128 x i16
90 
91  v1i32 = 42, // 1 x i32
92  v2i32 = 43, // 2 x i32
93  v3i32 = 44, // 3 x i32
94  v4i32 = 45, // 4 x i32
95  v5i32 = 46, // 5 x i32
96  v8i32 = 47, // 8 x i32
97  v16i32 = 48, // 16 x i32
98  v32i32 = 49, // 32 x i32
99  v64i32 = 50, // 64 x i32
100  v128i32 = 51, // 128 x i32
101  v256i32 = 52, // 256 x i32
102  v512i32 = 53, // 512 x i32
103  v1024i32 = 54, // 1024 x i32
104  v2048i32 = 55, // 2048 x i32
105 
106  v1i64 = 56, // 1 x i64
107  v2i64 = 57, // 2 x i64
108  v4i64 = 58, // 4 x i64
109  v8i64 = 59, // 8 x i64
110  v16i64 = 60, // 16 x i64
111  v32i64 = 61, // 32 x i64
112 
113  v1i128 = 62, // 1 x i128
114 
117 
118  v2f16 = 63, // 2 x f16
119  v3f16 = 64, // 3 x f16
120  v4f16 = 65, // 4 x f16
121  v8f16 = 66, // 8 x f16
122  v16f16 = 67, // 16 x f16
123  v32f16 = 68, // 32 x f16
124  v1f32 = 69, // 1 x f32
125  v2f32 = 70, // 2 x f32
126  v3f32 = 71, // 3 x f32
127  v4f32 = 72, // 4 x f32
128  v5f32 = 73, // 5 x f32
129  v8f32 = 74, // 8 x f32
130  v16f32 = 75, // 16 x f32
131  v32f32 = 76, // 32 x f32
132  v64f32 = 77, // 64 x f32
133  v128f32 = 78, // 128 x f32
134  v256f32 = 79, // 256 x f32
135  v512f32 = 80, // 512 x f32
136  v1024f32 = 81, // 1024 x f32
137  v2048f32 = 82, // 2048 x f32
138  v1f64 = 83, // 1 x f64
139  v2f64 = 84, // 2 x f64
140  v4f64 = 85, // 4 x f64
141  v8f64 = 86, // 8 x f64
142 
145 
148 
149  nxv1i1 = 87, // n x 1 x i1
150  nxv2i1 = 88, // n x 2 x i1
151  nxv4i1 = 89, // n x 4 x i1
152  nxv8i1 = 90, // n x 8 x i1
153  nxv16i1 = 91, // n x 16 x i1
154  nxv32i1 = 92, // n x 32 x i1
155 
156  nxv1i8 = 93, // n x 1 x i8
157  nxv2i8 = 94, // n x 2 x i8
158  nxv4i8 = 95, // n x 4 x i8
159  nxv8i8 = 96, // n x 8 x i8
160  nxv16i8 = 97, // n x 16 x i8
161  nxv32i8 = 98, // n x 32 x i8
162 
163  nxv1i16 = 99, // n x 1 x i16
164  nxv2i16 = 100, // n x 2 x i16
165  nxv4i16 = 101, // n x 4 x i16
166  nxv8i16 = 102, // n x 8 x i16
167  nxv16i16 = 103, // n x 16 x i16
168  nxv32i16 = 104, // n x 32 x i16
169 
170  nxv1i32 = 105, // n x 1 x i32
171  nxv2i32 = 106, // n x 2 x i32
172  nxv4i32 = 107, // n x 4 x i32
173  nxv8i32 = 108, // n x 8 x i32
174  nxv16i32 = 109, // n x 16 x i32
175  nxv32i32 = 110, // n x 32 x i32
176 
177  nxv1i64 = 111, // n x 1 x i64
178  nxv2i64 = 112, // n x 2 x i64
179  nxv4i64 = 113, // n x 4 x i64
180  nxv8i64 = 114, // n x 8 x i64
181  nxv16i64 = 115, // n x 16 x i64
182  nxv32i64 = 116, // n x 32 x i64
183 
186 
187  nxv2f16 = 117, // n x 2 x f16
188  nxv4f16 = 118, // n x 4 x f16
189  nxv8f16 = 119, // n x 8 x f16
190  nxv1f32 = 120, // n x 1 x f32
191  nxv2f32 = 121, // n x 2 x f32
192  nxv4f32 = 122, // n x 4 x f32
193  nxv8f32 = 123, // n x 8 x f32
194  nxv16f32 = 124, // n x 16 x f32
195  nxv1f64 = 125, // n x 1 x f64
196  nxv2f64 = 126, // n x 2 x f64
197  nxv4f64 = 127, // n x 4 x f64
198  nxv8f64 = 128, // n x 8 x f64
199 
202 
205 
208 
209  x86mmx = 129, // This is an X86 MMX value
210 
211  Glue = 130, // This glues nodes together during pre-RA sched
212 
213  isVoid = 131, // This has no value
214 
215  Untyped = 132, // This value takes a register, but has
216  // unspecified type. The register class
217  // will be determined by the opcode.
218 
219  exnref = 133, // WebAssembly's exnref type
220 
221  FIRST_VALUETYPE = 1, // This is always the beginning of the list.
222  LAST_VALUETYPE = 134, // This always remains at the end of the list.
223 
224  // This is the current maximum for LAST_VALUETYPE.
225  // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
226  // This value must be a multiple of 32.
228 
229  // A value of type llvm::TokenTy
230  token = 248,
231 
232  // This is MDNode or MDString.
233  Metadata = 249,
234 
235  // An int value the size of the pointer of the current
236  // target to any address space. This must only be used internal to
237  // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
238  iPTRAny = 250,
239 
240  // A vector with any length and element size. This is used
241  // for intrinsics that have overloadings based on vector types.
242  // This is only for tblgen's consumption!
243  vAny = 251,
244 
245  // Any floating-point or vector floating-point value. This is used
246  // for intrinsics that have overloadings based on floating-point types.
247  // This is only for tblgen's consumption!
248  fAny = 252,
249 
250  // An integer or vector integer value of any bit width. This is
251  // used for intrinsics that have overloadings based on integer bit widths.
252  // This is only for tblgen's consumption!
253  iAny = 253,
254 
255  // An int value the size of the pointer of the current
256  // target. This should only be used internal to tblgen!
257  iPTR = 254,
258 
259  // Any type. This is used for intrinsics that have overloadings.
260  // This is only for tblgen's consumption!
261  Any = 255
262  };
263 
265 
266  constexpr MVT() = default;
267  constexpr MVT(SimpleValueType SVT) : SimpleTy(SVT) {}
268 
269  bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; }
270  bool operator<(const MVT& S) const { return SimpleTy < S.SimpleTy; }
271  bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; }
272  bool operator!=(const MVT& S) const { return SimpleTy != S.SimpleTy; }
273  bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
274  bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
275 
276  /// Return true if this is a valid simple valuetype.
277  bool isValid() const {
278  return (SimpleTy >= MVT::FIRST_VALUETYPE &&
279  SimpleTy < MVT::LAST_VALUETYPE);
280  }
281 
282  /// Return true if this is a FP or a vector FP type.
283  bool isFloatingPoint() const {
284  return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
285  SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
290  }
291 
292  /// Return true if this is an integer or a vector integer type.
293  bool isInteger() const {
294  return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
295  SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
300  }
301 
302  /// Return true if this is an integer, not including vectors.
303  bool isScalarInteger() const {
304  return (SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
305  SimpleTy <= MVT::LAST_INTEGER_VALUETYPE);
306  }
307 
308  /// Return true if this is a vector value type.
309  bool isVector() const {
310  return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
311  SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
312  }
313 
314  /// Return true if this is a vector value type where the
315  /// runtime length is machine dependent
316  bool isScalableVector() const {
317  return (SimpleTy >= MVT::FIRST_SCALABLE_VECTOR_VALUETYPE &&
319  }
320 
321  bool isFixedLengthVector() const {
322  return (SimpleTy >= MVT::FIRST_FIXEDLEN_VECTOR_VALUETYPE &&
324  }
325 
326  /// Return true if this is a 16-bit vector type.
327  bool is16BitVector() const {
328  return (SimpleTy == MVT::v2i8 || SimpleTy == MVT::v1i16 ||
329  SimpleTy == MVT::v16i1);
330  }
331 
332  /// Return true if this is a 32-bit vector type.
333  bool is32BitVector() const {
334  return (SimpleTy == MVT::v32i1 || SimpleTy == MVT::v4i8 ||
335  SimpleTy == MVT::v2i16 || SimpleTy == MVT::v1i32 ||
336  SimpleTy == MVT::v2f16 || SimpleTy == MVT::v1f32);
337  }
338 
339  /// Return true if this is a 64-bit vector type.
340  bool is64BitVector() const {
341  return (SimpleTy == MVT::v64i1 || SimpleTy == MVT::v8i8 ||
342  SimpleTy == MVT::v4i16 || SimpleTy == MVT::v2i32 ||
343  SimpleTy == MVT::v1i64 || SimpleTy == MVT::v4f16 ||
344  SimpleTy == MVT::v2f32 || SimpleTy == MVT::v1f64);
345  }
346 
347  /// Return true if this is a 128-bit vector type.
348  bool is128BitVector() const {
349  return (SimpleTy == MVT::v128i1 || SimpleTy == MVT::v16i8 ||
350  SimpleTy == MVT::v8i16 || SimpleTy == MVT::v4i32 ||
351  SimpleTy == MVT::v2i64 || SimpleTy == MVT::v1i128 ||
352  SimpleTy == MVT::v8f16 || SimpleTy == MVT::v4f32 ||
353  SimpleTy == MVT::v2f64);
354  }
355 
356  /// Return true if this is a 256-bit vector type.
357  bool is256BitVector() const {
358  return (SimpleTy == MVT::v16f16 || SimpleTy == MVT::v8f32 ||
359  SimpleTy == MVT::v4f64 || SimpleTy == MVT::v32i8 ||
360  SimpleTy == MVT::v16i16 || SimpleTy == MVT::v8i32 ||
361  SimpleTy == MVT::v4i64);
362  }
363 
364  /// Return true if this is a 512-bit vector type.
365  bool is512BitVector() const {
366  return (SimpleTy == MVT::v32f16 || SimpleTy == MVT::v16f32 ||
367  SimpleTy == MVT::v8f64 || SimpleTy == MVT::v512i1 ||
368  SimpleTy == MVT::v64i8 || SimpleTy == MVT::v32i16 ||
369  SimpleTy == MVT::v16i32 || SimpleTy == MVT::v8i64);
370  }
371 
372  /// Return true if this is a 1024-bit vector type.
373  bool is1024BitVector() const {
374  return (SimpleTy == MVT::v1024i1 || SimpleTy == MVT::v128i8 ||
375  SimpleTy == MVT::v64i16 || SimpleTy == MVT::v32i32 ||
376  SimpleTy == MVT::v16i64);
377  }
378 
379  /// Return true if this is a 2048-bit vector type.
380  bool is2048BitVector() const {
381  return (SimpleTy == MVT::v256i8 || SimpleTy == MVT::v128i16 ||
382  SimpleTy == MVT::v64i32 || SimpleTy == MVT::v32i64);
383  }
384 
385  /// Return true if this is an overloaded type for TableGen.
386  bool isOverloaded() const {
387  return (SimpleTy==MVT::Any ||
388  SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
389  SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
390  }
391 
392  /// Return a VT for a vector type with the same element type but
393  /// half the number of elements.
395  MVT EltVT = getVectorElementType();
396  auto EltCnt = getVectorElementCount();
397  assert(!(EltCnt.Min & 1) && "Splitting vector, but not in half!");
398  return getVectorVT(EltVT, EltCnt / 2);
399  }
400 
401  /// Returns true if the given vector is a power of 2.
402  bool isPow2VectorType() const {
403  unsigned NElts = getVectorNumElements();
404  return !(NElts & (NElts - 1));
405  }
406 
407  /// Widens the length of the given vector MVT up to the nearest power of 2
408  /// and returns that type.
410  if (isPow2VectorType())
411  return *this;
412 
413  unsigned NElts = getVectorNumElements();
414  unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
415  return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
416  }
417 
418  /// If this is a vector, return the element type, otherwise return this.
419  MVT getScalarType() const {
420  return isVector() ? getVectorElementType() : *this;
421  }
422 
424  switch (SimpleTy) {
425  default:
426  llvm_unreachable("Not a vector MVT!");
427  case v1i1:
428  case v2i1:
429  case v4i1:
430  case v8i1:
431  case v16i1:
432  case v32i1:
433  case v64i1:
434  case v128i1:
435  case v512i1:
436  case v1024i1:
437  case nxv1i1:
438  case nxv2i1:
439  case nxv4i1:
440  case nxv8i1:
441  case nxv16i1:
442  case nxv32i1: return i1;
443  case v1i8:
444  case v2i8:
445  case v4i8:
446  case v8i8:
447  case v16i8:
448  case v32i8:
449  case v64i8:
450  case v128i8:
451  case v256i8:
452  case nxv1i8:
453  case nxv2i8:
454  case nxv4i8:
455  case nxv8i8:
456  case nxv16i8:
457  case nxv32i8: return i8;
458  case v1i16:
459  case v2i16:
460  case v3i16:
461  case v4i16:
462  case v8i16:
463  case v16i16:
464  case v32i16:
465  case v64i16:
466  case v128i16:
467  case nxv1i16:
468  case nxv2i16:
469  case nxv4i16:
470  case nxv8i16:
471  case nxv16i16:
472  case nxv32i16: return i16;
473  case v1i32:
474  case v2i32:
475  case v3i32:
476  case v4i32:
477  case v5i32:
478  case v8i32:
479  case v16i32:
480  case v32i32:
481  case v64i32:
482  case v128i32:
483  case v256i32:
484  case v512i32:
485  case v1024i32:
486  case v2048i32:
487  case nxv1i32:
488  case nxv2i32:
489  case nxv4i32:
490  case nxv8i32:
491  case nxv16i32:
492  case nxv32i32: return i32;
493  case v1i64:
494  case v2i64:
495  case v4i64:
496  case v8i64:
497  case v16i64:
498  case v32i64:
499  case nxv1i64:
500  case nxv2i64:
501  case nxv4i64:
502  case nxv8i64:
503  case nxv16i64:
504  case nxv32i64: return i64;
505  case v1i128: return i128;
506  case v2f16:
507  case v3f16:
508  case v4f16:
509  case v8f16:
510  case v16f16:
511  case v32f16:
512  case nxv2f16:
513  case nxv4f16:
514  case nxv8f16: return f16;
515  case v1f32:
516  case v2f32:
517  case v3f32:
518  case v4f32:
519  case v5f32:
520  case v8f32:
521  case v16f32:
522  case v32f32:
523  case v64f32:
524  case v128f32:
525  case v256f32:
526  case v512f32:
527  case v1024f32:
528  case v2048f32:
529  case nxv1f32:
530  case nxv2f32:
531  case nxv4f32:
532  case nxv8f32:
533  case nxv16f32: return f32;
534  case v1f64:
535  case v2f64:
536  case v4f64:
537  case v8f64:
538  case nxv1f64:
539  case nxv2f64:
540  case nxv4f64:
541  case nxv8f64: return f64;
542  }
543  }
544 
545  unsigned getVectorNumElements() const {
546  switch (SimpleTy) {
547  default:
548  llvm_unreachable("Not a vector MVT!");
549  case v2048i32:
550  case v2048f32: return 2048;
551  case v1024i1:
552  case v1024i32:
553  case v1024f32: return 1024;
554  case v512i1:
555  case v512i32:
556  case v512f32: return 512;
557  case v256i8:
558  case v256i32:
559  case v256f32: return 256;
560  case v128i1:
561  case v128i8:
562  case v128i16:
563  case v128i32:
564  case v128f32: return 128;
565  case v64i1:
566  case v64i8:
567  case v64i16:
568  case v64i32:
569  case v64f32: return 64;
570  case v32i1:
571  case v32i8:
572  case v32i16:
573  case v32i32:
574  case v32i64:
575  case v32f16:
576  case v32f32:
577  case nxv32i1:
578  case nxv32i8:
579  case nxv32i16:
580  case nxv32i32:
581  case nxv32i64: return 32;
582  case v16i1:
583  case v16i8:
584  case v16i16:
585  case v16i32:
586  case v16i64:
587  case v16f16:
588  case v16f32:
589  case nxv16i1:
590  case nxv16i8:
591  case nxv16i16:
592  case nxv16i32:
593  case nxv16i64:
594  case nxv16f32: return 16;
595  case v8i1:
596  case v8i8:
597  case v8i16:
598  case v8i32:
599  case v8i64:
600  case v8f16:
601  case v8f32:
602  case v8f64:
603  case nxv8i1:
604  case nxv8i8:
605  case nxv8i16:
606  case nxv8i32:
607  case nxv8i64:
608  case nxv8f16:
609  case nxv8f32:
610  case nxv8f64: return 8;
611  case v5i32:
612  case v5f32: return 5;
613  case v4i1:
614  case v4i8:
615  case v4i16:
616  case v4i32:
617  case v4i64:
618  case v4f16:
619  case v4f32:
620  case v4f64:
621  case nxv4i1:
622  case nxv4i8:
623  case nxv4i16:
624  case nxv4i32:
625  case nxv4i64:
626  case nxv4f16:
627  case nxv4f32:
628  case nxv4f64: return 4;
629  case v3i16:
630  case v3i32:
631  case v3f16:
632  case v3f32: return 3;
633  case v2i1:
634  case v2i8:
635  case v2i16:
636  case v2i32:
637  case v2i64:
638  case v2f16:
639  case v2f32:
640  case v2f64:
641  case nxv2i1:
642  case nxv2i8:
643  case nxv2i16:
644  case nxv2i32:
645  case nxv2i64:
646  case nxv2f16:
647  case nxv2f32:
648  case nxv2f64: return 2;
649  case v1i1:
650  case v1i8:
651  case v1i16:
652  case v1i32:
653  case v1i64:
654  case v1i128:
655  case v1f32:
656  case v1f64:
657  case nxv1i1:
658  case nxv1i8:
659  case nxv1i16:
660  case nxv1i32:
661  case nxv1i64:
662  case nxv1f32:
663  case nxv1f64: return 1;
664  }
665  }
666 
668  return { getVectorNumElements(), isScalableVector() };
669  }
670 
671  unsigned getSizeInBits() const {
672  switch (SimpleTy) {
673  default:
674  llvm_unreachable("getSizeInBits called on extended MVT.");
675  case Other:
676  llvm_unreachable("Value type is non-standard value, Other.");
677  case iPTR:
678  llvm_unreachable("Value type size is target-dependent. Ask TLI.");
679  case iPTRAny:
680  case iAny:
681  case fAny:
682  case vAny:
683  case Any:
684  llvm_unreachable("Value type is overloaded.");
685  case token:
686  llvm_unreachable("Token type is a sentinel that cannot be used "
687  "in codegen and has no size");
688  case Metadata:
689  llvm_unreachable("Value type is metadata.");
690  case i1:
691  case v1i1:
692  case nxv1i1: return 1;
693  case v2i1:
694  case nxv2i1: return 2;
695  case v4i1:
696  case nxv4i1: return 4;
697  case i8 :
698  case v1i8:
699  case v8i1:
700  case nxv1i8:
701  case nxv8i1: return 8;
702  case i16 :
703  case f16:
704  case v16i1:
705  case v2i8:
706  case v1i16:
707  case nxv16i1:
708  case nxv2i8:
709  case nxv1i16: return 16;
710  case f32 :
711  case i32 :
712  case v32i1:
713  case v4i8:
714  case v2i16:
715  case v2f16:
716  case v1f32:
717  case v1i32:
718  case nxv32i1:
719  case nxv4i8:
720  case nxv2i16:
721  case nxv1i32:
722  case nxv2f16:
723  case nxv1f32: return 32;
724  case v3i16:
725  case v3f16: return 48;
726  case x86mmx:
727  case f64 :
728  case i64 :
729  case v64i1:
730  case v8i8:
731  case v4i16:
732  case v2i32:
733  case v1i64:
734  case v4f16:
735  case v2f32:
736  case v1f64:
737  case nxv8i8:
738  case nxv4i16:
739  case nxv2i32:
740  case nxv1i64:
741  case nxv4f16:
742  case nxv2f32:
743  case nxv1f64: return 64;
744  case f80 : return 80;
745  case v3i32:
746  case v3f32: return 96;
747  case f128:
748  case ppcf128:
749  case i128:
750  case v128i1:
751  case v16i8:
752  case v8i16:
753  case v4i32:
754  case v2i64:
755  case v1i128:
756  case v8f16:
757  case v4f32:
758  case v2f64:
759  case nxv16i8:
760  case nxv8i16:
761  case nxv4i32:
762  case nxv2i64:
763  case nxv8f16:
764  case nxv4f32:
765  case nxv2f64: return 128;
766  case v5i32:
767  case v5f32: return 160;
768  case v32i8:
769  case v16i16:
770  case v8i32:
771  case v4i64:
772  case v16f16:
773  case v8f32:
774  case v4f64:
775  case nxv32i8:
776  case nxv16i16:
777  case nxv8i32:
778  case nxv4i64:
779  case nxv8f32:
780  case nxv4f64: return 256;
781  case v512i1:
782  case v64i8:
783  case v32i16:
784  case v16i32:
785  case v8i64:
786  case v32f16:
787  case v16f32:
788  case v8f64:
789  case nxv32i16:
790  case nxv16i32:
791  case nxv8i64:
792  case nxv16f32:
793  case nxv8f64: return 512;
794  case v1024i1:
795  case v128i8:
796  case v64i16:
797  case v32i32:
798  case v16i64:
799  case v32f32:
800  case nxv32i32:
801  case nxv16i64: return 1024;
802  case v256i8:
803  case v128i16:
804  case v64i32:
805  case v32i64:
806  case v64f32:
807  case nxv32i64: return 2048;
808  case v128i32:
809  case v128f32: return 4096;
810  case v256i32:
811  case v256f32: return 8192;
812  case v512i32:
813  case v512f32: return 16384;
814  case v1024i32:
815  case v1024f32: return 32768;
816  case v2048i32:
817  case v2048f32: return 65536;
818  case exnref: return 0; // opaque type
819  }
820  }
821 
822  unsigned getScalarSizeInBits() const {
823  return getScalarType().getSizeInBits();
824  }
825 
826  /// Return the number of bytes overwritten by a store of the specified value
827  /// type.
828  unsigned getStoreSize() const {
829  return (getSizeInBits() + 7) / 8;
830  }
831 
832  /// Return the number of bits overwritten by a store of the specified value
833  /// type.
834  unsigned getStoreSizeInBits() const {
835  return getStoreSize() * 8;
836  }
837 
838  /// Return true if this has more bits than VT.
839  bool bitsGT(MVT VT) const {
840  return getSizeInBits() > VT.getSizeInBits();
841  }
842 
843  /// Return true if this has no less bits than VT.
844  bool bitsGE(MVT VT) const {
845  return getSizeInBits() >= VT.getSizeInBits();
846  }
847 
848  /// Return true if this has less bits than VT.
849  bool bitsLT(MVT VT) const {
850  return getSizeInBits() < VT.getSizeInBits();
851  }
852 
853  /// Return true if this has no more bits than VT.
854  bool bitsLE(MVT VT) const {
855  return getSizeInBits() <= VT.getSizeInBits();
856  }
857 
858  static MVT getFloatingPointVT(unsigned BitWidth) {
859  switch (BitWidth) {
860  default:
861  llvm_unreachable("Bad bit width!");
862  case 16:
863  return MVT::f16;
864  case 32:
865  return MVT::f32;
866  case 64:
867  return MVT::f64;
868  case 80:
869  return MVT::f80;
870  case 128:
871  return MVT::f128;
872  }
873  }
874 
875  static MVT getIntegerVT(unsigned BitWidth) {
876  switch (BitWidth) {
877  default:
879  case 1:
880  return MVT::i1;
881  case 8:
882  return MVT::i8;
883  case 16:
884  return MVT::i16;
885  case 32:
886  return MVT::i32;
887  case 64:
888  return MVT::i64;
889  case 128:
890  return MVT::i128;
891  }
892  }
893 
894  static MVT getVectorVT(MVT VT, unsigned NumElements) {
895  switch (VT.SimpleTy) {
896  default:
897  break;
898  case MVT::i1:
899  if (NumElements == 1) return MVT::v1i1;
900  if (NumElements == 2) return MVT::v2i1;
901  if (NumElements == 4) return MVT::v4i1;
902  if (NumElements == 8) return MVT::v8i1;
903  if (NumElements == 16) return MVT::v16i1;
904  if (NumElements == 32) return MVT::v32i1;
905  if (NumElements == 64) return MVT::v64i1;
906  if (NumElements == 128) return MVT::v128i1;
907  if (NumElements == 512) return MVT::v512i1;
908  if (NumElements == 1024) return MVT::v1024i1;
909  break;
910  case MVT::i8:
911  if (NumElements == 1) return MVT::v1i8;
912  if (NumElements == 2) return MVT::v2i8;
913  if (NumElements == 4) return MVT::v4i8;
914  if (NumElements == 8) return MVT::v8i8;
915  if (NumElements == 16) return MVT::v16i8;
916  if (NumElements == 32) return MVT::v32i8;
917  if (NumElements == 64) return MVT::v64i8;
918  if (NumElements == 128) return MVT::v128i8;
919  if (NumElements == 256) return MVT::v256i8;
920  break;
921  case MVT::i16:
922  if (NumElements == 1) return MVT::v1i16;
923  if (NumElements == 2) return MVT::v2i16;
924  if (NumElements == 3) return MVT::v3i16;
925  if (NumElements == 4) return MVT::v4i16;
926  if (NumElements == 8) return MVT::v8i16;
927  if (NumElements == 16) return MVT::v16i16;
928  if (NumElements == 32) return MVT::v32i16;
929  if (NumElements == 64) return MVT::v64i16;
930  if (NumElements == 128) return MVT::v128i16;
931  break;
932  case MVT::i32:
933  if (NumElements == 1) return MVT::v1i32;
934  if (NumElements == 2) return MVT::v2i32;
935  if (NumElements == 3) return MVT::v3i32;
936  if (NumElements == 4) return MVT::v4i32;
937  if (NumElements == 5) return MVT::v5i32;
938  if (NumElements == 8) return MVT::v8i32;
939  if (NumElements == 16) return MVT::v16i32;
940  if (NumElements == 32) return MVT::v32i32;
941  if (NumElements == 64) return MVT::v64i32;
942  if (NumElements == 128) return MVT::v128i32;
943  if (NumElements == 256) return MVT::v256i32;
944  if (NumElements == 512) return MVT::v512i32;
945  if (NumElements == 1024) return MVT::v1024i32;
946  if (NumElements == 2048) return MVT::v2048i32;
947  break;
948  case MVT::i64:
949  if (NumElements == 1) return MVT::v1i64;
950  if (NumElements == 2) return MVT::v2i64;
951  if (NumElements == 4) return MVT::v4i64;
952  if (NumElements == 8) return MVT::v8i64;
953  if (NumElements == 16) return MVT::v16i64;
954  if (NumElements == 32) return MVT::v32i64;
955  break;
956  case MVT::i128:
957  if (NumElements == 1) return MVT::v1i128;
958  break;
959  case MVT::f16:
960  if (NumElements == 2) return MVT::v2f16;
961  if (NumElements == 3) return MVT::v3f16;
962  if (NumElements == 4) return MVT::v4f16;
963  if (NumElements == 8) return MVT::v8f16;
964  if (NumElements == 16) return MVT::v16f16;
965  if (NumElements == 32) return MVT::v32f16;
966  break;
967  case MVT::f32:
968  if (NumElements == 1) return MVT::v1f32;
969  if (NumElements == 2) return MVT::v2f32;
970  if (NumElements == 3) return MVT::v3f32;
971  if (NumElements == 4) return MVT::v4f32;
972  if (NumElements == 5) return MVT::v5f32;
973  if (NumElements == 8) return MVT::v8f32;
974  if (NumElements == 16) return MVT::v16f32;
975  if (NumElements == 32) return MVT::v32f32;
976  if (NumElements == 64) return MVT::v64f32;
977  if (NumElements == 128) return MVT::v128f32;
978  if (NumElements == 256) return MVT::v256f32;
979  if (NumElements == 512) return MVT::v512f32;
980  if (NumElements == 1024) return MVT::v1024f32;
981  if (NumElements == 2048) return MVT::v2048f32;
982  break;
983  case MVT::f64:
984  if (NumElements == 1) return MVT::v1f64;
985  if (NumElements == 2) return MVT::v2f64;
986  if (NumElements == 4) return MVT::v4f64;
987  if (NumElements == 8) return MVT::v8f64;
988  break;
989  }
991  }
992 
993  static MVT getScalableVectorVT(MVT VT, unsigned NumElements) {
994  switch(VT.SimpleTy) {
995  default:
996  break;
997  case MVT::i1:
998  if (NumElements == 1) return MVT::nxv1i1;
999  if (NumElements == 2) return MVT::nxv2i1;
1000  if (NumElements == 4) return MVT::nxv4i1;
1001  if (NumElements == 8) return MVT::nxv8i1;
1002  if (NumElements == 16) return MVT::nxv16i1;
1003  if (NumElements == 32) return MVT::nxv32i1;
1004  break;
1005  case MVT::i8:
1006  if (NumElements == 1) return MVT::nxv1i8;
1007  if (NumElements == 2) return MVT::nxv2i8;
1008  if (NumElements == 4) return MVT::nxv4i8;
1009  if (NumElements == 8) return MVT::nxv8i8;
1010  if (NumElements == 16) return MVT::nxv16i8;
1011  if (NumElements == 32) return MVT::nxv32i8;
1012  break;
1013  case MVT::i16:
1014  if (NumElements == 1) return MVT::nxv1i16;
1015  if (NumElements == 2) return MVT::nxv2i16;
1016  if (NumElements == 4) return MVT::nxv4i16;
1017  if (NumElements == 8) return MVT::nxv8i16;
1018  if (NumElements == 16) return MVT::nxv16i16;
1019  if (NumElements == 32) return MVT::nxv32i16;
1020  break;
1021  case MVT::i32:
1022  if (NumElements == 1) return MVT::nxv1i32;
1023  if (NumElements == 2) return MVT::nxv2i32;
1024  if (NumElements == 4) return MVT::nxv4i32;
1025  if (NumElements == 8) return MVT::nxv8i32;
1026  if (NumElements == 16) return MVT::nxv16i32;
1027  if (NumElements == 32) return MVT::nxv32i32;
1028  break;
1029  case MVT::i64:
1030  if (NumElements == 1) return MVT::nxv1i64;
1031  if (NumElements == 2) return MVT::nxv2i64;
1032  if (NumElements == 4) return MVT::nxv4i64;
1033  if (NumElements == 8) return MVT::nxv8i64;
1034  if (NumElements == 16) return MVT::nxv16i64;
1035  if (NumElements == 32) return MVT::nxv32i64;
1036  break;
1037  case MVT::f16:
1038  if (NumElements == 2) return MVT::nxv2f16;
1039  if (NumElements == 4) return MVT::nxv4f16;
1040  if (NumElements == 8) return MVT::nxv8f16;
1041  break;
1042  case MVT::f32:
1043  if (NumElements == 1) return MVT::nxv1f32;
1044  if (NumElements == 2) return MVT::nxv2f32;
1045  if (NumElements == 4) return MVT::nxv4f32;
1046  if (NumElements == 8) return MVT::nxv8f32;
1047  if (NumElements == 16) return MVT::nxv16f32;
1048  break;
1049  case MVT::f64:
1050  if (NumElements == 1) return MVT::nxv1f64;
1051  if (NumElements == 2) return MVT::nxv2f64;
1052  if (NumElements == 4) return MVT::nxv4f64;
1053  if (NumElements == 8) return MVT::nxv8f64;
1054  break;
1055  }
1057  }
1058 
1059  static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable) {
1060  if (IsScalable)
1061  return getScalableVectorVT(VT, NumElements);
1062  return getVectorVT(VT, NumElements);
1063  }
1064 
1065  static MVT getVectorVT(MVT VT, ElementCount EC) {
1066  if (EC.Scalable)
1067  return getScalableVectorVT(VT, EC.Min);
1068  return getVectorVT(VT, EC.Min);
1069  }
1070 
1071  /// Return the value type corresponding to the specified type. This returns
1072  /// all pointers as iPTR. If HandleUnknown is true, unknown types are
1073  /// returned as Other, otherwise they are invalid.
1074  static MVT getVT(Type *Ty, bool HandleUnknown = false);
1075 
1076  private:
1077  /// A simple iterator over the MVT::SimpleValueType enum.
1078  struct mvt_iterator {
1079  SimpleValueType VT;
1080 
1081  mvt_iterator(SimpleValueType VT) : VT(VT) {}
1082 
1083  MVT operator*() const { return VT; }
1084  bool operator!=(const mvt_iterator &LHS) const { return VT != LHS.VT; }
1085 
1086  mvt_iterator& operator++() {
1087  VT = (MVT::SimpleValueType)((int)VT + 1);
1088  assert((int)VT <= MVT::MAX_ALLOWED_VALUETYPE &&
1089  "MVT iterator overflowed.");
1090  return *this;
1091  }
1092  };
1093 
1094  /// A range of the MVT::SimpleValueType enum.
1096 
1097  public:
1098  /// SimpleValueType Iteration
1099  /// @{
1102  }
1103 
1107  }
1108 
1112  }
1113 
1117  }
1118 
1120  return mvt_range(
1123  }
1124 
1126  return mvt_range(
1129  }
1130 
1132  return mvt_range(
1135  }
1136 
1138  return mvt_range(
1141  }
1142 
1144  return mvt_range(
1147  }
1148 
1150  return mvt_range(
1153  }
1154  /// @}
1155  };
1156 
1157 } // end namespace llvm
1158 
1159 #endif // LLVM_CODEGEN_MACHINEVALUETYPE_H
static MVT getIntegerVT(unsigned BitWidth)
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:551
bool operator>=(const MVT &S) const
Definition: Any.h:26
bool isInteger() const
Return true if this is an integer or a vector integer type.
ElementCount getVectorElementCount() const
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static MVT getVectorVT(MVT VT, unsigned NumElements)
bool isVector() const
Return true if this is a vector value type.
bool isPow2VectorType() const
Returns true if the given vector is a power of 2.
static mvt_range fp_fixedlen_vector_valuetypes()
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
bool is256BitVector() const
Return true if this is a 256-bit vector type.
bool isFixedLengthVector() const
MVT getPow2VectorType() const
Widens the length of the given vector MVT up to the nearest power of 2 and returns that type...
static MVT getFloatingPointVT(unsigned BitWidth)
unsigned getVectorNumElements() const
unsigned getStoreSizeInBits() const
Return the number of bits overwritten by a store of the specified value type.
bool operator>(const MVT &S) const
bool isValid() const
Return true if this is a valid simple valuetype.
static MVT getScalableVectorVT(MVT VT, unsigned NumElements)
constexpr MVT(SimpleValueType SVT)
MVT getHalfNumVectorElementsVT() const
Return a VT for a vector type with the same element type but half the number of elements.
SimpleValueType SimpleTy
unsigned getStoreSize() const
Return the number of bytes overwritten by a store of the specified value type.
APInt operator*(APInt a, uint64_t RHS)
Definition: APInt.h:2099
bool is64BitVector() const
Return true if this is a 64-bit vector type.
static mvt_range integer_fixedlen_vector_valuetypes()
unsigned getSizeInBits() const
bool is1024BitVector() const
Return true if this is a 1024-bit vector type.
bool operator<=(const MVT &S) const
bool is2048BitVector() const
Return true if this is a 2048-bit vector type.
bool is16BitVector() const
Return true if this is a 16-bit vector type.
bool bitsLT(MVT VT) const
Return true if this has less bits than VT.
bool bitsGT(MVT VT) const
Return true if this has more bits than VT.
MVT getVectorElementType() const
bool isScalableVector() const
Return true if this is a vector value type where the runtime length is machine dependent.
bool is128BitVector() const
Return true if this is a 128-bit vector type.
bool bitsGE(MVT VT) const
Return true if this has no less bits than VT.
bool operator<(const MVT &S) const
Machine Value Type.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
unsigned getScalarSizeInBits() const
bool isScalarInteger() const
Return true if this is an integer, not including vectors.
static mvt_range fp_valuetypes()
bool bitsLE(MVT VT) const
Return true if this has no more bits than VT.
static mvt_range vector_valuetypes()
static MVT getVT(Type *Ty, bool HandleUnknown=false)
Return the value type corresponding to the specified type.
Definition: ValueTypes.cpp:446
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool operator==(const MVT &S) const
static MVT getVectorVT(MVT VT, ElementCount EC)
bool isFloatingPoint() const
Return true if this is a FP or a vector FP type.
static mvt_range integer_scalable_vector_valuetypes()
static mvt_range fp_scalable_vector_valuetypes()
MVT getScalarType() const
If this is a vector, return the element type, otherwise return this.
static mvt_range integer_valuetypes()
A range adaptor for a pair of iterators.
bool operator!=(const MVT &S) const
bool isOverloaded() const
Return true if this is an overloaded type for TableGen.
constexpr MVT()=default
bool is32BitVector() const
Return true if this is a 32-bit vector type.
static mvt_range all_valuetypes()
SimpleValueType Iteration.
static MVT getVectorVT(MVT VT, unsigned NumElements, bool IsScalable)
bool is512BitVector() const
Return true if this is a 512-bit vector type.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static mvt_range fixedlen_vector_valuetypes()
Root of the metadata hierarchy.
Definition: Metadata.h:57
static mvt_range scalable_vector_valuetypes()