[llvm] r227621 - Add a similar templated cast for getSubtarget off of the MachineFunction
Eric Christopher
echristo at gmail.com
Fri Jan 30 14:02:19 PST 2015
Author: echristo
Date: Fri Jan 30 16:02:19 2015
New Revision: 227621
URL: http://llvm.org/viewvc/llvm-project?rev=227621&view=rev
Log:
Add a similar templated cast for getSubtarget off of the MachineFunction
to save typing a lot of static_casts.
Modified:
llvm/trunk/include/llvm/CodeGen/MachineFunction.h
Modified: llvm/trunk/include/llvm/CodeGen/MachineFunction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFunction.h?rev=227621&r1=227620&r2=227621&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineFunction.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h Fri Jan 30 16:02:19 2015
@@ -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; }
More information about the llvm-commits
mailing list