~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/CodeGen/ValueTypes.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//===- CodeGen/ValueTypes.h - Low-Level Target independ. 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 low-level target independent types which various
 
11
// values in the code generator are.  This allows the target specific behavior
 
12
// of instructions to be described to target independent passes.
 
13
//
 
14
//===----------------------------------------------------------------------===//
 
15
 
 
16
#ifndef LLVM_CODEGEN_VALUETYPES_H
 
17
#define LLVM_CODEGEN_VALUETYPES_H
 
18
 
 
19
#include <cassert>
 
20
#include <string>
 
21
#include "llvm/System/DataTypes.h"
 
22
#include "llvm/Support/MathExtras.h"
 
23
 
 
24
namespace llvm {
 
25
  class Type;
 
26
  class LLVMContext;
 
27
  struct EVT;
 
28
 
 
29
  class MVT { // MVT = Machine Value Type
 
30
  public:
 
31
    enum SimpleValueType {
 
32
      // If you change this numbering, you must change the values in
 
33
      // ValueTypes.td as well!
 
34
      Other          =   0,   // This is a non-standard value
 
35
      i1             =   1,   // This is a 1 bit integer value
 
36
      i8             =   2,   // This is an 8 bit integer value
 
37
      i16            =   3,   // This is a 16 bit integer value
 
38
      i32            =   4,   // This is a 32 bit integer value
 
39
      i64            =   5,   // This is a 64 bit integer value
 
40
      i128           =   6,   // This is a 128 bit integer value
 
41
 
 
42
      FIRST_INTEGER_VALUETYPE = i1,
 
43
      LAST_INTEGER_VALUETYPE  = i128,
 
44
 
 
45
      f32            =   7,   // This is a 32 bit floating point value
 
46
      f64            =   8,   // This is a 64 bit floating point value
 
47
      f80            =   9,   // This is a 80 bit floating point value
 
48
      f128           =  10,   // This is a 128 bit floating point value
 
49
      ppcf128        =  11,   // This is a PPC 128-bit floating point value
 
50
 
 
51
      v2i8           =  12,   //  2 x i8
 
52
      v4i8           =  13,   //  4 x i8
 
53
      v8i8           =  14,   //  8 x i8
 
54
      v16i8          =  15,   // 16 x i8
 
55
      v32i8          =  16,   // 32 x i8
 
56
      v2i16          =  17,   //  2 x i16
 
57
      v4i16          =  18,   //  4 x i16
 
58
      v8i16          =  19,   //  8 x i16
 
59
      v16i16         =  20,   // 16 x i16
 
60
      v2i32          =  21,   //  2 x i32
 
61
      v4i32          =  22,   //  4 x i32
 
62
      v8i32          =  23,   //  8 x i32
 
63
      v1i64          =  24,   //  1 x i64
 
64
      v2i64          =  25,   //  2 x i64
 
65
      v4i64          =  26,   //  4 x i64
 
66
 
 
67
      v2f32          =  27,   //  2 x f32
 
68
      v4f32          =  28,   //  4 x f32
 
69
      v8f32          =  29,   //  8 x f32
 
70
      v2f64          =  30,   //  2 x f64
 
71
      v4f64          =  31,   //  4 x f64
 
72
 
 
73
      FIRST_VECTOR_VALUETYPE = v2i8,
 
74
      LAST_VECTOR_VALUETYPE  = v4f64,
 
75
 
 
76
      Flag           =  32,   // This glues nodes together during pre-RA sched
 
77
 
 
78
      isVoid         =  33,   // This has no value
 
79
 
 
80
      LAST_VALUETYPE =  34,   // This always remains at the end of the list.
 
81
 
 
82
      // This is the current maximum for LAST_VALUETYPE.
 
83
      // EVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
 
84
      // This value must be a multiple of 32.
 
85
      MAX_ALLOWED_VALUETYPE = 64,
 
86
 
 
87
      // Metadata - This is MDNode or MDString.
 
88
      Metadata       = 250,
 
89
 
 
90
      // iPTRAny - An int value the size of the pointer of the current
 
91
      // target to any address space. This must only be used internal to
 
92
      // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
 
93
      iPTRAny        = 251,
 
94
 
 
95
      // vAny - A vector with any length and element size. This is used
 
96
      // for intrinsics that have overloadings based on vector types.
 
97
      // This is only for tblgen's consumption!
 
98
      vAny           = 252,
 
99
 
 
100
      // fAny - Any floating-point or vector floating-point value. This is used
 
101
      // for intrinsics that have overloadings based on floating-point types.
 
102
      // This is only for tblgen's consumption!
 
103
      fAny           = 253,
 
104
 
 
105
      // iAny - An integer or vector integer value of any bit width. This is
 
106
      // used for intrinsics that have overloadings based on integer bit widths.
 
107
      // This is only for tblgen's consumption!
 
108
      iAny           = 254,
 
109
 
 
110
      // iPTR - An int value the size of the pointer of the current
 
111
      // target.  This should only be used internal to tblgen!
 
112
      iPTR           = 255,
 
113
 
 
114
      // LastSimpleValueType - The greatest valid SimpleValueType value.
 
115
      LastSimpleValueType = 255,
 
116
 
 
117
      // INVALID_SIMPLE_VALUE_TYPE - Simple value types greater than or equal
 
118
      // to this are considered extended value types.
 
119
      INVALID_SIMPLE_VALUE_TYPE = LastSimpleValueType + 1
 
120
    };
 
121
 
 
122
    SimpleValueType SimpleTy;
 
123
 
 
124
    MVT() : SimpleTy((SimpleValueType)(INVALID_SIMPLE_VALUE_TYPE)) {}
 
125
    MVT(SimpleValueType SVT) : SimpleTy(SVT) { }
 
126
    
 
127
    bool operator>(const MVT& S)  const { return SimpleTy >  S.SimpleTy; }
 
128
    bool operator<(const MVT& S)  const { return SimpleTy <  S.SimpleTy; }
 
129
    bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; }
 
130
    bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
 
131
    bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
 
132
    
 
133
    /// isFloatingPoint - Return true if this is a FP, or a vector FP type.
 
134
    bool isFloatingPoint() const {
 
135
      return ((SimpleTy >= MVT::f32 && SimpleTy <= MVT::ppcf128) ||
 
136
        (SimpleTy >= MVT::v2f32 && SimpleTy <= MVT::v4f64));
 
137
    }
 
138
 
 
139
    /// isInteger - Return true if this is an integer, or a vector integer type.
 
140
    bool isInteger() const {
 
141
      return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
 
142
               SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
 
143
               (SimpleTy >= MVT::v2i8 && SimpleTy <= MVT::v4i64));
 
144
    }
 
