void printHex32(unsigned int Value);
void emitFunctionStart(MachineFunction &MF);
- void emitFunctionEnd();
+ void emitFunctionEnd(MachineFunction &MF);
void emitFrameDirective(MachineFunction &MF);
void emitMaskDirective(MachineFunction &MF);
void emitFMaskDirective(MachineFunction &MF);
Bitmask |= (1 << MipsRegisterInfo::getRegisterNumbering(CSI[i].getReg()));
if (RI.hasFP(MF))
- Bitmask |= (1 << MipsRegisterInfo::getRegisterNumbering(RI.getFrameRegister(MF)));
+ Bitmask |= (1 << MipsRegisterInfo::
+ getRegisterNumbering(RI.getFrameRegister(MF)));
if (MF.getFrameInfo()->hasCalls())
- Bitmask |= (1 << MipsRegisterInfo::getRegisterNumbering(RI.getRARegister()));
+ Bitmask |= (1 << MipsRegisterInfo::
+ getRegisterNumbering(RI.getRARegister()));
return Bitmask;
}
emitFrameDirective(MF);
emitMaskDirective(MF);
emitFMaskDirective(MF);
- emitSetDirective(NOREORDER);
- emitSetDirective(NOMACRO);
+
+ if (MF.getTarget().getRelocationModel() == Reloc::Static) {
+ emitSetDirective(NOREORDER);
+ emitSetDirective(NOMACRO);
+ }
+
O << "\n";
}
/// Emit the directives used by GAS on the end of functions
void MipsAsmPrinter::
-emitFunctionEnd() {
- emitSetDirective(MACRO);
- emitSetDirective(REORDER);
+emitFunctionEnd(MachineFunction &MF)
+{
+ if (MF.getTarget().getRelocationModel() == Reloc::Static) {
+ emitSetDirective(MACRO);
+ emitSetDirective(REORDER);
+ }
+
O << "\t.end\t" << CurrentFnName << "\n";
}
}
// Emit function end directives
- emitFunctionEnd();
+ emitFunctionEnd(MF);
// We didn't modify anything.
return false;
/// the Return Address must be saved
int RAStackOffset;
+ /// When PIC is used the GP must be saved on the stack
+ /// on the function prologue, so a reference to its stack
+ /// location must be kept.
+ int GPStackOffset;
+
/// MipsFIHolder - Holds a FrameIndex and it's Stack Pointer Offset
struct MipsFIHolder {
int getRAStackOffset() const { return RAStackOffset; }
void setRAStackOffset(int Off) { RAStackOffset = Off; }
+ int getGPStackOffset() const { return GPStackOffset; }
+ void setGPStackOffset(int Off) { GPStackOffset = Off; }
+
int getTopSavedRegOffset() const {
return (RAStackOffset > FPStackOffset) ?
(RAStackOffset) : (FPStackOffset);
MipsTargetMachine(const Module &M, const std::string &FS):
Subtarget(*this, M, FS), DataLayout("E-p:32:32:32"),
InstrInfo(*this), FrameInfo(TargetFrameInfo::StackGrowsUp, 8, 0),
- TLInfo(*this) {}
+ TLInfo(*this)
+{
+ if (getRelocationModel() != Reloc::Static)
+ setRelocationModel(Reloc::PIC_);
+}
// return 0 and must specify -march to gen MIPS code.
unsigned MipsTargetMachine::