* Materialize GlobalAddress and ExternalSym with MOV32ri rather than
authorEvan Cheng <evan.cheng@apple.com>
Thu, 12 Jan 2006 07:56:47 +0000 (07:56 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 12 Jan 2006 07:56:47 +0000 (07:56 +0000)
  LEA32r.
* Do not lower GlobalAddress to TargetGlobalAddress. Let isel does it.

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

lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86InstrInfo.td

index 25ac370da9a9576f279026a7f66441ec4af08d13..8b15727aaeb8eeafe7e6d1a3381b85e98cc47d32 100644 (file)
@@ -1723,8 +1723,8 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
                        DAG.getValueType(AVT), InFlag);
   }
   case ISD::GlobalAddress: {
+    SDOperand Result;
     GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal();
-    SDOperand GVOp = DAG.getTargetGlobalAddress(GV, getPointerTy());
     // For Darwin, external and weak symbols are indirect, so we want to load
     // the value at address GV, not the value of GV itself.  This means that
     // the GlobalAddress must be in the base or index register of the address,
@@ -1732,11 +1732,10 @@ SDOperand X86TargetLowering::LowerOperation(SDOperand Op, SelectionDAG &DAG) {
     if (getTargetMachine().
         getSubtarget<X86Subtarget>().getIndirectExternAndWeakGlobals() &&
         (GV->hasWeakLinkage() || GV->isExternal()))
-      return DAG.getLoad(MVT::i32, DAG.getEntryNode(),
-                         GVOp, DAG.getSrcValue(NULL));
-    else
-      return GVOp;
-    break;
+      Result = DAG.getLoad(MVT::i32, DAG.getEntryNode(),
+                           DAG.getTargetGlobalAddress(GV, getPointerTy()),
+                           DAG.getSrcValue(NULL));
+    return Result;
   }
   }
 }
index 9de818543bb3c0957bed8a12aaea0aae6d18c08b..d6dc20a7a8bd50989329865045eb1d0af5348967 100644 (file)
@@ -153,8 +153,7 @@ def brtarget : Operand<OtherVT>;
 // Define X86 specific addressing mode.
 def addr    : ComplexPattern<i32, 4, "SelectAddr", []>;
 def leaaddr : ComplexPattern<i32, 4, "SelectLEAAddr",
-                             [add, frameindex, constpool,
-                              globaladdr, tglobaladdr, externalsym]>;
+                             [add, frameindex, constpool]>;
 
 //===----------------------------------------------------------------------===//
 // X86 Instruction Format Definitions.
@@ -2958,6 +2957,10 @@ def RDTSC : I<0x31, RawFrm, (ops), "rdtsc", [(X86rdtsc)]>,
 // Non-Instruction Patterns
 //===----------------------------------------------------------------------===//
 
+// GlobalAddress and ExternalSymbol
+def : Pat<(i32 globaladdr:$dst),  (MOV32ri globaladdr:$dst)>;
+def : Pat<(i32 externalsym:$dst), (MOV32ri externalsym:$dst)>;
+
 // Calls
 def : Pat<(X86call tglobaladdr:$dst),
           (CALLpcrel32 tglobaladdr:$dst)>;