145
 
 
146
    /// isVector - Return true if this is a vector value type.
 
147
    bool isVector() const {
 
148
      return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
 
149
              SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
 
150
    }
 
151
    
 
152
    /// isPow2VectorType - Returns true if the given vector is a power of 2.
 
153
    bool isPow2VectorType() const {
 
154
      unsigned NElts = getVectorNumElements();
 
155
      return !(NElts & (NElts - 1));
 
156
    }
 
157
 
 
158
    /// getPow2VectorType - Widens the length of the given vector EVT up to
 
159
    /// the nearest power of 2 and returns that type.
 
160
    MVT getPow2VectorType() const {
 
161
      if (!isPow2VectorType()) {
 
162
        unsigned NElts = getVectorNumElements();
 
163
        unsigned Pow2NElts = 1 <<  Log2_32_Ceil(NElts);
 
164
        return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
 
165
      }
 
166
      else {
 
167
        return *this;
 
168
      }
 
169
    }
 
170
 
 
171
    /// getScalarType - If this is a vector type, return the element type,
 
172
    /// otherwise return this.
 
173
    MVT getScalarType() const {
 
174
      return isVector() ? getVectorElementType() : *this;
 
175
    }
 
176
    
 
177
    MVT getVectorElementType() const {
 
178
      switch (SimpleTy) {
 
179
      default:
 
180
        return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
 
181
      case v2i8 :
 
182
      case v4i8 :
 
183
      case v8i8 :
 
184
      case v16i8:
 
185
      case v32i8: return i8;
 
186
      case v2i16:
 
187
      case v4i16:
 
188
      case v8i16:
 
189
      case v16i16: return i16;
 
190
      case v2i32:
 
191
      case v4i32:
 
192
      case v8i32: return i32;
 
193
      case v1i64:
 
194
      case v2i64:
 
195
      case v4i64: return i64;
 
196
      case v2f32:
 
197
      case v4f32:
 
198
      case v8f32: return f32;
 
199
      case v2f64:
 
200
      case v4f64: return f64;
 
201
      }
 
202
    }
 
