[llvm-commits] CVS: llvm/lib/VMCore/ValueTypes.cpp
Chris Lattner
sabre at nondot.org
Fri Mar 30 21:03:21 PDT 2007
Changes in directory llvm/lib/VMCore:
ValueTypes.cpp updated: 1.15 -> 1.16
---
Log message:
add a method to turn a type into a VT.
---
Diffs of the changes: (+28 -0)
ValueTypes.cpp | 28 ++++++++++++++++++++++++++++
1 files changed, 28 insertions(+)
Index: llvm/lib/VMCore/ValueTypes.cpp
diff -u llvm/lib/VMCore/ValueTypes.cpp:1.15 llvm/lib/VMCore/ValueTypes.cpp:1.16
--- llvm/lib/VMCore/ValueTypes.cpp:1.15 Sat Mar 24 12:36:26 2007
+++ llvm/lib/VMCore/ValueTypes.cpp Fri Mar 30 23:03:02 2007
@@ -110,3 +110,31 @@
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;
+ }
+}
More information about the llvm-commits
mailing list