llvm.org GIT mirror llvm / bb58b9c
add a way to make this less brittle git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36528 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 13 years ago
2 changed file(s) with 10 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
204204
205205 /// MVT::getValueType - Return the value type corresponding to the specified
206206 /// type. This returns all vectors as MVT::Vector and all pointers as
207 /// MVT::iPTR.
208 ValueType getValueType(const Type *Ty);
207 /// MVT::iPTR. If HandleUnknown is true, unknown types are returned as Other,
208 /// otherwise they are invalid.
209 ValueType getValueType(const Type *Ty, bool HandleUnknown = false);
209210 }
210211
211212 } // End llvm namespace
112112
113113 /// MVT::getValueType - Return the value type corresponding to the specified
114114 /// type. This returns all vectors as MVT::Vector and all pointers as
115 /// MVT::iPTR.
116 MVT::ValueType MVT::getValueType(const Type *Ty) {
115 /// MVT::iPTR. If HandleUnknown is true, unknown types are returned as Other,
116 /// otherwise they are invalid.
117 MVT::ValueType MVT::getValueType(const Type *Ty, bool HandleUnknown) {
117118 switch (Ty->getTypeID()) {
118 default: assert(0 && "Unknown type!");
119 default:
120 if (HandleUnknown) return MVT::Other;
121 assert(0 && "Unknown type!");
119122 case Type::VoidTyID:
120123 return MVT::isVoid;
121124 case Type::IntegerTyID:
122125 switch (cast(Ty)->getBitWidth()) {
123126 default:
124127 // FIXME: Return MVT::iANY.
128 if (HandleUnknown) return MVT::Other;
125129 assert(0 && "Invalid width for value type");
126130 case 1: return MVT::i1;
127131 case 8: return MVT::i8;