source: parabix-LLVM/MachineValueType.h.pytemplate @ 4015

Last change on this file since 4015 was 3906, checked in by linmengl, 5 years ago

add a table of LLVM builtin vector types

File size: 8.7 KB
Line 
1//===- CodeGen/MachineValueType.h - Machine-Level types ---------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the set of machine-level target independent types which
11// legal values in the code generator use.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_MACHINEVALUETYPE_H
16#define LLVM_CODEGEN_MACHINEVALUETYPE_H
17
18#include "llvm/Support/ErrorHandling.h"
19#include "llvm/Support/MathExtras.h"
20
21namespace llvm {
22
23  class Type;
24
25  /// MVT - Machine Value Type. Every type that is supported natively by some
26  /// processor targeted by LLVM occurs here. This means that any legal value
27  /// type can be represented by an MVT.
28  class MVT {
29  public:
30    enum SimpleValueType {
31      // INVALID_SIMPLE_VALUE_TYPE - Simple value types less than zero are
32      // considered extended value types.
33      INVALID_SIMPLE_VALUE_TYPE = -1,
34
35      // If you change this numbering, you must change the values in
36      // ValueTypes.td as well!
37      Other          =   0,   // This is a non-standard value
38${integer_type_lines}
39
40      FIRST_INTEGER_VALUETYPE = ${first_integer_type},
41      LAST_INTEGER_VALUETYPE  = ${last_integer_type},
42
43      f16            =   $f16,   // This is a 16 bit floating point value
44      f32            =   $f32,   // This is a 32 bit floating point value
45      f64            =   $f64,   // This is a 64 bit floating point value
46      f80            =  $f80,   // This is a 80 bit floating point value
47      f128           =  $f128,   // This is a 128 bit floating point value
48      ppcf128        =  $ppcf128,   // This is a PPC 128-bit floating point value
49
50      FIRST_FP_VALUETYPE = f16,
51      LAST_FP_VALUETYPE  = ppcf128,
52
53${integer_vector_type_lines}
54
55      FIRST_INTEGER_VECTOR_VALUETYPE = ${first_integer_vector_type},
56      LAST_INTEGER_VECTOR_VALUETYPE = ${last_integer_vector_type},
57
58${float_vector_type_lines}
59
60      FIRST_FP_VECTOR_VALUETYPE = ${first_float_vector_type},
61      LAST_FP_VECTOR_VALUETYPE = ${last_float_vector_type},
62
63      FIRST_VECTOR_VALUETYPE = ${first_integer_vector_type},
64      LAST_VECTOR_VALUETYPE  = ${last_float_vector_type},
65
66      x86mmx         =  $x86mmx,   // This is an X86 MMX value
67
68      Glue           =  $Glue,   // This glues nodes together during pre-RA sched
69
70      isVoid         =  $isVoid,   // This has no value
71
72      Untyped        =  $Untyped,   // This value takes a register, but has
73            // unspecified type.  The register class
74            // will be determined by the opcode.
75
76      LAST_VALUETYPE =  ${last_value_type},   // This always remains at the end of the list.
77
78      // This is the current maximum for LAST_VALUETYPE.
79      // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
80      // This value must be a multiple of 32.
81      MAX_ALLOWED_VALUETYPE = ${max_value_type},
82
83      // Metadata - This is MDNode or MDString.
84      Metadata       = 250,
85
86      // iPTRAny - An int value the size of the pointer of the current
87      // target to any address space. This must only be used internal to
88      // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
89      iPTRAny        = 251,
90
91      // vAny - A vector with any length and element size. This is used
92      // for intrinsics that have overloadings based on vector types.
93      // This is only for tblgen's consumption!
94      vAny           = 252,
95
96      // fAny - Any floating-point or vector floating-point value. This is used
97      // for intrinsics that have overloadings based on floating-point types.
98      // This is only for tblgen's consumption!
99      fAny           = 253,
100
101      // iAny - An integer or vector integer value of any bit width. This is
102      // used for intrinsics that have overloadings based on integer bit widths.
103      // This is only for tblgen's consumption!
104      iAny           = 254,
105
106      // iPTR - An int value the size of the pointer of the current
107      // target.  This should only be used internal to tblgen!
108      iPTR           = 255
109    };
110
111    SimpleValueType SimpleTy;
112
113    MVT() : SimpleTy((SimpleValueType)(INVALID_SIMPLE_VALUE_TYPE)) {}
114    MVT(SimpleValueType SVT) : SimpleTy(SVT) { }
115
116    bool operator>(const MVT& S)  const { return SimpleTy >  S.SimpleTy; }
117    bool operator<(const MVT& S)  const { return SimpleTy <  S.SimpleTy; }
118    bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; }
119    bool operator!=(const MVT& S) const { return SimpleTy != S.SimpleTy; }
120    bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
121    bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
122
123    /// isFloatingPoint - Return true if this is a FP, or a vector FP type.
124    bool isFloatingPoint() const {
125      return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
126               SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
127              (SimpleTy >= MVT::FIRST_FP_VECTOR_VALUETYPE &&
128               SimpleTy <= MVT::LAST_FP_VECTOR_VALUETYPE));
129    }
130
131    /// isInteger - Return true if this is an integer, or a vector integer type.
132    bool isInteger() const {
133      return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
134               SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
135              (SimpleTy >= MVT::FIRST_INTEGER_VECTOR_VALUETYPE &&
136               SimpleTy <= MVT::LAST_INTEGER_VECTOR_VALUETYPE));
137    }
138
139    /// isVector - Return true if this is a vector value type.
140    bool isVector() const {
141      return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
142              SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
143    }
144
145    /// Parabix helper functions here
146    bool isParabixVector() const {
147      return (SimpleTy == MVT::v32i1 || SimpleTy == MVT::v64i1);
148    }
149
150    bool isParabixValue() const {
151      return ${isParabixValue};
152    }
153
154${isXXXBitFunctions}
155
156    /// isOverloaded - Return true if this is an overloaded type for TableGen.
157    bool isOverloaded() const {
158      return (SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
159              SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
160    }
161
162    /// isPow2VectorType - Returns true if the given vector is a power of 2.
163    bool isPow2VectorType() const {
164      unsigned NElts = getVectorNumElements();
165      return !(NElts & (NElts - 1));
166    }
167
168    /// getPow2VectorType - Widens the length of the given vector MVT up to
169    /// the nearest power of 2 and returns that type.
170    MVT getPow2VectorType() const {
171      if (isPow2VectorType())
172        return *this;
173
174      unsigned NElts = getVectorNumElements();
175      unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
176      return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
177    }
178
179    /// getScalarType - If this is a vector type, return the element type,
180    /// otherwise return this.
181    MVT getScalarType() const {
182      return isVector() ? getVectorElementType() : *this;
183    }
184
185${getVectorElementType}
186
187${getVectorNumElements}
188
189${getSizeInBits}
190
191    unsigned getScalarSizeInBits() const {
192      return getScalarType().getSizeInBits();
193    }
194
195    /// getStoreSize - Return the number of bytes overwritten by a store
196    /// of the specified value type.
197    unsigned getStoreSize() const {
198      return (getSizeInBits() + 7) / 8;
199    }
200
201    /// getStoreSizeInBits - Return the number of bits overwritten by a store
202    /// of the specified value type.
203    unsigned getStoreSizeInBits() const {
204      return getStoreSize() * 8;
205    }
206
207    /// Return true if this has more bits than VT.
208    bool bitsGT(MVT VT) const {
209      return getSizeInBits() > VT.getSizeInBits();
210    }
211
212    /// Return true if this has no less bits than VT.
213    bool bitsGE(MVT VT) const {
214      return getSizeInBits() >= VT.getSizeInBits();
215    }
216
217    /// Return true if this has less bits than VT.
218    bool bitsLT(MVT VT) const {
219      return getSizeInBits() < VT.getSizeInBits();
220    }
221
222    /// Return true if this has no more bits than VT.
223    bool bitsLE(MVT VT) const {
224      return getSizeInBits() <= VT.getSizeInBits();
225    }
226
227
228    static MVT getFloatingPointVT(unsigned BitWidth) {
229      switch (BitWidth) {
230      default:
231        llvm_unreachable("Bad bit width!");
232      case 16:
233        return MVT::f16;
234      case 32:
235        return MVT::f32;
236      case 64:
237        return MVT::f64;
238      case 80:
239        return MVT::f80;
240      case 128:
241        return MVT::f128;
242      }
243    }
244
245${getIntegerVT}
246
247${getVectorVT}
248
249    /// Return the value type corresponding to the specified type.  This returns
250    /// all pointers as iPTR.  If HandleUnknown is true, unknown types are
251    /// returned as Other, otherwise they are invalid.
252    static MVT getVT(Type *Ty, bool HandleUnknown = false);
253
254  };
255
256} // End llvm namespace
257
258#endif
Note: See TracBrowser for help on using the repository browser.