#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
FIRST_VECTOR_VALUETYPE = v2i8,
LAST_VECTOR_VALUETYPE = v4f64,
- Flag = 33, // This glues nodes together during pre-RA sched
+ x86mmx = 33, // This is an X86 MMX value
- isVoid = 34, // This has no value
+ Glue = 34, // This glues nodes together during pre-RA sched
- LAST_VALUETYPE = 35, // This always remains at the end of the list.
+ isVoid = 35, // This has no value
+
+ 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 i32 :
case v4i8:
case v2i16: return 32;
+ case x86mmx:
case f64 :
case i64 :
case v8i8:
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 {