From b6daad1f4dcb021592215a33ee552c42c5aa258e Mon Sep 17 00:00:00 2001 From: Nate Begeman Date: Tue, 12 Jul 2005 03:04:49 +0000 Subject: [PATCH] Clean up and add comments to the newly implemented subtarget code. llvm-svn: 22396 --- llvm/include/llvm/Target/TargetMachine.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h index efeb61d4997b..5376f452f0f3 100644 --- a/llvm/include/llvm/Target/TargetMachine.h +++ b/llvm/include/llvm/Target/TargetMachine.h @@ -64,6 +64,10 @@ protected: // Can only create subclasses... /// TargetMachine(const std::string &name, IntrinsicLowering *IL, const Module &M); + + /// getSubtargetImpl - virtual method implemented by subclasses that returns + /// a reference to that target's TargetSubtarget-derived member variable. + virtual const TargetSubtarget *getSubtargetImpl() const { return 0; } public: virtual ~TargetMachine(); @@ -98,11 +102,14 @@ public: virtual const TargetFrameInfo *getFrameInfo() const { return 0; } const TargetData &getTargetData() const { return DataLayout; } - virtual const TargetSubtarget *getSubtargetImpl() const { return 0; } + /// getSubtarget - This method returns a pointer to the specified type of + /// TargetSubtarget. In debug builds, it verifies that the object being + /// returned is of the correct type. template STC *getSubtarget() const { - assert(getSubtargetImpl() && dynamic_cast(getSubtargetImpl()) && + const TargetSubtarget *TST = getSubtargetImpl(); + assert(getSubtargetImpl() && dynamic_cast(TST) && "Not the right kind of subtarget!"); - return (STC*)getSubtargetImpl(); + return (STC*)TST; } /// getRegisterInfo - If register information is available, return it. If