mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-30 16:17:05 +00:00 
			
		
		
		
	Switch isa_impl from a function template to a class template with a
static inline member function doit(). This enables the use of partial specialization to override the last stage of the "isa" check. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99898 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -50,9 +50,11 @@ template<typename From> struct simplify_type<const From> { | |||||||
| //  if (isa<Type*>(myVal)) { ... } | //  if (isa<Type*>(myVal)) { ... } | ||||||
| // | // | ||||||
| template <typename To, typename From> | template <typename To, typename From> | ||||||
| inline bool isa_impl(const From &Val) { | struct isa_impl { | ||||||
|  |   static inline bool doit(const From &Val) { | ||||||
|     return To::classof(&Val); |     return To::classof(&Val); | ||||||
|   } |   } | ||||||
|  | }; | ||||||
|  |  | ||||||
| template<typename To, typename From, typename SimpleType> | template<typename To, typename From, typename SimpleType> | ||||||
| struct isa_impl_wrap { | struct isa_impl_wrap { | ||||||
| @@ -68,7 +70,7 @@ template<typename To, typename FromTy> | |||||||
| struct isa_impl_wrap<To, const FromTy, const FromTy> { | struct isa_impl_wrap<To, const FromTy, const FromTy> { | ||||||
|   // When From == SimpleType, we are as simple as we are going to get. |   // When From == SimpleType, we are as simple as we are going to get. | ||||||
|   static bool doit(const FromTy &Val) { |   static bool doit(const FromTy &Val) { | ||||||
|     return isa_impl<To,FromTy>(Val); |     return isa_impl<To,FromTy>::doit(Val); | ||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| @@ -251,10 +253,12 @@ struct foo { | |||||||
|     }*/ |     }*/ | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <> inline bool isa_impl<foo,bar>(const bar &Val) { | template <> struct isa_impl<foo,bar> { | ||||||
|  |   static inline bool doit(const bar &Val) { | ||||||
|     dbgs() << "Classof: " << &Val << "\n"; |     dbgs() << "Classof: " << &Val << "\n"; | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
|  | }; | ||||||
|  |  | ||||||
|  |  | ||||||
| bar *fub(); | bar *fub(); | ||||||
|   | |||||||
| @@ -548,9 +548,11 @@ template <> struct GraphTraits<const Type*> { | |||||||
|   } |   } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| template <> inline bool isa_impl<PointerType, Type>(const Type &Ty) { | template <> struct isa_impl<PointerType, Type> { | ||||||
|  |   static inline bool doit(const Type &Ty) { | ||||||
|     return Ty.getTypeID() == Type::PointerTyID; |     return Ty.getTypeID() == Type::PointerTyID; | ||||||
|   } |   } | ||||||
|  | }; | ||||||
|  |  | ||||||
| raw_ostream &operator<<(raw_ostream &OS, const Type &T); | raw_ostream &operator<<(raw_ostream &OS, const Type &T); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -324,39 +324,67 @@ void Use::set(Value *V) { | |||||||
| // isa - Provide some specializations of isa so that we don't have to include | // isa - Provide some specializations of isa so that we don't have to include | ||||||
| // the subtype header files to test to see if the value is a subclass... | // the subtype header files to test to see if the value is a subclass... | ||||||
| // | // | ||||||
| template <> inline bool isa_impl<Constant, Value>(const Value &Val) { | template <> struct isa_impl<Constant, Value> { | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return Val.getValueID() >= Value::ConstantFirstVal && |     return Val.getValueID() >= Value::ConstantFirstVal && | ||||||
|       Val.getValueID() <= Value::ConstantLastVal; |       Val.getValueID() <= Value::ConstantLastVal; | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<Argument, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<Argument, Value> { | ||||||
|  |   static inline bool doit (const Value &Val) { | ||||||
|     return Val.getValueID() == Value::ArgumentVal; |     return Val.getValueID() == Value::ArgumentVal; | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<InlineAsm, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<InlineAsm, Value> {  | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return Val.getValueID() == Value::InlineAsmVal; |     return Val.getValueID() == Value::InlineAsmVal; | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<Instruction, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<Instruction, Value> {  | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return Val.getValueID() >= Value::InstructionVal; |     return Val.getValueID() >= Value::InstructionVal; | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<BasicBlock, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<BasicBlock, Value> {  | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return Val.getValueID() == Value::BasicBlockVal; |     return Val.getValueID() == Value::BasicBlockVal; | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<Function, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<Function, Value> {  | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return Val.getValueID() == Value::FunctionVal; |     return Val.getValueID() == Value::FunctionVal; | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<GlobalVariable, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<GlobalVariable, Value> {  | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return Val.getValueID() == Value::GlobalVariableVal; |     return Val.getValueID() == Value::GlobalVariableVal; | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<GlobalAlias, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<GlobalAlias, Value> {  | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return Val.getValueID() == Value::GlobalAliasVal; |     return Val.getValueID() == Value::GlobalAliasVal; | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<GlobalValue, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<GlobalValue, Value> {  | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return isa<GlobalVariable>(Val) || isa<Function>(Val) || |     return isa<GlobalVariable>(Val) || isa<Function>(Val) || | ||||||
|       isa<GlobalAlias>(Val); |       isa<GlobalAlias>(Val); | ||||||
|   } |   } | ||||||
| template <> inline bool isa_impl<MDNode, Value>(const Value &Val) { | }; | ||||||
|  |  | ||||||
|  | template <> struct isa_impl<MDNode, Value> {  | ||||||
|  |   static inline bool doit(const Value &Val) { | ||||||
|     return Val.getValueID() == Value::MDNodeVal; |     return Val.getValueID() == Value::MDNodeVal; | ||||||
|   } |   } | ||||||
|    | }; | ||||||
|    |    | ||||||
| // Value* is only 4-byte aligned. | // Value* is only 4-byte aligned. | ||||||
| template<> | template<> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user