203
    
 
204
    unsigned getVectorNumElements() const {
 
205
      switch (SimpleTy) {
 
206
      default:
 
207
        return ~0U;
 
208
      case v32i8: return 32;
 
209
      case v16i8:
 
210
      case v16i16: return 16;
 
211
      case v8i8 :
 
212
      case v8i16:
 
213
      case v8i32:
 
214
      case v8f32: return 8;
 
215
      case v4i8:
 
216
      case v4i16:
 
217
      case v4i32:
 
218
      case v4i64:
 
219
      case v4f32:
 
220
      case v4f64: return 4;
 
221
      case v2i8:
 
222
      case v2i16:
 
223
      case v2i32:
 
224
      case v2i64:
 
225
      case v2f32:
 
226
      case v2f64: return 2;
 
227
      case v1i64: return 1;
 
228
      }
 
229
    }
 
230
    
 
231
    unsigned getSizeInBits() const {
 
232
      switch (SimpleTy) {
 
233
      case iPTR:
 
234
        assert(0 && "Value type size is target-dependent. Ask TLI.");
 
235
      case iPTRAny:
 
236
      case iAny:
 
237
      case fAny:
 
238
        assert(0 && "Value type is overloaded.");
 
239
      default:
 
240
        assert(0 && "getSizeInBits called on extended MVT.");
 
241
      case i1  :  return 1;
 
242
      case i8  :  return 8;
 
243
      case i16 :
 
244
      case v2i8:  return 16;
 
245
      case f32 :
 
246
      case i32 :
 
247
      case v4i8:
 
248
      case v2i16: return 32;
 
249
      case f64 :
 
250
      case i64 :
 
251
      case v8i8:
 
252
      case v4i16:
 
253
      case v2i32:
 
254
      case v1i64:
 
255
      case v2f32: return 64;
 
256
      case f80 :  return 80;
 
257
      case f128:
 
258
      case ppcf128:
 
259
      case i128:
 
260
      case v16i8:
 
261
      case v8i16:
 
262
      case v4i32:
 
263
      case v2i64:
 
264
      case v4f32:
 
265
      case v2f64: return 128;
 
266
      case v32i8:
 
267
      case v16i16:
 
268
      case v8i32:
 
269
      case v4i64:
 
270
      case v8f32:
 
271
      case v4f64: return 256;
 
272
      }
 
273
    }
 
274
    
 
275
    static MVT getFloatingPointVT(unsigned BitWidth) {
 
276
      switch (BitWidth) {
 
277
      default:
 
278
        assert(false && "Bad bit width!");
 
279
      case 32:
 
280
        return MVT::f32;
 
281
      case 64:
 
282
        return MVT::f64;
 
283
      case 80:
 
284
        return MVT::f80;
 
285
      case 128:
 
286
        return MVT::f128;
 
287
      }
 
288
    }
 
289
    
 
290
    static MVT getIntegerVT(unsigned BitWidth) {
 
291
      switch (BitWidth) {
 
292
      default:
 
293
        return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
 
294
      case 1:
 
295
        return MVT::i1;
 
296
      case 8:
 
297
        return MVT::i8;
 
298
      case 16:
 
299
        return MVT::i16;
 
300
      case 32:
 
301
        return MVT::i32;
 
302
      case 64:
 
303
        return MVT::i64;
 
304
      case 128:
 
305
        return MVT::i128;
 
306
      }
 
307
    }
 
