llvm.org GIT mirror llvm / 505e551
Change UsedPhysRegs from array bool to BitVector to save some space. Setting / getting its states now go through MachineFunction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36451 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 13 years ago
2 changed file(s) with 14 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
2020 #include "llvm/CodeGen/MachineModuleInfo.h"
2121 #include "llvm/CodeGen/MachineBasicBlock.h"
2222 #include "llvm/Support/Annotation.h"
23 #include "llvm/ADT/BitVector.h"
2324
2425 namespace llvm {
2526
102103 // numbered and this vector keeps track of the mapping from ID's to MBB's.
103104 std::vector MBBNumbering;
104105
105 /// UsedPhysRegs - This is a new[]'d array of bools that is computed and set
106 /// by the register allocator, and must be kept up to date by passes that run
107 /// after register allocation (though most don't modify this). This is used
106 /// UsedPhysRegs - This is a bit vector that is computed and set by the
107 /// register allocator, and must be kept up to date by passes that run after
108 /// register allocation (though most don't modify this). This is used
108109 /// so that the code generator knows which callee save registers to save and
109110 /// for other target specific uses.
110 bool *UsedPhysRegs;
111 BitVector UsedPhysRegs;
111112
112113 /// LiveIns/LiveOuts - Keep track of the physical registers that are
113114 /// livein/liveout of the function. Live in values are typically arguments in
169170 return const_cast(this)->getInfo();
170171 }
171172
172 /// setUsedPhysRegs - The register allocator should call this to initialized
173 /// the UsedPhysRegs set. This should be passed a new[]'d array with entries
174 /// for all of the physical registers that the target supports. Each array
175 /// entry should be set to true iff the physical register is used within the
176 /// function.
177 void setUsedPhysRegs(bool *UPR) { UsedPhysRegs = UPR; }
178
179 /// getUsedPhysregs - This returns the UsedPhysRegs array. This returns null
180 /// before register allocation.
181 bool *getUsedPhysregs() { return UsedPhysRegs; }
182 const bool *getUsedPhysregs() const { return UsedPhysRegs; }
183
184173 /// isPhysRegUsed - Return true if the specified register is used in this
185174 /// function. This only works after register allocation.
186175 bool isPhysRegUsed(unsigned Reg) const { return UsedPhysRegs[Reg]; }
187176
188 /// changePhyRegUsed - This method allows code that runs after register
189 /// allocation to keep the PhysRegsUsed array up-to-date.
190 void changePhyRegUsed(unsigned Reg, bool State) { UsedPhysRegs[Reg] = State; }
191
177 /// setPhysRegUsed - Mark the specified register used in this function.
178 /// This should only be called during and after register allocation.
179 void setPhysRegUsed(unsigned Reg) { UsedPhysRegs[Reg] = true; }
180
181 /// setPhysRegUnused - Mark the specified register unused in this function.
182 /// This should only be called during and after register allocation.
183 void setPhysRegUnused(unsigned Reg) { UsedPhysRegs[Reg] = false; }
192184
193185 // LiveIn/LiveOut management methods.
194186
113113
114114 MachineFunction::MachineFunction(const Function *F,
115115 const TargetMachine &TM)
116 : Annotation(MF_AID), Fn(F), Target(TM), UsedPhysRegs(0) {
116 : Annotation(MF_AID), Fn(F), Target(TM) {
117117 SSARegMapping = new SSARegMap();
118118 MFInfo = 0;
119119 FrameInfo = new MachineFrameInfo();
120120 ConstantPool = new MachineConstantPool(TM.getTargetData());
121 UsedPhysRegs.resize(TM.getRegisterInfo()->getNumRegs());
121122
122123 // Set up jump table.
123124 const TargetData &TD = *TM.getTargetData();
137138 delete FrameInfo;
138139 delete ConstantPool;
139140 delete JumpTableInfo;
140 delete[] UsedPhysRegs;
141141 }
142142
143143