Add a similar templated cast for getSubtarget off of the MachineFunction
[oota-llvm.git] / include / llvm / CodeGen / MachineFunction.h
index 4e9ff9ebb4fead3136df917bc799b1f8eeb6325d..5d037428942acc06649462784175e717ac701803 100644 (file)
@@ -176,6 +176,13 @@ public:
   const TargetSubtargetInfo &getSubtarget() const { return *STI; }
   void setSubtarget(const TargetSubtargetInfo *ST) { STI = ST; }
 
+  /// getSubtarget - This method returns a pointer to the specified type of
+  /// TargetSubtargetInfo.  In debug builds, it verifies that the object being
+  /// returned is of the correct type.
+  template<typename STC> const STC &getSubtarget() const {
+    return *static_cast<const STC *>(STI);
+  }
+
   /// getRegInfo - Return information about the registers currently in use.
   ///
   MachineRegisterInfo &getRegInfo() { return *RegInfo; }