Add a similar templated cast for getSubtarget off of the MachineFunction

to save typing a lot of static_casts.

llvm-svn: 227621
This commit is contained in:
Eric Christopher 2015-01-30 22:02:19 +00:00
parent 3fd78353fb
commit 6d9fcc38be
1 changed files with 7 additions and 0 deletions

View 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; }