Position Independent Code (PIC) support [2]
- Added a function to hold the stack location 
  where GP must be stored during LowerCALL
- AsmPrinter now emits directives based on
  relocation type
- PIC_ set to default relocation type (same as GCC)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42779 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Target/Mips/MipsAsmPrinter.cpp b/lib/Target/Mips/MipsAsmPrinter.cpp
index 254cc56..cd5c1a3 100644
--- a/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -67,7 +67,7 @@
     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);
@@ -209,10 +209,12 @@
     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;
 }
@@ -247,16 +249,24 @@
   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";
 }
 
@@ -298,7 +308,7 @@
   }
 
   // Emit function end directives
-  emitFunctionEnd();
+  emitFunctionEnd(MF);
 
   // We didn't modify anything.
   return false;