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