summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2015-01-30 22:02:19 +0000
committerEric Christopher <echristo@gmail.com>2015-01-30 22:02:19 +0000
commit6d9fcc38be459f16ed4da465db0db14db06ecdb7 (patch)
tree266c1e0ccd2ce2649a4b3a08f31771b98343ceba /llvm
parent3fd78353fbeb7d9dbfed80996015a57b54a53c19 (diff)
downloadbcm5719-llvm-6d9fcc38be459f16ed4da465db0db14db06ecdb7.tar.gz
bcm5719-llvm-6d9fcc38be459f16ed4da465db0db14db06ecdb7.zip
Add a similar templated cast for getSubtarget off of the MachineFunction
to save typing a lot of static_casts. llvm-svn: 227621
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/CodeGen/MachineFunction.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index 4e9ff9ebb4f..5d037428942 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -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; }
OpenPOWER on IntegriCloud