llvm.org GIT mirror llvm / 5ea64fd
Constify some methods. Patch provided by Anton Vayvod, thanks! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29756 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 14 years ago
11 changed file(s) with 42 addition(s) and 37 deletion(s). Raw diff Collapse all Expand all
164164 return static_cast(MFInfo);
165165 }
166166
167 template
168 const Ty *getInfo() const {
169 return const_cast(this)->getInfo();
170 }
171
167172 /// setUsedPhysRegs - The register allocator should call this to initialized
168173 /// the UsedPhysRegs set. This should be passed a new[]'d array with entries
169174 /// for all of the physical registers that the target supports. Each array
169169 ///
170170 /// By default, these methods return all registers in the class.
171171 ///
172 virtual iterator allocation_order_begin(MachineFunction &MF) const {
172 virtual iterator allocation_order_begin(const MachineFunction &MF) const {
173173 return begin();
174174 }
175 virtual iterator allocation_order_end(MachineFunction &MF) const {
175 virtual iterator allocation_order_end(const MachineFunction &MF) const {
176176 return end();
177177 }
178178
4444 R7, R8, R9, R10, R11, R12,
4545 R13, R14, R15]> {
4646 let MethodProtos = [{
47 iterator allocation_order_end(MachineFunction &MF) const;
47 iterator allocation_order_end(const MachineFunction &MF) const;
4848 }];
4949 let MethodBodies = [{
5050 IntRegsClass::iterator
51 IntRegsClass::allocation_order_end(MachineFunction &MF) const {
51 IntRegsClass::allocation_order_end(const MachineFunction &MF) const {
5252 // r15 == Program Counter
5353 // r14 == Link Register
5454 // r13 == Stack Pointer
179179 // pointer register. This is true if the function has variable sized allocas or
180180 // if frame pointer elimination is disabled.
181181 //
182 static bool hasFP(MachineFunction &MF) {
182 static bool hasFP(const MachineFunction &MF) {
183183 MachineFrameInfo *MFI = MF.getFrameInfo();
184184 return MFI->hasVarSizedObjects();
185185 }
123123 R15, R30, R31 ]> //zero
124124 {
125125 let MethodProtos = [{
126 iterator allocation_order_end(MachineFunction &MF) const;
126 iterator allocation_order_end(const MachineFunction &MF) const;
127127 }];
128128 let MethodBodies = [{
129129 GPRCClass::iterator
130 GPRCClass::allocation_order_end(MachineFunction &MF) const {
130 GPRCClass::allocation_order_end(const MachineFunction &MF) const {
131131 return end()-3;
132132 }
133133 }];
141141 F31 ]> //zero
142142 {
143143 let MethodProtos = [{
144 iterator allocation_order_end(MachineFunction &MF) const;
144 iterator allocation_order_end(const MachineFunction &MF) const;
145145 }];
146146 let MethodBodies = [{
147147 F4RCClass::iterator
148 F4RCClass::allocation_order_end(MachineFunction &MF) const {
148 F4RCClass::allocation_order_end(const MachineFunction &MF) const {
149149 return end()-1;
150150 }
151151 }];
159159 F31 ]> //zero
160160 {
161161 let MethodProtos = [{
162 iterator allocation_order_end(MachineFunction &MF) const;
162 iterator allocation_order_end(const MachineFunction &MF) const;
163163 }];
164164 let MethodBodies = [{
165165 F8RCClass::iterator
166 F8RCClass::allocation_order_end(MachineFunction &MF) const {
166 F8RCClass::allocation_order_end(const MachineFunction &MF) const {
167167 return end()-1;
168168 }
169169 }];
112112 // pointer register. This is true if the function has variable sized allocas or
113113 // if frame pointer elimination is disabled.
114114 //
115 static bool hasFP(MachineFunction &MF) {
115 static bool hasFP(const MachineFunction &MF) {
116116 return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects();
117117 }
118118
421421 r0, r1, r2, r5, r12, r13, r22, rp]> // the last 16 are special (look down)
422422 {
423423 let MethodProtos = [{
424 iterator allocation_order_begin(MachineFunction &MF) const;
425 iterator allocation_order_end(MachineFunction &MF) const;
424 iterator allocation_order_begin(const MachineFunction &MF) const;
425 iterator allocation_order_end(const MachineFunction &MF) const;
426426 }];
427427 let MethodBodies = [{
428428 GRClass::iterator
429 GRClass::allocation_order_begin(MachineFunction &MF) const {
429 GRClass::allocation_order_begin(const MachineFunction &MF) const {
430430 // hide the 8 out? registers appropriately:
431431 return begin()+(8-(MF.getInfo()->outRegsUsed));
432432 }
433433
434434 GRClass::iterator
435 GRClass::allocation_order_end(MachineFunction &MF) const {
435 GRClass::allocation_order_end(const MachineFunction &MF) const {
436436 int numReservedRegs=8; // the 8 special registers r0,r1,r2,r5,r12,r13 etc
437437
438438 // we also can't allocate registers for use as locals if they're
471471 let Alignment=128;
472472
473473 let MethodProtos = [{
474 iterator allocation_order_begin(MachineFunction &MF) const;
475 iterator allocation_order_end(MachineFunction &MF) const;
474 iterator allocation_order_begin(const MachineFunction &MF) const;
475 iterator allocation_order_end(const MachineFunction &MF) const;
476476 }];
477477 let MethodBodies = [{
478478 FPClass::iterator
479 FPClass::allocation_order_begin(MachineFunction &MF) const {
479 FPClass::allocation_order_begin(const MachineFunction &MF) const {
480480 return begin(); // we don't hide any FP regs from the start
481481 }
482482
483483 FPClass::iterator
484 FPClass::allocation_order_end(MachineFunction &MF) const {
484 FPClass::allocation_order_end(const MachineFunction &MF) const {
485485 return end()-2; // we hide regs F0, F1 from the end
486486 }
487487 }];
208208 R16, R15, R14, R13, R31, R0, R1, LR]>
209209 {
210210 let MethodProtos = [{
211 iterator allocation_order_begin(MachineFunction &MF) const;
212 iterator allocation_order_end(MachineFunction &MF) const;
211 iterator allocation_order_begin(const MachineFunction &MF) const;
212 iterator allocation_order_end(const MachineFunction &MF) const;
213213 }];
214214 let MethodBodies = [{
215215 GPRCClass::iterator
216 GPRCClass::allocation_order_begin(MachineFunction &MF) const {
216 GPRCClass::allocation_order_begin(const MachineFunction &MF) const {
217217 return begin();
218218 }
219219 GPRCClass::iterator
220 GPRCClass::allocation_order_end(MachineFunction &MF) const {
220 GPRCClass::allocation_order_end(const MachineFunction &MF) const {
221221 if (hasFP(MF))
222222 return end()-4; // don't allocate R31, R0, R1, LR
223223 else
231231 X16, X15, X14, X13, X31, X0, X1]>
232232 {
233233 let MethodProtos = [{
234 iterator allocation_order_begin(MachineFunction &MF) const;
235 iterator allocation_order_end(MachineFunction &MF) const;
234 iterator allocation_order_begin(const MachineFunction &MF) const;
235 iterator allocation_order_end(const MachineFunction &MF) const;
236236 }];
237237 let MethodBodies = [{
238238 G8RCClass::iterator
239 G8RCClass::allocation_order_begin(MachineFunction &MF) const {
239 G8RCClass::allocation_order_begin(const MachineFunction &MF) const {
240240 return begin();
241241 }
242242 G8RCClass::iterator
243 G8RCClass::allocation_order_end(MachineFunction &MF) const {
243 G8RCClass::allocation_order_end(const MachineFunction &MF) const {
244244 if (hasFP(MF))
245245 return end()-3;
246246 else
137137 G5, G6, G7 // reserved for kernel
138138 ]> {
139139 let MethodProtos = [{
140 iterator allocation_order_end(MachineFunction &MF) const;
140 iterator allocation_order_end(const MachineFunction &MF) const;
141141 }];
142142 let MethodBodies = [{
143143 IntRegsClass::iterator
144 IntRegsClass::allocation_order_end(MachineFunction &MF) const {
144 IntRegsClass::allocation_order_end(const MachineFunction &MF) const {
145145 // FIXME: These special regs should be taken out of the regclass!
146146 return end()-10 // Don't allocate special registers
147147 -1; // FIXME: G1 reserved for large imm generation by frame code.
736736 // pointer register. This is true if the function has variable sized allocas or
737737 // if frame pointer elimination is disabled.
738738 //
739 static bool hasFP(MachineFunction &MF) {
739 static bool hasFP(const MachineFunction &MF) {
740740 return (NoFramePointerElim ||
741741 MF.getFrameInfo()->hasVarSizedObjects() ||
742742 MF.getInfo()->getForceFramePointer());
106106
107107 def GR16 : RegisterClass<"X86", [i16], 16, [AX, CX, DX, SI, DI, BX, BP, SP]> {
108108 let MethodProtos = [{
109 iterator allocation_order_end(MachineFunction &MF) const;
109 iterator allocation_order_end(const MachineFunction &MF) const;
110110 }];
111111 let MethodBodies = [{
112112 GR16Class::iterator
113 GR16Class::allocation_order_end(MachineFunction &MF) const {
113 GR16Class::allocation_order_end(const MachineFunction &MF) const {
114114 if (hasFP(MF)) // Does the function dedicate EBP to being a frame ptr?
115115 return end()-2; // If so, don't allocate SP or BP
116116 else
122122 def GR32 : RegisterClass<"X86", [i32], 32,
123123 [EAX, ECX, EDX, ESI, EDI, EBX, EBP, ESP]> {
124124 let MethodProtos = [{
125 iterator allocation_order_end(MachineFunction &MF) const;
125 iterator allocation_order_end(const MachineFunction &MF) const;
126126 }];
127127 let MethodBodies = [{
128128 GR32Class::iterator
129 GR32Class::allocation_order_end(MachineFunction &MF) const {
129 GR32Class::allocation_order_end(const MachineFunction &MF) const {
130130 if (hasFP(MF)) // Does the function dedicate EBP to being a frame ptr?
131131 return end()-2; // If so, don't allocate ESP or EBP
132132 else
159159 def RST : RegisterClass<"X86", [f64], 32,
160160 [ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7]> {
161161 let MethodProtos = [{
162 iterator allocation_order_end(MachineFunction &MF) const;
162 iterator allocation_order_end(const MachineFunction &MF) const;
163163 }];
164164 let MethodBodies = [{
165165 RSTClass::iterator
166 RSTClass::allocation_order_end(MachineFunction &MF) const {
166 RSTClass::allocation_order_end(const MachineFunction &MF) const {
167167 return begin();
168168 }
169169 }];