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

Last change on this file since 3848 was 3848, checked in by cameron, 5 years ago

Fixes

File size: 8.5 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 = v2f16,
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${isXXXBitFunctions}
146
147    /// isOverloaded - Return true if this is an overloaded type for TableGen.
148    bool isOverloaded() const {
149      return (SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
150              SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
151    }
152
153    /// isPow2VectorType - Returns true if the given vector is a power of 2.
154    bool isPow2VectorType() const {
155      unsigned NElts = getVectorNumElements();
156      return !(NElts & (NElts - 1));
157    }
158
159    /// getPow2VectorType - Widens the length of the given vector MVT up to
160    /// the nearest power of 2 and returns that type.
161    MVT getPow2VectorType() const {
162      if (isPow2VectorType())
163        return *this;
164
165      unsigned NElts = getVectorNumElements();
166      unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
167      return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
168    }
169
170    /// getScalarType - If this is a vector type, return the element type,
171    /// otherwise return this.
172    MVT getScalarType() const {
173      return isVector() ? getVectorElementType() : *this;
174    }
175
176${getVectorElementType}
177
178${getVectorNumElements}
179
180${getSizeInBits}
181
182    unsigned getScalarSizeInBits() const {
183      return getScalarType().getSizeInBits();
184    }
185
186    /// getStoreSize - Return the number of bytes overwritten by a store
187    /// of the specified value type.
188    unsigned getStoreSize() const {
189      return (getSizeInBits() + 7) / 8;
190    }
191
192    /// getStoreSizeInBits - Return the number of bits overwritten by a store
193    /// of the specified value type.
194    unsigned getStoreSizeInBits() const {
195      return getStoreSize() * 8;
196    }
197
198    /// Return true if this has more bits than VT.
199    bool bitsGT(MVT VT) const {
200      return getSizeInBits() > VT.getSizeInBits();
201    }
202
203    /// Return true if this has no less bits than VT.
204    bool bitsGE(MVT VT) const {
205      return getSizeInBits() >= VT.getSizeInBits();
206    }
207
208    /// Return true if this has less bits than VT.
209    bool bitsLT(MVT VT) const {
210      return getSizeInBits() < VT.getSizeInBits();
211    }
212
213    /// Return true if this has no more bits than VT.
214    bool bitsLE(MVT VT) const {
215      return getSizeInBits() <= VT.getSizeInBits();
216    }
217
218
219    static MVT getFloatingPointVT(unsigned BitWidth) {
220      switch (BitWidth) {
221      default:
222        llvm_unreachable("Bad bit width!");
223      case 16:
224        return MVT::f16;
225      case 32:
226        return MVT::f32;
227      case 64:
228        return MVT::f64;
229      case 80:
230        return MVT::f80;
231      case 128:
232        return MVT::f128;
233      }
234    }
235
236${getIntegerVT}
237
238${getVectorVT}
239
240    /// Return the value type corresponding to the specified type.  This returns
241    /// all pointers as iPTR.  If HandleUnknown is true, unknown types are
242    /// returned as Other, otherwise they are invalid.
243    static MVT getVT(Type *Ty, bool HandleUnknown = false);
244
245  };
246
247} // End llvm namespace
248
249#endif
Note: See TracBrowser for help on using the repository browser.