MachineValueType.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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. #ifndef LLVM_CODEGEN_MACHINEVALUETYPE_H
  15. #define LLVM_CODEGEN_MACHINEVALUETYPE_H
  16. #include "llvm/ADT/iterator_range.h"
  17. #include "llvm/Support/ErrorHandling.h"
  18. #include "llvm/Support/MathExtras.h"
  19. namespace llvm {
  20. class Type;
  21. /// MVT - Machine Value Type. Every type that is supported natively by some
  22. /// processor targeted by LLVM occurs here. This means that any legal value
  23. /// type can be represented by an MVT.
  24. class MVT {
  25. public:
  26. enum SimpleValueType {
  27. // INVALID_SIMPLE_VALUE_TYPE - Simple value types less than zero are
  28. // considered extended value types.
  29. INVALID_SIMPLE_VALUE_TYPE = -1,
  30. // If you change this numbering, you must change the values in
  31. // ValueTypes.td as well!
  32. Other = 0, // This is a non-standard value
  33. i1 = 1, // This is a 1 bit integer value
  34. i8 = 2, // This is an 8 bit integer value
  35. i16 = 3, // This is a 16 bit integer value
  36. i32 = 4, // This is a 32 bit integer value
  37. i64 = 5, // This is a 64 bit integer value
  38. i128 = 6, // This is a 128 bit integer value
  39. FIRST_INTEGER_VALUETYPE = i1,
  40. LAST_INTEGER_VALUETYPE = i128,
  41. f16 = 7, // This is a 16 bit floating point value
  42. f32 = 8, // This is a 32 bit floating point value
  43. f64 = 9, // This is a 64 bit floating point value
  44. f80 = 10, // This is a 80 bit floating point value
  45. f128 = 11, // This is a 128 bit floating point value
  46. ppcf128 = 12, // This is a PPC 128-bit floating point value
  47. FIRST_FP_VALUETYPE = f16,
  48. LAST_FP_VALUETYPE = ppcf128,
  49. v2i1 = 13, // 2 x i1
  50. v4i1 = 14, // 4 x i1
  51. v8i1 = 15, // 8 x i1
  52. v16i1 = 16, // 16 x i1
  53. v32i1 = 17, // 32 x i1
  54. v64i1 = 18, // 64 x i1
  55. v1i8 = 19, // 1 x i8
  56. v2i8 = 20, // 2 x i8
  57. v4i8 = 21, // 4 x i8
  58. v8i8 = 22, // 8 x i8
  59. v16i8 = 23, // 16 x i8
  60. v32i8 = 24, // 32 x i8
  61. v64i8 = 25, // 64 x i8
  62. v1i16 = 26, // 1 x i16
  63. v2i16 = 27, // 2 x i16
  64. v4i16 = 28, // 4 x i16
  65. v8i16 = 29, // 8 x i16
  66. v16i16 = 30, // 16 x i16
  67. v32i16 = 31, // 32 x i16
  68. v1i32 = 32, // 1 x i32
  69. v2i32 = 33, // 2 x i32
  70. v4i32 = 34, // 4 x i32
  71. v8i32 = 35, // 8 x i32
  72. v16i32 = 36, // 16 x i32
  73. v1i64 = 37, // 1 x i64
  74. v2i64 = 38, // 2 x i64
  75. v4i64 = 39, // 4 x i64
  76. v8i64 = 40, // 8 x i64
  77. v16i64 = 41, // 16 x i64
  78. v1i128 = 42, // 1 x i128
  79. FIRST_INTEGER_VECTOR_VALUETYPE = v2i1,
  80. LAST_INTEGER_VECTOR_VALUETYPE = v1i128,
  81. v2f16 = 43, // 2 x f16
  82. v4f16 = 44, // 4 x f16
  83. v8f16 = 45, // 8 x f16
  84. v1f32 = 46, // 1 x f32
  85. v2f32 = 47, // 2 x f32
  86. v4f32 = 48, // 4 x f32
  87. v8f32 = 49, // 8 x f32
  88. v16f32 = 50, // 16 x f32
  89. v1f64 = 51, // 1 x f64
  90. v2f64 = 52, // 2 x f64
  91. v4f64 = 53, // 4 x f64
  92. v8f64 = 54, // 8 x f64
  93. FIRST_FP_VECTOR_VALUETYPE = v2f16,
  94. LAST_FP_VECTOR_VALUETYPE = v8f64,
  95. FIRST_VECTOR_VALUETYPE = v2i1,
  96. LAST_VECTOR_VALUETYPE = v8f64,
  97. x86mmx = 55, // This is an X86 MMX value
  98. Glue = 56, // This glues nodes together during pre-RA sched
  99. isVoid = 57, // This has no value
  100. Untyped = 58, // This value takes a register, but has
  101. // unspecified type. The register class
  102. // will be determined by the opcode.
  103. FIRST_VALUETYPE = 0, // This is always the beginning of the list.
  104. LAST_VALUETYPE = 59, // This always remains at the end of the list.
  105. // This is the current maximum for LAST_VALUETYPE.
  106. // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
  107. // This value must be a multiple of 32.
  108. MAX_ALLOWED_VALUETYPE = 64,
  109. // Metadata - This is MDNode or MDString.
  110. Metadata = 250,
  111. // iPTRAny - An int value the size of the pointer of the current
  112. // target to any address space. This must only be used internal to
  113. // tblgen. Other than for overloading, we treat iPTRAny the same as iPTR.
  114. iPTRAny = 251,
  115. // vAny - A vector with any length and element size. This is used
  116. // for intrinsics that have overloadings based on vector types.
  117. // This is only for tblgen's consumption!
  118. vAny = 252,
  119. // fAny - Any floating-point or vector floating-point value. This is used
  120. // for intrinsics that have overloadings based on floating-point types.
  121. // This is only for tblgen's consumption!
  122. fAny = 253,
  123. // iAny - An integer or vector integer value of any bit width. This is
  124. // used for intrinsics that have overloadings based on integer bit widths.
  125. // This is only for tblgen's consumption!
  126. iAny = 254,
  127. // iPTR - An int value the size of the pointer of the current
  128. // target. This should only be used internal to tblgen!
  129. iPTR = 255,
  130. // Any - Any type. This is used for intrinsics that have overloadings.
  131. // This is only for tblgen's consumption!
  132. Any = 256
  133. };
  134. SimpleValueType SimpleTy;
  135. LLVM_CONSTEXPR MVT() : SimpleTy(INVALID_SIMPLE_VALUE_TYPE) {}
  136. LLVM_CONSTEXPR MVT(SimpleValueType SVT) : SimpleTy(SVT) { }
  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. /// isValid - Return true if this is a valid simple valuetype.
  144. bool isValid() const {
  145. return (SimpleTy >= MVT::FIRST_VALUETYPE &&
  146. SimpleTy < MVT::LAST_VALUETYPE);
  147. }
  148. /// isFloatingPoint - Return true if this is a FP, or a vector FP type.
  149. bool isFloatingPoint() const {
  150. return ((SimpleTy >= MVT::FIRST_FP_VALUETYPE &&
  151. SimpleTy <= MVT::LAST_FP_VALUETYPE) ||
  152. (SimpleTy >= MVT::FIRST_FP_VECTOR_VALUETYPE &&
  153. SimpleTy <= MVT::LAST_FP_VECTOR_VALUETYPE));
  154. }
  155. /// isInteger - Return true if this is an integer, or a vector integer type.
  156. bool isInteger() const {
  157. return ((SimpleTy >= MVT::FIRST_INTEGER_VALUETYPE &&
  158. SimpleTy <= MVT::LAST_INTEGER_VALUETYPE) ||
  159. (SimpleTy >= MVT::FIRST_INTEGER_VECTOR_VALUETYPE &&
  160. SimpleTy <= MVT::LAST_INTEGER_VECTOR_VALUETYPE));
  161. }
  162. /// isVector - Return true if this is a vector value type.
  163. bool isVector() const {
  164. return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
  165. SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
  166. }
  167. /// is16BitVector - Return true if this is a 16-bit vector type.
  168. bool is16BitVector() const {
  169. return (SimpleTy == MVT::v2i8 || SimpleTy == MVT::v1i16 ||
  170. SimpleTy == MVT::v16i1);
  171. }
  172. /// is32BitVector - Return true if this is a 32-bit vector type.
  173. bool is32BitVector() const {
  174. return (SimpleTy == MVT::v4i8 || SimpleTy == MVT::v2i16 ||
  175. SimpleTy == MVT::v1i32 || SimpleTy == MVT::v2f16 ||
  176. SimpleTy == MVT::v1f32);
  177. }
  178. /// is64BitVector - Return true if this is a 64-bit vector type.
  179. bool is64BitVector() const {
  180. return (SimpleTy == MVT::v8i8 || SimpleTy == MVT::v4i16 ||
  181. SimpleTy == MVT::v2i32 || SimpleTy == MVT::v1i64 ||
  182. SimpleTy == MVT::v4f16 || SimpleTy == MVT::v2f32 ||
  183. SimpleTy == MVT::v1f64);
  184. }
  185. /// is128BitVector - Return true if this is a 128-bit vector type.
  186. bool is128BitVector() const {
  187. return (SimpleTy == MVT::v16i8 || SimpleTy == MVT::v8i16 ||
  188. SimpleTy == MVT::v4i32 || SimpleTy == MVT::v2i64 ||
  189. SimpleTy == MVT::v1i128 || SimpleTy == MVT::v8f16 ||
  190. SimpleTy == MVT::v4f32 || SimpleTy == MVT::v2f64);
  191. }
  192. /// is256BitVector - Return true if this is a 256-bit vector type.
  193. bool is256BitVector() const {
  194. return (SimpleTy == MVT::v8f32 || SimpleTy == MVT::v4f64 ||
  195. SimpleTy == MVT::v32i8 || SimpleTy == MVT::v16i16 ||
  196. SimpleTy == MVT::v8i32 || SimpleTy == MVT::v4i64);
  197. }
  198. /// is512BitVector - Return true if this is a 512-bit vector type.
  199. bool is512BitVector() const {
  200. return (SimpleTy == MVT::v8f64 || SimpleTy == MVT::v16f32 ||
  201. SimpleTy == MVT::v64i8 || SimpleTy == MVT::v32i16 ||
  202. SimpleTy == MVT::v8i64 || SimpleTy == MVT::v16i32);
  203. }
  204. /// is1024BitVector - Return true if this is a 1024-bit vector type.
  205. bool is1024BitVector() const {
  206. return (SimpleTy == MVT::v16i64);
  207. }
  208. /// isOverloaded - Return true if this is an overloaded type for TableGen.
  209. bool isOverloaded() const {
  210. return (SimpleTy==MVT::Any ||
  211. SimpleTy==MVT::iAny || SimpleTy==MVT::fAny ||
  212. SimpleTy==MVT::vAny || SimpleTy==MVT::iPTRAny);
  213. }
  214. /// isPow2VectorType - Returns true if the given vector is a power of 2.
  215. bool isPow2VectorType() const {
  216. unsigned NElts = getVectorNumElements();
  217. return !(NElts & (NElts - 1));
  218. }
  219. /// getPow2VectorType - Widens the length of the given vector MVT up to
  220. /// the nearest power of 2 and returns that type.
  221. MVT getPow2VectorType() const {
  222. if (isPow2VectorType())
  223. return *this;
  224. unsigned NElts = getVectorNumElements();
  225. unsigned Pow2NElts = 1 << Log2_32_Ceil(NElts);
  226. return MVT::getVectorVT(getVectorElementType(), Pow2NElts);
  227. }
  228. /// getScalarType - If this is a vector type, return the element type,
  229. /// otherwise return this.
  230. MVT getScalarType() const {
  231. return isVector() ? getVectorElementType() : *this;
  232. }
  233. MVT getVectorElementType() const {
  234. switch (SimpleTy) {
  235. default:
  236. llvm_unreachable("Not a vector MVT!");
  237. case v2i1 :
  238. case v4i1 :
  239. case v8i1 :
  240. case v16i1 :
  241. case v32i1 :
  242. case v64i1: return i1;
  243. case v1i8 :
  244. case v2i8 :
  245. case v4i8 :
  246. case v8i8 :
  247. case v16i8:
  248. case v32i8:
  249. case v64i8: return i8;
  250. case v1i16:
  251. case v2i16:
  252. case v4i16:
  253. case v8i16:
  254. case v16i16:
  255. case v32i16: return i16;
  256. case v1i32:
  257. case v2i32:
  258. case v4i32:
  259. case v8i32:
  260. case v16i32: return i32;
  261. case v1i64:
  262. case v2i64:
  263. case v4i64:
  264. case v8i64:
  265. case v16i64: return i64;
  266. case v1i128: return i128;
  267. case v2f16:
  268. case v4f16:
  269. case v8f16: return f16;
  270. case v1f32:
  271. case v2f32:
  272. case v4f32:
  273. case v8f32:
  274. case v16f32: return f32;
  275. case v1f64:
  276. case v2f64:
  277. case v4f64:
  278. case v8f64: return f64;
  279. }
  280. }
  281. unsigned getVectorNumElements() const {
  282. switch (SimpleTy) {
  283. default:
  284. llvm_unreachable("Not a vector MVT!");
  285. case v32i1:
  286. case v32i8:
  287. case v32i16: return 32;
  288. case v64i1:
  289. case v64i8: return 64;
  290. case v16i1:
  291. case v16i8:
  292. case v16i16:
  293. case v16i32:
  294. case v16i64:
  295. case v16f32: return 16;
  296. case v8i1 :
  297. case v8i8 :
  298. case v8i16:
  299. case v8i32:
  300. case v8i64:
  301. case v8f16:
  302. case v8f32:
  303. case v8f64: return 8;
  304. case v4i1:
  305. case v4i8:
  306. case v4i16:
  307. case v4i32:
  308. case v4i64:
  309. case v4f16:
  310. case v4f32:
  311. case v4f64: return 4;
  312. case v2i1:
  313. case v2i8:
  314. case v2i16:
  315. case v2i32:
  316. case v2i64:
  317. case v2f16:
  318. case v2f32:
  319. case v2f64: return 2;
  320. case v1i8:
  321. case v1i16:
  322. case v1i32:
  323. case v1i64:
  324. case v1i128:
  325. case v1f32:
  326. case v1f64: return 1;
  327. }
  328. }
  329. unsigned getSizeInBits() const {
  330. switch (SimpleTy) {
  331. default:
  332. llvm_unreachable("getSizeInBits called on extended MVT.");
  333. case Other:
  334. llvm_unreachable("Value type is non-standard value, Other.");
  335. case iPTR:
  336. llvm_unreachable("Value type size is target-dependent. Ask TLI.");
  337. case iPTRAny:
  338. case iAny:
  339. case fAny:
  340. case vAny:
  341. case Any:
  342. llvm_unreachable("Value type is overloaded.");
  343. case Metadata:
  344. llvm_unreachable("Value type is metadata.");
  345. case i1 : return 1;
  346. case v2i1: return 2;
  347. case v4i1: return 4;
  348. case i8 :
  349. case v1i8:
  350. case v8i1: return 8;
  351. case i16 :
  352. case f16:
  353. case v16i1:
  354. case v2i8:
  355. case v1i16: return 16;
  356. case f32 :
  357. case i32 :
  358. case v32i1:
  359. case v4i8:
  360. case v2i16:
  361. case v2f16:
  362. case v1f32:
  363. case v1i32: return 32;
  364. case x86mmx:
  365. case f64 :
  366. case i64 :
  367. case v64i1:
  368. case v8i8:
  369. case v4i16:
  370. case v2i32:
  371. case v1i64:
  372. case v4f16:
  373. case v2f32:
  374. case v1f64: return 64;
  375. case f80 : return 80;
  376. case f128:
  377. case ppcf128:
  378. case i128:
  379. case v16i8:
  380. case v8i16:
  381. case v4i32:
  382. case v2i64:
  383. case v1i128:
  384. case v8f16:
  385. case v4f32:
  386. case v2f64: return 128;
  387. case v32i8:
  388. case v16i16:
  389. case v8i32:
  390. case v4i64:
  391. case v8f32:
  392. case v4f64: return 256;
  393. case v64i8:
  394. case v32i16:
  395. case v16i32:
  396. case v8i64:
  397. case v16f32:
  398. case v8f64: return 512;
  399. case v16i64:return 1024;
  400. }
  401. }
  402. unsigned getScalarSizeInBits() const {
  403. return getScalarType().getSizeInBits();
  404. }
  405. /// getStoreSize - Return the number of bytes overwritten by a store
  406. /// of the specified value type.
  407. unsigned getStoreSize() const {
  408. return (getSizeInBits() + 7) / 8;
  409. }
  410. /// getStoreSizeInBits - Return the number of bits overwritten by a store
  411. /// of the specified value type.
  412. unsigned getStoreSizeInBits() const {
  413. return getStoreSize() * 8;
  414. }
  415. /// Return true if this has more bits than VT.
  416. bool bitsGT(MVT VT) const {
  417. return getSizeInBits() > VT.getSizeInBits();
  418. }
  419. /// Return true if this has no less bits than VT.
  420. bool bitsGE(MVT VT) const {
  421. return getSizeInBits() >= VT.getSizeInBits();
  422. }
  423. /// Return true if this has less bits than VT.
  424. bool bitsLT(MVT VT) const {
  425. return getSizeInBits() < VT.getSizeInBits();
  426. }
  427. /// Return true if this has no more bits than VT.
  428. bool bitsLE(MVT VT) const {
  429. return getSizeInBits() <= VT.getSizeInBits();
  430. }
  431. static MVT getFloatingPointVT(unsigned BitWidth) {
  432. switch (BitWidth) {
  433. default:
  434. llvm_unreachable("Bad bit width!");
  435. case 16:
  436. return MVT::f16;
  437. case 32:
  438. return MVT::f32;
  439. case 64:
  440. return MVT::f64;
  441. case 80:
  442. return MVT::f80;
  443. case 128:
  444. return MVT::f128;
  445. }
  446. }
  447. static MVT getIntegerVT(unsigned BitWidth) {
  448. switch (BitWidth) {
  449. default:
  450. return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
  451. case 1:
  452. return MVT::i1;
  453. case 8:
  454. return MVT::i8;
  455. case 16:
  456. return MVT::i16;
  457. case 32:
  458. return MVT::i32;
  459. case 64:
  460. return MVT::i64;
  461. case 128:
  462. return MVT::i128;
  463. }
  464. }
  465. static MVT getVectorVT(MVT VT, unsigned NumElements) {
  466. switch (VT.SimpleTy) {
  467. default:
  468. break;
  469. case MVT::i1:
  470. if (NumElements == 2) return MVT::v2i1;
  471. if (NumElements == 4) return MVT::v4i1;
  472. if (NumElements == 8) return MVT::v8i1;
  473. if (NumElements == 16) return MVT::v16i1;
  474. if (NumElements == 32) return MVT::v32i1;
  475. if (NumElements == 64) return MVT::v64i1;
  476. break;
  477. case MVT::i8:
  478. if (NumElements == 1) return MVT::v1i8;
  479. if (NumElements == 2) return MVT::v2i8;
  480. if (NumElements == 4) return MVT::v4i8;
  481. if (NumElements == 8) return MVT::v8i8;
  482. if (NumElements == 16) return MVT::v16i8;
  483. if (NumElements == 32) return MVT::v32i8;
  484. if (NumElements == 64) return MVT::v64i8;
  485. break;
  486. case MVT::i16:
  487. if (NumElements == 1) return MVT::v1i16;
  488. if (NumElements == 2) return MVT::v2i16;
  489. if (NumElements == 4) return MVT::v4i16;
  490. if (NumElements == 8) return MVT::v8i16;
  491. if (NumElements == 16) return MVT::v16i16;
  492. if (NumElements == 32) return MVT::v32i16;
  493. break;
  494. case MVT::i32:
  495. if (NumElements == 1) return MVT::v1i32;
  496. if (NumElements == 2) return MVT::v2i32;
  497. if (NumElements == 4) return MVT::v4i32;
  498. if (NumElements == 8) return MVT::v8i32;
  499. if (NumElements == 16) return MVT::v16i32;
  500. break;
  501. case MVT::i64:
  502. if (NumElements == 1) return MVT::v1i64;
  503. if (NumElements == 2) return MVT::v2i64;
  504. if (NumElements == 4) return MVT::v4i64;
  505. if (NumElements == 8) return MVT::v8i64;
  506. if (NumElements == 16) return MVT::v16i64;
  507. break;
  508. case MVT::i128:
  509. if (NumElements == 1) return MVT::v1i128;
  510. break;
  511. case MVT::f16:
  512. if (NumElements == 2) return MVT::v2f16;
  513. if (NumElements == 4) return MVT::v4f16;
  514. if (NumElements == 8) return MVT::v8f16;
  515. break;
  516. case MVT::f32:
  517. if (NumElements == 1) return MVT::v1f32;
  518. if (NumElements == 2) return MVT::v2f32;
  519. if (NumElements == 4) return MVT::v4f32;
  520. if (NumElements == 8) return MVT::v8f32;
  521. if (NumElements == 16) return MVT::v16f32;
  522. break;
  523. case MVT::f64:
  524. if (NumElements == 1) return MVT::v1f64;
  525. if (NumElements == 2) return MVT::v2f64;
  526. if (NumElements == 4) return MVT::v4f64;
  527. if (NumElements == 8) return MVT::v8f64;
  528. break;
  529. }
  530. return (MVT::SimpleValueType)(MVT::INVALID_SIMPLE_VALUE_TYPE);
  531. }
  532. /// Return the value type corresponding to the specified type. This returns
  533. /// all pointers as iPTR. If HandleUnknown is true, unknown types are
  534. /// returned as Other, otherwise they are invalid.
  535. static MVT getVT(Type *Ty, bool HandleUnknown = false);
  536. private:
  537. /// A simple iterator over the MVT::SimpleValueType enum.
  538. struct mvt_iterator {
  539. SimpleValueType VT;
  540. mvt_iterator(SimpleValueType VT) : VT(VT) {}
  541. MVT operator*() const { return VT; }
  542. bool operator!=(const mvt_iterator &LHS) const { return VT != LHS.VT; }
  543. mvt_iterator& operator++() {
  544. VT = (MVT::SimpleValueType)((int)VT + 1);
  545. assert((int)VT <= MVT::MAX_ALLOWED_VALUETYPE &&
  546. "MVT iterator overflowed.");
  547. return *this;
  548. }
  549. };
  550. /// A range of the MVT::SimpleValueType enum.
  551. typedef iterator_range<mvt_iterator> mvt_range;
  552. public:
  553. /// SimpleValueType Iteration
  554. /// @{
  555. static mvt_range all_valuetypes() {
  556. return mvt_range(MVT::FIRST_VALUETYPE, MVT::LAST_VALUETYPE);
  557. }
  558. static mvt_range integer_valuetypes() {
  559. return mvt_range(MVT::FIRST_INTEGER_VALUETYPE,
  560. (MVT::SimpleValueType)(MVT::LAST_INTEGER_VALUETYPE + 1));
  561. }
  562. static mvt_range fp_valuetypes() {
  563. return mvt_range(MVT::FIRST_FP_VALUETYPE,
  564. (MVT::SimpleValueType)(MVT::LAST_FP_VALUETYPE + 1));
  565. }
  566. static mvt_range vector_valuetypes() {
  567. return mvt_range(MVT::FIRST_VECTOR_VALUETYPE,
  568. (MVT::SimpleValueType)(MVT::LAST_VECTOR_VALUETYPE + 1));
  569. }
  570. static mvt_range integer_vector_valuetypes() {
  571. return mvt_range(
  572. MVT::FIRST_INTEGER_VECTOR_VALUETYPE,
  573. (MVT::SimpleValueType)(MVT::LAST_INTEGER_VECTOR_VALUETYPE + 1));
  574. }
  575. static mvt_range fp_vector_valuetypes() {
  576. return mvt_range(
  577. MVT::FIRST_FP_VECTOR_VALUETYPE,
  578. (MVT::SimpleValueType)(MVT::LAST_FP_VECTOR_VALUETYPE + 1));
  579. }
  580. /// @}
  581. };
  582. } // End llvm namespace
  583. #endif