simplify some code based on the fact that picstyles != none are only valid
authorChris Lattner <sabre@nondot.org>
Thu, 9 Jul 2009 04:39:06 +0000 (04:39 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 9 Jul 2009 04:39:06 +0000 (04:39 +0000)
in pic or dynamic-no-pic mode. Also, x86-64 never used picstylegot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75101 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86FastISel.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86Subtarget.cpp

index b336d780c505da870ece3c25493b2dc72d4e7890..58f5b988b056aa0d26139c374d1de4676475c2c0 100644 (file)
@@ -470,8 +470,7 @@ bool X86FastISel::X86SelectAddress(Value *V, X86AddressMode &AM, bool isCall) {
         Opc = X86::MOV32rm;
         RC  = X86::GR32RegisterClass;
         
-        if (Subtarget->isPICStyleGOT() &&
-            TM.getRelocationModel() == Reloc::PIC_)
+        if (Subtarget->isPICStyleGOT())
           StubAM.GVOpFlags = X86II::MO_GOT;
         
       } else {
@@ -1294,9 +1293,7 @@ bool X86FastISel::X86SelectCall(Instruction *I) {
 
   // ELF / PIC requires GOT in the EBX register before function calls via PLT
   // GOT pointer.  
-  if (!Subtarget->is64Bit() &&
-      TM.getRelocationModel() == Reloc::PIC_ &&
-      Subtarget->isPICStyleGOT()) {
+  if (Subtarget->isPICStyleGOT()) {
     TargetRegisterClass *RC = X86::GR32RegisterClass;
     unsigned Base = getInstrInfo()->getGlobalBaseReg(&MF);
     bool Emitted = TII.copyRegToReg(*MBB, MBB->end(), X86::EBX, Base, RC, RC);
@@ -1313,9 +1310,7 @@ bool X86FastISel::X86SelectCall(Instruction *I) {
     : BuildMI(MBB, DL, TII.get(CallOpc)).addGlobalAddress(GV);
 
   // Add an implicit use GOT pointer in EBX.
-  if (!Subtarget->is64Bit() &&
-      TM.getRelocationModel() == Reloc::PIC_ &&
-      Subtarget->isPICStyleGOT())
+  if (Subtarget->isPICStyleGOT())
     MIB.addReg(X86::EBX);
 
   // Add implicit physical register uses to the call.
@@ -1509,16 +1504,16 @@ unsigned X86FastISel::TargetMaterializeConstant(Constant *C) {
   // x86-32 PIC requires a PIC base register for constant pools.
   unsigned PICBase = 0;
   unsigned char OpFlag = 0;
-  if (TM.getRelocationModel() == Reloc::PIC_) {
-    if (Subtarget->isPICStyleStub()) {
-      OpFlag = X86II::MO_PIC_BASE_OFFSET;
-      PICBase = getInstrInfo()->getGlobalBaseReg(&MF);
-    } else if (Subtarget->isPICStyleGOT()) {
-      OpFlag = X86II::MO_GOTOFF;
-      PICBase = getInstrInfo()->getGlobalBaseReg(&MF);
-    } else if (Subtarget->isPICStyleRIPRel() &&
-               TM.getCodeModel() == CodeModel::Small)
-      PICBase = X86::RIP;
+  if (Subtarget->isPICStyleStub() &&
+      TM.getRelocationModel() == Reloc::PIC_) { // Not dynamic-no-pic
+    OpFlag = X86II::MO_PIC_BASE_OFFSET;
+    PICBase = getInstrInfo()->getGlobalBaseReg(&MF);
+  } else if (Subtarget->isPICStyleGOT()) {
+    OpFlag = X86II::MO_GOTOFF;
+    PICBase = getInstrInfo()->getGlobalBaseReg(&MF);
+  } else if (Subtarget->isPICStyleRIPRel() &&
+             TM.getCodeModel() == CodeModel::Small) {
+    PICBase = X86::RIP;
   }
 
   // Create the load from the constant pool.
index 1deeb4560ba493374c661096da7422c07fe2f1b9..d859423300117c26c769e6abdf81c3c998c64844 100644 (file)
@@ -1811,7 +1811,7 @@ SDValue X86TargetLowering::LowerCALL(SDValue Op, SelectionDAG &DAG) {
           !G->getGlobal()->hasProtectedVisibility())
         Callee = LowerGlobalAddress(Callee, DAG);
       else if (isa<ExternalSymbolSDNode>(Callee))
-        Callee = LowerExternalSymbol(Callee,DAG);
+        Callee = LowerExternalSymbol(Callee, DAG);
     }
   }
 
index b253146713ec941275a8a6b79e09d8ba6feb321b..5507e43b6df3f129cb506561c9e39f0d3e8de2f9 100644 (file)
@@ -3245,8 +3245,7 @@ unsigned X86InstrInfo::getGlobalBaseReg(MachineFunction *MF) const {
   
   // If we're using vanilla 'GOT' PIC style, we should use relative addressing
   // not to pc, but to _GLOBAL_OFFSET_TABLE_ external.
-  if (TM.getRelocationModel() == Reloc::PIC_ &&
-      TM.getSubtarget<X86Subtarget>().isPICStyleGOT()) {
+  if (TM.getSubtarget<X86Subtarget>().isPICStyleGOT()) {
     GlobalBaseReg = RegInfo.createVirtualRegister(X86::GR32RegisterClass);
     // Generate addl $__GLOBAL_OFFSET_TABLE_ + [.-piclabel], %some_register
     BuildMI(FirstMBB, MBBI, DL, TII->get(X86::ADD32ri), GlobalBaseReg)
index e4cd288470e2f868adca15095218ee208fedb4ca..f181b38cb2890f289c70d215665ee62afb4bfc72 100644 (file)
@@ -77,8 +77,7 @@ bool X86Subtarget::GVRequiresExtraLoad(const GlobalValue* GV,
 /// a register, but not an extra load.
 bool X86Subtarget::GVRequiresRegister(const GlobalValue *GV,
                                       const TargetMachine& TM,
-                                      bool isDirectCall) const
-{
+                                      bool isDirectCall) const {
   if (GVRequiresExtraLoad(GV, TM, isDirectCall))
     return true;
   // Code below here need only consider cases where GVRequiresExtraLoad