[llvm-commits] CVS: llvm/lib/VMCore/ValueTypes.cpp
Chris Lattner
sabre at nondot.org
Fri Apr 27 22:39:14 PDT 2007
Changes in directory llvm/lib/VMCore:
ValueTypes.cpp updated: 1.16 -> 1.17
---
Log message:
add a way to make this less brittle
---
Diffs of the changes: (+7 -3)
ValueTypes.cpp | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
Index: llvm/lib/VMCore/ValueTypes.cpp
diff -u llvm/lib/VMCore/ValueTypes.cpp:1.16 llvm/lib/VMCore/ValueTypes.cpp:1.17
--- llvm/lib/VMCore/ValueTypes.cpp:1.16 Fri Mar 30 23:03:02 2007
+++ llvm/lib/VMCore/ValueTypes.cpp Sat Apr 28 00:38:52 2007
@@ -113,16 +113,20 @@
/// 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) {
+/// MVT::iPTR. If HandleUnknown is true, unknown types are returned as Other,
+/// otherwise they are invalid.
+MVT::ValueType MVT::getValueType(const Type *Ty, bool HandleUnknown) {
switch (Ty->getTypeID()) {
- default: assert(0 && "Unknown type!");
+ default:
+ if (HandleUnknown) return MVT::Other;
+ assert(0 && "Unknown type!");
case Type::VoidTyID:
return MVT::isVoid;
case Type::IntegerTyID:
switch (cast<IntegerType>(Ty)->getBitWidth()) {
default:
// FIXME: Return MVT::iANY.
+ if (HandleUnknown) return MVT::Other;
assert(0 && "Invalid width for value type");
case 1: return MVT::i1;
case 8: return MVT::i8;
More information about the llvm-commits
mailing list