308
    
 
309
    static MVT getVectorVT(MVT VT, unsigned NumElements) {
 
310
      switch (VT.SimpleTy) {
 
311
      default:
 
312
        break;
 
313
      case MVT::i8:
 
314
        if (NumElements == 2)  return MVT::v2i8;
 
315
        if (NumElements == 4)  return MVT::v4i8;
 
316
        if (NumElements == 8)  return MVT::v8i8;
 
317
        if (NumElements == 16) return MVT::v16i8;
 
318
        if (NumElements == 32) return MVT::v32i8;
 
319
        break;
 
320
      case MVT::i16:
 
321
        if (NumElements == 2)  return MVT::v2i16;
 
322
        if (NumElements == 4)  return MVT::v4i16;
 
323
        if (NumElements == 8)  return MVT::v8i16;
 
324
        if (NumElements == 16) return MVT::v16i16;
 
325
        break;
 
326
      case MVT::i32:
 
327
        if (NumElements == 2)  return MVT::v2i32;
 
328
        if (NumElements == 4)  return MVT::v4i32;
 
329
        if (NumElements == 8)  return MVT::v8i32;
 
330
        break;
 
331
      case MVT::i64:
 
332
        if (NumElements == 1)  return MVT::v1i64;
 
333
        if (NumElements == 2)  return MVT::v2i64;
 
334
        if (NumElements == 4)  return MVT::v4i64;
 
335
        break;
 
336
      case MVT::f32:
 
337
        if (NumElements == 2)  return MVT::v2f32;
 
338
        if (NumElements == 4)  return MVT::v4f32;
 
339
        if (NumElements == 8)  return MVT::v8f32;
 
340
        break;
 
341
      case MVT::f64:
 
342
        if (NumElements == 2)  return MVT::v2f64;
 
343
        if (NumElements == 4)  return MVT::v4f64;
 
344
        break;
 
345
      }
 
346
      return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
 
347
    }
 
348
    
 
349
    static MVT getIntVectorWithNumElements(unsigned NumElts) {
 
350
      switch (NumElts) {
 
351
      default: return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
 
352
      case  1: return MVT::v1i64;
 
353
      case  2: return MVT::v2i32;
 
354
      case  4: return MVT::v4i16;
 
355
      case  8: return MVT::v8i8;
 
356
      case 16: return MVT::v16i8;
 
357
      }
 
358
    }
 
359
  };
 
