From a60636bffb6b45166c5cb6f0936e92bdcd570649 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 30 Jan 2015 22:02:19 +0000 Subject: [PATCH] Add a similar templated cast for getSubtarget off of the MachineFunction to save typing a lot of static_casts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227621 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineFunction.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 4e9ff9ebb4f..5d037428942 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/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 const STC &getSubtarget() const { + return *static_cast(STI); + } + /// getRegInfo - Return information about the registers currently in use. /// MachineRegisterInfo &getRegInfo() { return *RegInfo; }