diff options
author | Chris Lattner <sabre@nondot.org> | 2004-02-19 16:13:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-02-19 16:13:54 +0000 |
commit | d23a882f2f4c16955e5f7e46ec3b4b3a2ea3de0f (patch) | |
tree | 69fe456f978eb298ea0ca0da50c81a190ba5dd0f /llvm | |
parent | 3562c2dd9fd8b82432b6bc682ef92ace785f940f (diff) | |
download | bcm5719-llvm-d23a882f2f4c16955e5f7e46ec3b4b3a2ea3de0f.tar.gz bcm5719-llvm-d23a882f2f4c16955e5f7e46ec3b4b3a2ea3de0f.zip |
Add a MachineBasicBlock::getParent() method
llvm-svn: 11622
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineBasicBlock.h | 10 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 10 |
2 files changed, 14 insertions, 6 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineBasicBlock.h b/llvm/include/llvm/CodeGen/MachineBasicBlock.h index 9399d56b76f..44cab9e9e3f 100644 --- a/llvm/include/llvm/CodeGen/MachineBasicBlock.h +++ b/llvm/include/llvm/CodeGen/MachineBasicBlock.h @@ -19,11 +19,11 @@ #include <iosfwd> namespace llvm { + class MachineFunction; // ilist_traits template <> -class ilist_traits<MachineInstr> -{ +class ilist_traits<MachineInstr> { // this is only set by the MachineBasicBlock owning the ilist friend class MachineBasicBlock; MachineBasicBlock* parent; @@ -70,7 +70,11 @@ public: /// corresponded to originally. /// const BasicBlock *getBasicBlock() const { return BB; } - + + /// getParent - Return the MachineFunction containing this basic block. + /// + const MachineFunction *getParent() const; + typedef ilist<MachineInstr>::iterator iterator; typedef ilist<MachineInstr>::const_iterator const_iterator; typedef std::reverse_iterator<const_iterator> const_reverse_iterator; diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 93606931868..9d65453edff 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -12,15 +12,19 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineBasicBlock.h" - #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "Support/LeakDetector.h" -#include <iostream> - using namespace llvm; +const MachineFunction *MachineBasicBlock::getParent() const { + // Get the parent by getting the Function parent of the basic block, and + // getting the MachineFunction from it. + return &MachineFunction::get(getBasicBlock()->getParent()); +} + + MachineInstr* ilist_traits<MachineInstr>::createNode() { MachineInstr* dummy = new MachineInstr(0, 0); |