forked from OSchip/llvm-project
* Materialize GlobalAddress and ExternalSym with MOV32ri rather than
LEA32r. * Do not lower GlobalAddress to TargetGlobalAddress. Let isel does it. llvm-svn: 25246
This commit is contained in:
parent
e6300aaabc
commit
b94db9e9a4
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)>;
|
||||
|
|
Loading…
Reference in New Issue