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