From 9c341366a7e644c9d8333ed84a90aa57516c7ace Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 12 May 2003 03:51:30 +0000 Subject: [PATCH] Expand API for updating live var info. Expose iterators, not const-iterators. Rename method that was VERY misleading git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6108 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveVariables.h | 47 +++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/include/llvm/CodeGen/LiveVariables.h b/include/llvm/CodeGen/LiveVariables.h index 1da673afc06..7b03c31654e 100644 --- a/include/llvm/CodeGen/LiveVariables.h +++ b/include/llvm/CodeGen/LiveVariables.h @@ -72,6 +72,7 @@ class LiveVariables : public MachineFunctionPass { /// liveness for values that are not in this set. /// std::vector AllocatablePhysicalRegisters; + private: // Intermediate data structures /// BBMap - Maps LLVM basic blocks to their corresponding machine basic block. @@ -89,32 +90,62 @@ public: /// killed_iterator - Iterate over registers killed by a machine instruction /// - typedef std::multimap::const_iterator killed_iterator; + typedef std::multimap::iterator killed_iterator; /// killed_begin/end - Get access to the range of registers killed by a /// machine instruction. - killed_iterator killed_begin(MachineInstr *MI) const { + killed_iterator killed_begin(MachineInstr *MI) { return RegistersKilled.lower_bound(MI); } - killed_iterator killed_end(MachineInstr *MI) const { + killed_iterator killed_end(MachineInstr *MI) { return RegistersKilled.upper_bound(MI); } + std::pair + killed_range(MachineInstr *MI) { + return RegistersKilled.equal_range(MI); + } - killed_iterator dead_begin(MachineInstr *MI) const { + killed_iterator dead_begin(MachineInstr *MI) { return RegistersDead.lower_bound(MI); } - killed_iterator dead_end(MachineInstr *MI) const { + killed_iterator dead_end(MachineInstr *MI) { return RegistersDead.upper_bound(MI); } + std::pair + dead_range(MachineInstr *MI) { + return RegistersDead.equal_range(MI); + } - /// addVirtualRegisterKill - Add information about the fact that the specified + //===--------------------------------------------------------------------===// + // API to update live variable information + + /// addVirtualRegisterKilled - Add information about the fact that the + /// specified register is killed after being used by the specified + /// instruction. + /// + void addVirtualRegisterKilled(unsigned IncomingReg, MachineInstr *MI) { + RegistersKilled.insert(std::make_pair(MI, IncomingReg)); + } + + /// removeVirtualRegistersKilled - Remove all of the specified killed + /// registers from the live variable information. + void removeVirtualRegistersKilled(killed_iterator B, killed_iterator E) { + RegistersKilled.erase(B, E); + } + + /// addVirtualRegisterDead - Add information about the fact that the specified /// register is dead after being used by the specified instruction. /// - void addVirtualRegisterKill(unsigned IncomingReg, MachineInstr *MI) { + void addVirtualRegisterDead(unsigned IncomingReg, MachineInstr *MI) { RegistersDead.insert(std::make_pair(MI, IncomingReg)); } + /// removeVirtualRegistersKilled - Remove all of the specified killed + /// registers from the live variable information. + void removeVirtualRegistersDead(killed_iterator B, killed_iterator E) { + RegistersDead.erase(B, E); + } + virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); }