add a way to make this less brittle
authorChris Lattner <sabre@nondot.org>
Sat, 28 Apr 2007 05:38:52 +0000 (05:38 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 28 Apr 2007 05:38:52 +0000 (05:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36528 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/ValueTypes.h
lib/VMCore/ValueTypes.cpp

index be16aa0c60ced2740f8fbf69d39bfaf867d5ea0b..6f864d79146ff5f92ebddfed00c941e6a97bb5e9 100644 (file)
@@ -205,8 +205,9 @@ namespace MVT {  // MVT = Machine Value Types
   
   /// MVT::getValueType - Return the value type corresponding to the specified
   /// type.  This returns all vectors as MVT::Vector and all pointers as
-  /// MVT::iPTR.
-  ValueType getValueType(const Type *Ty);
+  /// MVT::iPTR.  If HandleUnknown is true, unknown types are returned as Other,
+  /// otherwise they are invalid.
+  ValueType getValueType(const Type *Ty, bool HandleUnknown = false);
 }
 
 } // End llvm namespace
index ccbd29771de380e04e4b803de99a619d40642b51..52d8549201da260c7ca33ae0631bd641cde25376 100644 (file)
@@ -113,16 +113,20 @@ const Type *MVT::getTypeForValueType(MVT::ValueType VT) {
 
 /// 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;