diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-02-23 18:14:48 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-02-23 18:14:48 +0000 |
commit | af2de4848ee302d18c3894fb12ebcde71752dbdd (patch) | |
tree | 43590363403eb45df671710b2bc40d05c0f6bd3e /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | cb185a34bbed7fbf1fb84c8b00d4a81011363b16 (diff) | |
download | bcm5719-llvm-af2de4848ee302d18c3894fb12ebcde71752dbdd.tar.gz bcm5719-llvm-af2de4848ee302d18c3894fb12ebcde71752dbdd.zip |
Refactor rewinding code for finding the first terminator of a basic
block into MachineBasicBlock::getFirstTerminator().
This also fixes a bug in the implementation of the above in both
RegAllocLocal and InstrSched, where instructions where added after the
terminator if the basic block's only instruction was a terminator (it
shouldn't matter for RegAllocLocal since this case never occurs in
practice).
llvm-svn: 11748
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index 9d65453edff..89763ba4f3b 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -15,6 +15,8 @@ #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetMachine.h" #include "Support/LeakDetector.h" using namespace llvm; @@ -56,6 +58,16 @@ void ilist_traits<MachineInstr>::transferNodesFromList( first->parent = toList.parent; } +MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() +{ + const TargetInstrInfo& TII = MachineFunction::get( + getBasicBlock()->getParent()).getTarget().getInstrInfo(); + iterator I = end(); + while (I != begin() && TII.isTerminatorInstr((--I)->getOpcode())); + if (I != end() && !TII.isTerminatorInstr(I->getOpcode())) ++I; + return I; +} + void MachineBasicBlock::dump() const { print(std::cerr); |