Clean up and add comments to the newly implemented subtarget code.
authorNate Begeman <natebegeman@mac.com>
Tue, 12 Jul 2005 03:04:49 +0000 (03:04 +0000)
committerNate Begeman <natebegeman@mac.com>
Tue, 12 Jul 2005 03:04:49 +0000 (03:04 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22396 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Target/TargetMachine.h

index efeb61d4997b8dc6963727e89e410d5bbc91a931..5376f452f0f38c6e91674e14aecb9fa119092905 100644 (file)
@@ -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<typename STC> STC *getSubtarget() const {
-    assert(getSubtargetImpl() && dynamic_cast<STC*>(getSubtargetImpl()) &&
+    const TargetSubtarget *TST = getSubtargetImpl();
+    assert(getSubtargetImpl() && dynamic_cast<STC*>(TST) &&
            "Not the right kind of subtarget!");
-    return (STC*)getSubtargetImpl();
+    return (STC*)TST;
   }
 
   /// getRegisterInfo - If register information is available, return it.  If