diff options
author | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-02-12 02:27:10 +0000 |
---|---|---|
committer | Alkis Evlogimenos <alkis@evlogimenos.com> | 2004-02-12 02:27:10 +0000 |
commit | c0b9dc5be79f009d260edb5cd5e1d8346587aaa2 (patch) | |
tree | f68d35cea961a4c0fdb0c5bd9f943e77c5f34161 /lib/Target/X86/InstSelectSimple.cpp | |
parent | 918cdd420b52a4745ce7d4495759c87fd1b32fd5 (diff) |
Change MachineBasicBlock's vector of MachineInstr pointers into an
ilist of MachineInstr objects. This allows constant time removal and
insertion of MachineInstr instances from anywhere in each
MachineBasicBlock. It also allows for constant time splicing of
MachineInstrs into or out of MachineBasicBlocks.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11340 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/InstSelectSimple.cpp')
-rw-r--r-- | lib/Target/X86/InstSelectSimple.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index af2544f17d..9df7697344 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -37,23 +37,21 @@ using namespace llvm; /// instruction at as well as a basic block. This is the version for when you /// have a destination register in mind. inline static MachineInstrBuilder BMI(MachineBasicBlock *MBB, - MachineBasicBlock::iterator &I, + MachineBasicBlock::iterator I, int Opcode, unsigned NumOperands, unsigned DestReg) { - assert(I >= MBB->begin() && I <= MBB->end() && "Bad iterator!"); MachineInstr *MI = new MachineInstr(Opcode, NumOperands+1, true, true); - I = MBB->insert(I, MI)+1; + MBB->insert(I, MI); return MachineInstrBuilder(MI).addReg(DestReg, MOTy::Def); } /// BMI - A special BuildMI variant that takes an iterator to insert the /// instruction at as well as a basic block. inline static MachineInstrBuilder BMI(MachineBasicBlock *MBB, - MachineBasicBlock::iterator &I, + MachineBasicBlock::iterator I, int Opcode, unsigned NumOperands) { - assert(I >= MBB->begin() && I <= MBB->end() && "Bad iterator!"); MachineInstr *MI = new MachineInstr(Opcode, NumOperands, true, true); - I = MBB->insert(I, MI)+1; + MBB->insert(I, MI); return MachineInstrBuilder(MI); } @@ -541,19 +539,19 @@ void ISel::SelectPHINodes() { MachineBasicBlock *MBB = MBBMap[I]; // Loop over all of the PHI nodes in the LLVM basic block... - unsigned NumPHIs = 0; + MachineInstr* instr = MBB->begin(); for (BasicBlock::const_iterator I = BB->begin(); PHINode *PN = const_cast<PHINode*>(dyn_cast<PHINode>(I)); ++I) { // Create a new machine instr PHI node, and insert it. unsigned PHIReg = getReg(*PN); MachineInstr *PhiMI = BuildMI(X86::PHI, PN->getNumOperands(), PHIReg); - MBB->insert(MBB->begin()+NumPHIs++, PhiMI); + MBB->insert(instr, PhiMI); MachineInstr *LongPhiMI = 0; if (PN->getType() == Type::LongTy || PN->getType() == Type::ULongTy) { LongPhiMI = BuildMI(X86::PHI, PN->getNumOperands(), PHIReg+1); - MBB->insert(MBB->begin()+NumPHIs++, LongPhiMI); + MBB->insert(instr, LongPhiMI); } // PHIValues - Map of blocks to incoming virtual registers. We use this @@ -588,7 +586,7 @@ void ISel::SelectPHINodes() { MachineBasicBlock::iterator PI = PredMBB->begin(); // Skip over any PHI nodes though! - while (PI != PredMBB->end() && (*PI)->getOpcode() == X86::PHI) + while (PI != PredMBB->end() && PI->getOpcode() == X86::PHI) ++PI; ValReg = getReg(Val, PredMBB, PI); |