aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-12-18 17:54:53 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-12-18 17:54:53 +0000
commit422e07b091950e0834c9a50ea124932440106349 (patch)
treea1b3ce82703b24028bd71791b3649207db99583f /llvm/lib/CodeGen/MachineBasicBlock.cpp
parent943f76d1b304f63f35d6ab256cd0ac5ee8a14223 (diff)
downloadllvm-422e07b091950e0834c9a50ea124932440106349.zip
llvm-422e07b091950e0834c9a50ea124932440106349.tar.gz
llvm-422e07b091950e0834c9a50ea124932440106349.tar.bz2
Tighten the insert() API for bundled instructions.
The normal insert() function takes an MBB::iterator position, and inserts a stand-alone MachineInstr as before. The insert() function that takes an MBB::instr_iterator position can insert instructions inside a bundle, and will now update the bundle flags correctly when that happens. When the insert position is between two bundles, it is unclear whether the instruction should be appended to the previous bundle, prepended to the next bundle, or stand on its own. The MBB::insert() function doesn't bundle the instruction in that case, use the MIBundleBuilder class for that. llvm-svn: 170437
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineBasicBlock.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp
index b4ff6b4..027f777 100644
--- a/llvm/lib/CodeGen/MachineBasicBlock.cpp
+++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp
@@ -814,6 +814,18 @@ MachineInstr *MachineBasicBlock::remove_instr(MachineInstr *MI) {
return Insts.remove(MI);
}
+MachineBasicBlock::instr_iterator
+MachineBasicBlock::insert(instr_iterator I, MachineInstr *MI) {
+ assert(!MI->isBundledWithPred() && !MI->isBundledWithSucc() &&
+ "Cannot insert instruction with bundle flags");
+ // Set the bundle flags when inserting inside a bundle.
+ if (I != instr_end() && I->isBundledWithPred()) {
+ MI->setFlag(MachineInstr::BundledPred);
+ MI->setFlag(MachineInstr::BundledSucc);
+ }
+ return Insts.insert(I, MI);
+}
+
void MachineBasicBlock::splice(MachineBasicBlock::iterator where,
MachineBasicBlock *Other,
MachineBasicBlock::iterator From) {