[llvm-commits] CVS: llvm/include/llvm/Target/TargetMachine.h
Nate Begeman
natebegeman at mac.com
Mon Jul 11 20:05:00 PDT 2005
Changes in directory llvm/include/llvm/Target:
TargetMachine.h updated: 1.54 -> 1.55
---
Log message:
Clean up and add comments to the newly implemented subtarget code.
---
Diffs of the changes: (+10 -3)
TargetMachine.h | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
Index: llvm/include/llvm/Target/TargetMachine.h
diff -u llvm/include/llvm/Target/TargetMachine.h:1.54 llvm/include/llvm/Target/TargetMachine.h:1.55
--- llvm/include/llvm/Target/TargetMachine.h:1.54 Mon Jul 11 20:41:54 2005
+++ llvm/include/llvm/Target/TargetMachine.h Mon Jul 11 22:04:49 2005
@@ -64,6 +64,10 @@
///
TargetMachine(const std::string &name, IntrinsicLowering *IL,
const Module &M);
+
+ /// getSubtargetImpl - virtual method implemented by subclasses that returns
+ /// a reference to that target's TargetSubtarget-derived member variable.
+ virtual const TargetSubtarget *getSubtargetImpl() const { return 0; }
public:
virtual ~TargetMachine();
@@ -98,11 +102,14 @@
virtual const TargetFrameInfo *getFrameInfo() const { return 0; }
const TargetData &getTargetData() const { return DataLayout; }
- virtual const TargetSubtarget *getSubtargetImpl() const { return 0; }
+ /// getSubtarget - This method returns a pointer to the specified type of
+ /// TargetSubtarget. In debug builds, it verifies that the object being
+ /// returned is of the correct type.
template<typename STC> STC *getSubtarget() const {
- assert(getSubtargetImpl() && dynamic_cast<STC*>(getSubtargetImpl()) &&
+ const TargetSubtarget *TST = getSubtargetImpl();
+ assert(getSubtargetImpl() && dynamic_cast<STC*>(TST) &&
"Not the right kind of subtarget!");
- return (STC*)getSubtargetImpl();
+ return (STC*)TST;
}
/// getRegisterInfo - If register information is available, return it. If
More information about the llvm-commits
mailing list