diff options
author | Chris Lattner <sabre@nondot.org> | 2007-03-31 04:03:02 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-03-31 04:03:02 +0000 |
commit | 2df6dc579ca7c85a20d2d221f4df32fbb26fc97a (patch) | |
tree | 2f35fdd0229dea1899b4e058d45efaa771a7c042 /lib/VMCore | |
parent | 1c5d163634b772d829ad37961e383d015b75a5ce (diff) | |
download | external_llvm-2df6dc579ca7c85a20d2d221f4df32fbb26fc97a.zip external_llvm-2df6dc579ca7c85a20d2d221f4df32fbb26fc97a.tar.gz external_llvm-2df6dc579ca7c85a20d2d221f4df32fbb26fc97a.tar.bz2 |
add a method to turn a type into a VT.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35526 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/ValueTypes.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/VMCore/ValueTypes.cpp b/lib/VMCore/ValueTypes.cpp index 9fb7655..ccbd297 100644 --- a/lib/VMCore/ValueTypes.cpp +++ b/lib/VMCore/ValueTypes.cpp @@ -110,3 +110,31 @@ const Type *MVT::getTypeForValueType(MVT::ValueType VT) { case MVT::v2f64: return VectorType::get(Type::DoubleTy, 2); } } + +/// MVT::getValueType - Return the value type corresponding to the specified +/// type. This returns all vectors as MVT::Vector and all pointers as +/// MVT::iPTR. +MVT::ValueType MVT::getValueType(const Type *Ty) { + switch (Ty->getTypeID()) { + default: assert(0 && "Unknown type!"); + case Type::VoidTyID: + return MVT::isVoid; + case Type::IntegerTyID: + switch (cast<IntegerType>(Ty)->getBitWidth()) { + default: + // FIXME: Return MVT::iANY. + assert(0 && "Invalid width for value type"); + case 1: return MVT::i1; + case 8: return MVT::i8; + case 16: return MVT::i16; + case 32: return MVT::i32; + case 64: return MVT::i64; + case 128: return MVT::i128; + } + break; + case Type::FloatTyID: return MVT::f32; + case Type::DoubleTyID: return MVT::f64; + case Type::PointerTyID: return MVT::iPTR; + case Type::VectorTyID: return MVT::Vector; + } +} |