llvm.org GIT mirror llvm / a997918
Expose base register for DwarfWriter. Refactor code accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@27225 91177308-0d34-0410-b5e6-96231b3b80d8 Jim Laskey 13 years ago
14 changed file(s) with 55 addition(s) and 65 deletion(s). Raw diff Collapse all Expand all
342342 virtual void emitEpilogue(MachineFunction &MF,
343343 MachineBasicBlock &MBB) const = 0;
344344
345 //===--------------------------------------------------------------------===//
346 /// Debug information queries.
347
348 /// getFrameRegister - This method should return the register used as a base
349 /// for values allocated in the current stack frame. This value should be
350 /// returned as a dwarf register number (getDwarfRegNum.)
351 virtual unsigned getFrameRegister(MachineFunction &MF) const = 0;
352
345353 /// getLocation - This method should return the actual location of a frame
346354 /// variable given the frame index. The location is returned in ML.
355 /// Subclasses should override this method for special handling of frame
356 /// variables and call MRegisterInfo::getLocation for the default action.
347357 virtual void getLocation(MachineFunction &MF, unsigned Index,
348 MachineLocation &ML) const = 0;
358 MachineLocation &ML) const;
349359 };
350360
351361 // This is useful when building DenseMaps keyed on virtual registers
353353 }
354354 }
355355
356 void AlphaRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
357 MachineLocation &ML) const {
358 assert(0 && "Needs to be defined for target");
359 MachineFrameInfo *MFI = MF.getFrameInfo();
360 bool FP = hasFP(MF);
361
362 // FIXME - Needs to handle register variables.
363 // FIXME - Faking that llvm number is same as gcc numbering.
364 ML.set(getDwarfRegNum(FP ? Alpha::R15 : Alpha::R30),
365 MFI->getObjectOffset(Index) + MFI->getStackSize());
356 unsigned AlphaRegisterInfo::getFrameRegister(MachineFunction &MF) const {
357 return getDwarfRegNum(hasFP(MF) ? Alpha::R15 : Alpha::R30);
366358 }
367359
368360 #include "AlphaGenRegisterInfo.inc"
5252 void emitPrologue(MachineFunction &MF) const;
5353 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
5454
55 void getLocation(MachineFunction &MF, unsigned Index, MachineLocation &ML) const;
56
55 // Debug information queries.
56 unsigned getFrameRegister(MachineFunction &MF) const;
5757
5858 static std::string getPrettyName(unsigned reg);
5959 };
328328
329329 }
330330
331 void IA64RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
332 MachineLocation &ML) const {
333 assert(0 && "Needs to be defined for target");
334 MachineFrameInfo *MFI = MF.getFrameInfo();
335 bool FP = hasFP(MF);
336
337 // FIXME - Needs to handle register variables.
338 // FIXME - Faking that llvm number is same as gcc numbering.
339 ML.set(getDwarfRegNum(FP ? IA64::r5 : IA64::r12),
340 MFI->getObjectOffset(Index) + MFI->getStackSize());
341 }
342
331 unsigned IA64RegisterInfo::getFrameRegister(MachineFunction &MF) const {
332 return getDwarfRegNum(hasFP(MF) ? IA64::r5 : IA64::r12);
333 }
343334
344335 #include "IA64GenRegisterInfo.inc"
345336
4848 void emitPrologue(MachineFunction &MF) const;
4949 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
5050
51 void getLocation(MachineFunction &MF, unsigned Index, MachineLocation &ML) const;
51 // Debug information queries.
52 unsigned getFrameRegister(MachineFunction &MF) const;
5253 };
5354
5455 } // End llvm namespace
1111 //===----------------------------------------------------------------------===//
1212
1313 #include "llvm/Target/MRegisterInfo.h"
14
15 #include "llvm/CodeGen/MachineFunction.h"
16 #include "llvm/CodeGen/MachineFrameInfo.h"
17 #include "llvm/CodeGen/MachineLocation.h"
18
1419 using namespace llvm;
1520
1621 MRegisterInfo::MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
3742 }
3843 return Allocatable;
3944 }
45
46 /// getLocation - This method should return the actual location of a frame
47 /// variable given the frame index. The location is returned in ML.
48 /// Subclasses should override this method for special handling of frame
49 /// variables and then call MRegisterInfo::getLocation for the default action.
50 void MRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
51 MachineLocation &ML) const {
52 MachineFrameInfo *MFI = MF.getFrameInfo();
53 ML.set(getFrameRegister(MF),
54 MFI->getObjectOffset(Index) + MFI->getStackSize());
55 }
446446 }
447447 }
448448
449 void PPCRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
450 MachineLocation &ML) const {
451 MachineFrameInfo *MFI = MF.getFrameInfo();
452 bool FP = hasFP(MF);
453
454 // FIXME - Needs to handle register variables.
455 // FIXME - Faking that llvm number is same as gcc numbering.
456 ML.set(getDwarfRegNum(FP ? PPC::R31 : PPC::R1),
457 MFI->getObjectOffset(Index) + MFI->getStackSize());
449 unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const {
450 return getDwarfRegNum(hasFP(MF) ? PPC::R31 : PPC::R1);
458451 }
459452
460453 #include "PPCGenRegisterInfo.inc"
5555 void emitPrologue(MachineFunction &MF) const;
5656 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
5757
58 void getLocation(MachineFunction &MF, unsigned Index,
59 MachineLocation &ML) const;
58 // Debug information queries.
59 unsigned getFrameRegister(MachineFunction &MF) const;
6060 };
6161
6262 } // end namespace llvm
199199 BuildMI(MBB, MBBI, SP::RESTORErr, 2, SP::G0).addReg(SP::G0).addReg(SP::G0);
200200 }
201201
202 void SparcRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
203 MachineLocation &ML) const {
204 assert(0 && "Needs to be defined for target");
205 MachineFrameInfo *MFI = MF.getFrameInfo();
206
207 // FIXME - Needs to handle register variables.
208 // FIXME - Faking that llvm number is same as gcc numbering.
209 ML.set(getDwarfRegNum(SP::G1),
210 MFI->getObjectOffset(Index) + MFI->getStackSize());
202 unsigned SparcRegisterInfo::getFrameRegister(MachineFunction &MF) const {
203 return getDwarfRegNum(SP::G1);
211204 }
212205
213206 #include "SparcGenRegisterInfo.inc"
5656 void emitPrologue(MachineFunction &MF) const;
5757 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
5858
59 void getLocation(MachineFunction &MF, unsigned Index,
60 MachineLocation &ML) const;
59 // Debug information queries.
60 unsigned getFrameRegister(MachineFunction &MF) const;
6161 };
6262
6363 } // end namespace llvm
317317 }
318318
319319
320 void SparcV9RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
321 MachineLocation &ML) const {
322 abort ();
323 }
320 unsigned SparcV9RegisterInfo::getFrameRegister(MachineFunction &MF) const {
321 abort ();
322 return 0;
323 }
4343 void eliminateFrameIndex (MachineBasicBlock::iterator MI) const;
4444 void emitPrologue (MachineFunction &MF) const;
4545 void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const;
46 void getLocation(MachineFunction &MF, unsigned Index,
47 MachineLocation &ML) const;
46
47 // Debug information queries.
48 unsigned getFrameRegister(MachineFunction &MF) const;
4849 };
4950
5051 } // End llvm namespace
685685 }
686686 }
687687
688 void X86RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
689 MachineLocation &ML) const {
690 MachineFrameInfo *MFI = MF.getFrameInfo();
691 bool FP = hasFP(MF);
692
693 // FIXME - Needs to handle register variables.
694 // FIXME - Hardcoding gcc numbering.
695 ML.set(getDwarfRegNum(FP ? X86::EBP : X86::ESP),
696 MFI->getObjectOffset(Index) + MFI->getStackSize());
688 unsigned X86RegisterInfo::getFrameRegister(MachineFunction &MF) const {
689 return getDwarfRegNum(hasFP(MF) ? X86::EBP : X86::ESP);
697690 }
698691
699692 #include "X86GenRegisterInfo.inc"
6262 void emitPrologue(MachineFunction &MF) const;
6363 void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
6464
65 void getLocation(MachineFunction &MF, unsigned Index,
66 MachineLocation &ML) const;
65 // Debug information queries.
66 unsigned getFrameRegister(MachineFunction &MF) const;
6767 };
6868
6969 } // End llvm namespace