#include <cassert>
#include <string>
-#include "llvm/System/DataTypes.h"
+#include "llvm/Support/DataTypes.h"
#include "llvm/Support/MathExtras.h"
namespace llvm {
class LLVMContext;
struct EVT;
- class MVT { // MVT = Machine Value Type
+ /// MVT - Machine Value Type. Every type that is supported natively by some
+ /// processor targeted by LLVM occurs here. This means that any legal value
+ /// type can be represented by a MVT.
+ class MVT {
public:
enum SimpleValueType {
// If you change this numbering, you must change the values in
v2i8 = 12, // 2 x i8
v4i8 = 13, // 4 x i8
- v8i8 = 14, // 8 x i8 - MMX type
+ v8i8 = 14, // 8 x i8
v16i8 = 15, // 16 x i8
v32i8 = 16, // 32 x i8
v2i16 = 17, // 2 x i16
- v4i16 = 18, // 4 x i16 - MMX type
+ v4i16 = 18, // 4 x i16
v8i16 = 19, // 8 x i16
v16i16 = 20, // 16 x i16
- v2i32 = 21, // 2 x i32 - MMX type
+ v2i32 = 21, // 2 x i32
v4i32 = 22, // 4 x i32
v8i32 = 23, // 8 x i32
- v1i64 = 24, // 1 x i64 - MMX type
+ v1i64 = 24, // 1 x i64
v2i64 = 25, // 2 x i64
v4i64 = 26, // 4 x i64
v8i64 = 27, // 8 x i64
LAST_VALUETYPE = 36, // This always remains at the end of the list.
// This is the current maximum for LAST_VALUETYPE.
- // EVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
+ // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors
// This value must be a multiple of 32.
MAX_ALLOWED_VALUETYPE = 64,
MVT() : SimpleTy((SimpleValueType)(INVALID_SIMPLE_VALUE_TYPE)) {}
MVT(SimpleValueType SVT) : SimpleTy(SVT) { }
-
+
bool operator>(const MVT& S) const { return SimpleTy > S.SimpleTy; }
bool operator<(const MVT& S) const { return SimpleTy < S.SimpleTy; }
bool operator==(const MVT& S) const { return SimpleTy == S.SimpleTy; }
+ bool operator!=(const MVT& S) const { return SimpleTy != S.SimpleTy; }
bool operator>=(const MVT& S) const { return SimpleTy >= S.SimpleTy; }
bool operator<=(const MVT& S) const { return SimpleTy <= S.SimpleTy; }
-
+
/// isFloatingPoint - Return true if this is a FP, or a vector FP type.
bool isFloatingPoint() const {
return ((SimpleTy >= MVT::f32 && SimpleTy <= MVT::ppcf128) ||
return (SimpleTy >= MVT::FIRST_VECTOR_VALUETYPE &&
SimpleTy <= MVT::LAST_VECTOR_VALUETYPE);
}
-
+
/// isPow2VectorType - Returns true if the given vector is a power of 2.
bool isPow2VectorType() const {
unsigned NElts = getVectorNumElements();
return !(NElts & (NElts - 1));
}
- /// getPow2VectorType - Widens the length of the given vector EVT up to
+ /// getPow2VectorType - Widens the length of the given vector MVT up to
/// the nearest power of 2 and returns that type.
MVT getPow2VectorType() const {
if (isPow2VectorType())
MVT getScalarType() const {
return isVector() ? getVectorElementType() : *this;
}
-
+
MVT getVectorElementType() const {
switch (SimpleTy) {
default:
case v4f64: return f64;
}
}
-
+
unsigned getVectorNumElements() const {
switch (SimpleTy) {
default:
case v1i64: return 1;
}
}
-
+
unsigned getSizeInBits() const {
switch (SimpleTy) {
case iPTR:
case v8i64: return 512;
}
}
-
+
+ /// getStoreSize - Return the number of bytes overwritten by a store
+ /// of the specified value type.
+ unsigned getStoreSize() const {
+ return (getSizeInBits() + 7) / 8;
+ }
+
+ /// getStoreSizeInBits - Return the number of bits overwritten by a store
+ /// of the specified value type.
+ unsigned getStoreSizeInBits() const {
+ return getStoreSize() * 8;
+ }
+
static MVT getFloatingPointVT(unsigned BitWidth) {
switch (BitWidth) {
default:
return MVT::f128;
}
}
-
+
static MVT getIntegerVT(unsigned BitWidth) {
switch (BitWidth) {
default:
return MVT::i128;
}
}
-
+
static MVT getVectorVT(MVT VT, unsigned NumElements) {
switch (VT.SimpleTy) {
default:
}
};
- struct EVT { // EVT = Extended Value Type
+
+ /// EVT - Extended Value Type. Capable of holding value types which are not
+ /// native for any processor (such as the i12345 type), as well as the types
+ /// a MVT can represent.
+ struct EVT {
private:
MVT V;
const Type *LLVMTy;
EVT getScalarType() const {
return isVector() ? getVectorElementType() : *this;
}
-
+
/// getVectorElementType - Given a vector type, return the type of
/// each element.
EVT getVectorElementType() const {