summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-03-31 04:03:02 +0000
committerChris Lattner <sabre@nondot.org>2007-03-31 04:03:02 +0000
commit516f38b35f9da5ded1036d8472e33ede2f3e4b13 (patch)
tree0e638f6a417622f1ccf5ea6e0d3e25072f4df55f /llvm/lib
parent82c42284f49de4110255525bee363905f2c20544 (diff)
downloadbcm5719-llvm-516f38b35f9da5ded1036d8472e33ede2f3e4b13.tar.gz
bcm5719-llvm-516f38b35f9da5ded1036d8472e33ede2f3e4b13.zip
add a method to turn a type into a VT.
llvm-svn: 35526
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/VMCore/ValueTypes.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/ValueTypes.cpp b/llvm/lib/VMCore/ValueTypes.cpp
index 9fb76554f7f..ccbd29771de 100644
--- a/llvm/lib/VMCore/ValueTypes.cpp
+++ b/llvm/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;
+ }
+}
OpenPOWER on IntegriCloud