360
 
 
361
  struct EVT { // EVT = Extended Value Type
 
362
  private:
 
363
    MVT V;
 
364
    const Type *LLVMTy;
 
365
 
 
366
  public:
 
367
    EVT() : V((MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE)),
 
368
            LLVMTy(0) {}
 
369
    EVT(MVT::SimpleValueType SVT) : V(SVT), LLVMTy(0) { }
 
370
    EVT(MVT S) : V(S), LLVMTy(0) {}
 
371
 
 
372
    bool operator==(const EVT VT) const {
 
373
      if (V.SimpleTy == VT.V.SimpleTy) {
 
374
        if (V.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE)
 
375
          return LLVMTy == VT.LLVMTy;
 
376
        return true;
 
377
      }
 
378
      return false;
 
379
    }
 
380
    bool operator!=(const EVT VT) const {
 
381
      if (V.SimpleTy == VT.V.SimpleTy) {
 
382
        if (V.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE)
 
383
          return LLVMTy != VT.LLVMTy;
 
384
        return false;
 
385
      }
 
386
      return true;
 
387
    }
 
388
 
 
389
    /// getFloatingPointVT - Returns the EVT that represents a floating point
 
390
    /// type with the given number of bits.  There are two floating point types
 
391
    /// with 128 bits - this returns f128 rather than ppcf128.
 
392
    static EVT getFloatingPointVT(unsigned BitWidth) {
 
393
      return MVT::getFloatingPointVT(BitWidth);
 
394
    }
 
395
 
 
396
    /// getIntegerVT - Returns the EVT that represents an integer with the given
 
397
    /// number of bits.
 
398
    static EVT getIntegerVT(LLVMContext &Context, unsigned BitWidth) {
 
399
      MVT M = MVT::getIntegerVT(BitWidth);
 
400
      if (M.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE)
 
401
        return getExtendedIntegerVT(Context, BitWidth);
 
402
      else
 
403
        return M;
 
404
    }
 
405
 
 
406
    /// getVectorVT - Returns the EVT that represents a vector NumElements in
 
407
    /// length, where each element is of type VT.
 
408
    static EVT getVectorVT(LLVMContext &Context, EVT VT, unsigned NumElements) {
 
409
      MVT M = MVT::getVectorVT(VT.V, NumElements);
 
410
      if (M.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE)
 
411
        return getExtendedVectorVT(Context, VT, NumElements);
 
412
      else
 
413
        return M;
 
414
    }
 
415
 
 
416
    /// getIntVectorWithNumElements - Return any integer vector type that has
 
417
    /// the specified number of elements.
 
418
    static EVT getIntVectorWithNumElements(LLVMContext &C, unsigned NumElts) {
 
419
      MVT M = MVT::getIntVectorWithNumElements(NumElts);
 
420
      if (M.SimpleTy == MVT::INVALID_SIMPLE_VALUE_TYPE)
 
421
        return getVectorVT(C, MVT::i8, NumElts);
 
422
      else
 
423
        return M;
 
424
    }
 
425
 
 
426
    /// isSimple - Test if the given EVT is simple (as opposed to being
 
427
    /// extended).
 
428
    bool isSimple() const {
 
429
      return V.SimpleTy <= MVT::LastSimpleValueType;
 
430
    }
 
431
 
 
432
    /// isExtended - Test if the given EVT is extended (as opposed to
 
433
    /// being simple).
 
434
    bool isExtended() const {
 
435
      return !isSimple();
 
436
    }
 
437
 
 
438
    /// isFloatingPoint - Return true if this is a FP, or a vector FP type.
 
439
    bool isFloatingPoint() const {
 
440
      return isSimple() ? V.isFloatingPoint() : isExtendedFloatingPoint();
 
441
    }
 
442
 
 
443
    /// isInteger - Return true if this is an integer, or a vector integer type.
 
444
    bool isInteger() const {
 
445
      return isSimple() ? V.isInteger() : isExtendedInteger();
 
446
    }
 
447
 
 
448
    /// isVector - Return true if this is a vector value type.
 
449
    bool isVector() const {
 
450
      return isSimple() ? V.isVector() : isExtendedVector();
 
451
    }
 
452
 
 
453
    /// is64BitVector - Return true if this is a 64-bit vector type.
 
454
    bool is64BitVector() const {
 
455
      return isSimple() ?
 
456
             (V==MVT::v8i8 || V==MVT::v4i16 || V==MVT::v2i32 ||
 
457
              V==MVT::v1i64 || V==MVT::v2f32) :
 
458
             isExtended64BitVector();
 
459
    }
 
460
 
 
461
    /// is128BitVector - Return true if this is a 128-bit vector type.
 
462
    bool is128BitVector() const {
 
463
      return isSimple() ?
 
464
             (V==MVT::v16i8 || V==MVT::v8i16 || V==MVT::v4i32 ||
 
465
              V==MVT::v2i64 || V==MVT::v4f32 || V==MVT::v2f64) :
 
466
             isExtended128BitVector();
 
467
    }
 
468
 
 
469
    /// is256BitVector - Return true if this is a 256-bit vector type.
 
470
    inline bool is256BitVector() const {
 
471
      return isSimple() ?
 
472
             (V==MVT::v8f32 || V==MVT::v4f64 || V==MVT::v32i8 ||
 
473
              V==MVT::v16i16 || V==MVT::v8i32 || V==MVT::v4i64) : 
 
474
            isExtended256BitVector();
 
475
    }
 
476
 
 
477
    /// isOverloaded - Return true if this is an overloaded type for TableGen.
 
478
    bool isOverloaded() const {
 
479
      return (V==MVT::iAny || V==MVT::fAny || V==MVT::vAny || V==MVT::iPTRAny);
 
480
    }
 
481
 
 
482
    /// isByteSized - Return true if the bit size is a multiple of 8.
 
483
    bool isByteSized() const {
 
484
      return (getSizeInBits() & 7) == 0;
 
485
    }
 
486
 
 
487
    /// isRound - Return true if the size is a power-of-two number of bytes.
 
488
    bool isRound() const {
 
489
      unsigned BitSize = getSizeInBits();
 
490
      return BitSize >= 8 && !(BitSize & (BitSize - 1));
 
491
    }
 
492
 
 
493
    /// bitsEq - Return true if this has the same number of bits as VT.
 
494
    bool bitsEq(EVT VT) const {
 
495
      if (EVT::operator==(VT)) return true;
 
496
      return getSizeInBits() == VT.getSizeInBits();
 
497
    }
 
498
 
 
499
    /// bitsGT - Return true if this has more bits than VT.
 
500
    bool bitsGT(EVT VT) const {
 
501
      if (EVT::operator==(VT)) return false;
 
502
      return getSizeInBits() > VT.getSizeInBits();
 
503
    }
 
504
 
 
505
    /// bitsGE - Return true if this has no less bits than VT.
 
506
    bool bitsGE(EVT VT) const {
 
507
      if (EVT::operator==(VT)) return true;
 
508
      return getSizeInBits() >= VT.getSizeInBits();
 
509
    }
 
510
 
 
511
    /// bitsLT - Return true if this has less bits than VT.
 
512
    bool bitsLT(EVT VT) const {
 
513
      if (EVT::operator==(VT)) return false;
 
514
      return getSizeInBits() < VT.getSizeInBits();
 
515
    }
 
516
 
 
517
    /// bitsLE - Return true if this has no more bits than VT.
 
518
    bool bitsLE(EVT VT) const {
 
519
      if (EVT::operator==(VT)) return true;
 
520
      return getSizeInBits() <= VT.getSizeInBits();
 
521
    }
 
522
 
 
523
 
 
524
    /// getSimpleVT - Return the SimpleValueType held in the specified
 
525
    /// simple EVT.
 
526
    MVT getSimpleVT() const {
 
527
      assert(isSimple() && "Expected a SimpleValueType!");
 
528
      return V;
 
529
    }
 
530
 
 
531
    /// getScalarType - If this is a vector type, return the element type,
 
532
    /// otherwise return this.
 
533
    EVT getScalarType() const {
 
534
      return isVector() ? getVectorElementType() : *this;
 
535
    }
 
536
    
 
537
    /// getVectorElementType - Given a vector type, return the type of
 
538
    /// each element.
 
539
    EVT getVectorElementType() const {
 
540
      assert(isVector() && "Invalid vector type!");
 
541
      if (isSimple())
 
542
        return V.getVectorElementType();
 
543
      else
 
544
        return getExtendedVectorElementType();
 
545
    }
 
546
 
 
547
    /// getVectorNumElements - Given a vector type, return the number of
 
548
    /// elements it contains.
 
549
    unsigned getVectorNumElements() const {
 
550
      assert(isVector() && "Invalid vector type!");
 
551
      if (isSimple())
 
552
        return V.getVectorNumElements();
 
553
      else
 
554
        return getExtendedVectorNumElements();
 
555
    }
 
556
 
 
557
    /// getSizeInBits - Return the size of the specified value type in bits.
 
558
    unsigned getSizeInBits() const {
 
559
      if (isSimple())
 
560
        return V.getSizeInBits();
 
561
      else
 
562
        return getExtendedSizeInBits();
 
563
    }
 
564
 
 
565
    /// getStoreSize - Return the number of bytes overwritten by a store
 
566
    /// of the specified value type.
 
567
    unsigned getStoreSize() const {
 
568
      return (getSizeInBits() + 7) / 8;
 
569
    }
 
570
 
 
571
    /// getStoreSizeInBits - Return the number of bits overwritten by a store
 
572
    /// of the specified value type.
 
573
    unsigned getStoreSizeInBits() const {
 
574
      return getStoreSize() * 8;
 
575
    }
 
576
 
 
577
    /// getRoundIntegerType - Rounds the bit-width of the given integer EVT up
 
578
    /// to the nearest power of two (and at least to eight), and returns the
 
579
    /// integer EVT with that number of bits.
 
580
    EVT getRoundIntegerType(LLVMContext &Context) const {
 
581
      assert(isInteger() && !isVector() && "Invalid integer type!");
 
582
      unsigned BitWidth = getSizeInBits();
 
583
      if (BitWidth <= 8)
 
584
        return EVT(MVT::i8);
 
585
      else
 
586
        return getIntegerVT(Context, 1 << Log2_32_Ceil(BitWidth));
 
587
    }
 
588
 
 
589
    /// getHalfSizedIntegerVT - Finds the smallest simple value type that is
 
590
    /// greater than or equal to half the width of this EVT. If no simple
 
591
    /// value type can be found, an extended integer value type of half the
 
592
    /// size (rounded up) is returned.
 
593
    EVT getHalfSizedIntegerVT(LLVMContext &Context) const {
 
594
      assert(isInteger() && !isVector() && "Invalid integer type!");
 
595
      unsigned EVTSize = getSizeInBits();
 
596
      for (unsigned IntVT = MVT::FIRST_INTEGER_VALUETYPE;
 
597
          IntVT <= MVT::LAST_INTEGER_VALUETYPE;
 
598
          ++IntVT) {
 
599
        EVT HalfVT = EVT((MVT::SimpleValueType)IntVT);
 
600
        if(HalfVT.getSizeInBits() * 2 >= EVTSize) { 
 
601
          return HalfVT;
 
602
        }
 
603
      }
 
604
      return getIntegerVT(Context, (EVTSize + 1) / 2);
 
605
    }
 
606
 
 
607
    /// isPow2VectorType - Returns true if the given vector is a power of 2.
 
608
    bool isPow2VectorType() const {
 
609
      unsigned NElts = getVectorNumElements();
 
610
      return !(NElts & (NElts - 1));
 
611
    }
 
612
 
 
613
    /// getPow2VectorType - Widens the length of the given vector EVT up to
 
614
    /// the nearest power of 2 and returns that type.
 
615
    EVT getPow2VectorType(LLVMContext &Context) const {
 
616
      if (!isPow2VectorType()) {
 
617
        unsigned NElts = getVectorNumElements();
 
618
        unsigned Pow2NElts = 1 <<  Log2_32_Ceil(NElts);
 
619
        return EVT::getVectorVT(Context, getVectorElementType(), Pow2NElts);
 
620
      }
 
621
      else {
 
622
        return *this;
 
623
      }
 
624
    }
 
625
 
 
626
    /// getEVTString - This function returns value type as a string,
 
627
    /// e.g. "i32".
 
628
    std::string getEVTString() const;
 
629
 
 
630
    /// getTypeForEVT - This method returns an LLVM type corresponding to the
 
631
    /// specified EVT.  For integer types, this returns an unsigned type.  Note
 
632
    /// that this will abort for types that cannot be represented.
 
633
    const Type *getTypeForEVT(LLVMContext &Context) const;
 
634
 
 
635
    /// getEVT - Return the value type corresponding to the specified type.
 
636
    /// This returns all pointers as iPTR.  If HandleUnknown is true, unknown
 
637
    /// types are returned as Other, otherwise they are invalid.
 
638
    static EVT getEVT(const Type *Ty, bool HandleUnknown = false);
 
639
 
 
640
    intptr_t getRawBits() {
 
641
      if (isSimple())
 
642
        return V.SimpleTy;
 
643
      else
 
644
        return (intptr_t)(LLVMTy);
 
645
    }
 
646
 
 
647
    /// compareRawBits - A meaningless but well-behaved order, useful for
 
648
    /// constructing containers.
 
649
    struct compareRawBits {
 
650
      bool operator()(EVT L, EVT R) const {
 
651
        if (L.V.SimpleTy == R.V.SimpleTy)
 
652
          return L.LLVMTy < R.LLVMTy;
 
653
        else
 
654
          return L.V.SimpleTy < R.V.SimpleTy;
 
655
      }
 
656
    };
 
657
 
 
658
  private:
 
659
    // Methods for handling the Extended-type case in functions above.
 
660
    // These are all out-of-line to prevent users of this header file
 
661
    // from having a dependency on Type.h.
 
662
    static EVT getExtendedIntegerVT(LLVMContext &C, unsigned BitWidth);
 
663
    static EVT getExtendedVectorVT(LLVMContext &C, EVT VT,
 
664
                                   unsigned NumElements);
 
665
    bool isExtendedFloatingPoint() const;
 
666
    bool isExtendedInteger() const;
 
667
    bool isExtendedVector() const;
 
668
    bool isExtended64BitVector() const;
 
669
    bool isExtended128BitVector() const;
 
670
    bool isExtended256BitVector() const;
 
671
    EVT getExtendedVectorElementType() const;
 
672
    unsigned getExtendedVectorNumElements() const;
 
673
    unsigned getExtendedSizeInBits() const;
 
674
  };
 
675
 
 
676
} // End llvm namespace
 
677
 
 
678
#endif