virtual void emitEpilogue(MachineFunction &MF,
MachineBasicBlock &MBB) const = 0;
+ //===--------------------------------------------------------------------===//
+ /// Debug information queries.
+
+ /// getFrameRegister - This method should return the register used as a base
+ /// for values allocated in the current stack frame. This value should be
+ /// returned as a dwarf register number (getDwarfRegNum.)
+ virtual unsigned getFrameRegister(MachineFunction &MF) const = 0;
+
/// getLocation - This method should return the actual location of a frame
/// variable given the frame index. The location is returned in ML.
+ /// Subclasses should override this method for special handling of frame
+ /// variables and call MRegisterInfo::getLocation for the default action.
virtual void getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const = 0;
+ MachineLocation &ML) const;
};
// This is useful when building DenseMaps keyed on virtual registers
}
}
-void AlphaRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const {
- assert(0 && "Needs to be defined for target");
- MachineFrameInfo *MFI = MF.getFrameInfo();
- bool FP = hasFP(MF);
-
- // FIXME - Needs to handle register variables.
- // FIXME - Faking that llvm number is same as gcc numbering.
- ML.set(getDwarfRegNum(FP ? Alpha::R15 : Alpha::R30),
- MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned AlphaRegisterInfo::getFrameRegister(MachineFunction &MF) const {
+ return getDwarfRegNum(hasFP(MF) ? Alpha::R15 : Alpha::R30);
}
#include "AlphaGenRegisterInfo.inc"
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
- void getLocation(MachineFunction &MF, unsigned Index, MachineLocation &ML) const;
-
+ // Debug information queries.
+ unsigned getFrameRegister(MachineFunction &MF) const;
static std::string getPrettyName(unsigned reg);
};
}
-void IA64RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const {
- assert(0 && "Needs to be defined for target");
- MachineFrameInfo *MFI = MF.getFrameInfo();
- bool FP = hasFP(MF);
-
- // FIXME - Needs to handle register variables.
- // FIXME - Faking that llvm number is same as gcc numbering.
- ML.set(getDwarfRegNum(FP ? IA64::r5 : IA64::r12),
- MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned IA64RegisterInfo::getFrameRegister(MachineFunction &MF) const {
+ return getDwarfRegNum(hasFP(MF) ? IA64::r5 : IA64::r12);
}
-
#include "IA64GenRegisterInfo.inc"
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
- void getLocation(MachineFunction &MF, unsigned Index, MachineLocation &ML) const;
+ // Debug information queries.
+ unsigned getFrameRegister(MachineFunction &MF) const;
};
} // End llvm namespace
//===----------------------------------------------------------------------===//
#include "llvm/Target/MRegisterInfo.h"
+
+#include "llvm/CodeGen/MachineFunction.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
+#include "llvm/CodeGen/MachineLocation.h"
+
using namespace llvm;
MRegisterInfo::MRegisterInfo(const TargetRegisterDesc *D, unsigned NR,
}
return Allocatable;
}
+
+/// getLocation - This method should return the actual location of a frame
+/// variable given the frame index. The location is returned in ML.
+/// Subclasses should override this method for special handling of frame
+/// variables and then call MRegisterInfo::getLocation for the default action.
+void MRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
+ MachineLocation &ML) const {
+ MachineFrameInfo *MFI = MF.getFrameInfo();
+ ML.set(getFrameRegister(MF),
+ MFI->getObjectOffset(Index) + MFI->getStackSize());
+}
}
}
-void PPCRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const {
- MachineFrameInfo *MFI = MF.getFrameInfo();
- bool FP = hasFP(MF);
-
- // FIXME - Needs to handle register variables.
- // FIXME - Faking that llvm number is same as gcc numbering.
- ML.set(getDwarfRegNum(FP ? PPC::R31 : PPC::R1),
- MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned PPCRegisterInfo::getFrameRegister(MachineFunction &MF) const {
+ return getDwarfRegNum(hasFP(MF) ? PPC::R31 : PPC::R1);
}
#include "PPCGenRegisterInfo.inc"
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
- void getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const;
+ // Debug information queries.
+ unsigned getFrameRegister(MachineFunction &MF) const;
};
} // end namespace llvm
BuildMI(MBB, MBBI, SP::RESTORErr, 2, SP::G0).addReg(SP::G0).addReg(SP::G0);
}
-void SparcRegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const {
- assert(0 && "Needs to be defined for target");
- MachineFrameInfo *MFI = MF.getFrameInfo();
-
- // FIXME - Needs to handle register variables.
- // FIXME - Faking that llvm number is same as gcc numbering.
- ML.set(getDwarfRegNum(SP::G1),
- MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned SparcRegisterInfo::getFrameRegister(MachineFunction &MF) const {
+ return getDwarfRegNum(SP::G1);
}
#include "SparcGenRegisterInfo.inc"
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
- void getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const;
+ // Debug information queries.
+ unsigned getFrameRegister(MachineFunction &MF) const;
};
} // end namespace llvm
}
-void SparcV9RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const {
+unsigned SparcV9RegisterInfo::getFrameRegister(MachineFunction &MF) const {
abort ();
+ return 0;
}
void eliminateFrameIndex (MachineBasicBlock::iterator MI) const;
void emitPrologue (MachineFunction &MF) const;
void emitEpilogue (MachineFunction &MF, MachineBasicBlock &MBB) const;
- void getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const;
+
+ // Debug information queries.
+ unsigned getFrameRegister(MachineFunction &MF) const;
};
} // End llvm namespace
}
}
-void X86RegisterInfo::getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const {
- MachineFrameInfo *MFI = MF.getFrameInfo();
- bool FP = hasFP(MF);
-
- // FIXME - Needs to handle register variables.
- // FIXME - Hardcoding gcc numbering.
- ML.set(getDwarfRegNum(FP ? X86::EBP : X86::ESP),
- MFI->getObjectOffset(Index) + MFI->getStackSize());
+unsigned X86RegisterInfo::getFrameRegister(MachineFunction &MF) const {
+ return getDwarfRegNum(hasFP(MF) ? X86::EBP : X86::ESP);
}
#include "X86GenRegisterInfo.inc"
void emitPrologue(MachineFunction &MF) const;
void emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const;
- void getLocation(MachineFunction &MF, unsigned Index,
- MachineLocation &ML) const;
+ // Debug information queries.
+ unsigned getFrameRegister(MachineFunction &MF) const;
};
} // End llvm namespace