mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
[mips] The decision to use MO_GOT_PAGE and MO_GOT_OFST depends on the ABI being N32 or N64 not the arch being MIPS64
Summary: No functional change (in supported use cases) Reviewers: matheusalmeida Reviewed By: matheusalmeida Differential Revision: http://llvm-reviews.chandlerc.com/D3177 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204805 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4de1039403
commit
cee1aecc57
@ -1519,7 +1519,7 @@ SDValue MipsTargetLowering::lowerGlobalAddress(SDValue Op,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (GV->hasInternalLinkage() || (GV->hasLocalLinkage() && !isa<Function>(GV)))
|
if (GV->hasInternalLinkage() || (GV->hasLocalLinkage() && !isa<Function>(GV)))
|
||||||
return getAddrLocal(N, Ty, DAG, HasMips64);
|
return getAddrLocal(N, Ty, DAG, isN32() || IsN64);
|
||||||
|
|
||||||
if (LargeGOT)
|
if (LargeGOT)
|
||||||
return getAddrGlobalLargeGOT(N, Ty, DAG, MipsII::MO_GOT_HI16,
|
return getAddrGlobalLargeGOT(N, Ty, DAG, MipsII::MO_GOT_HI16,
|
||||||
@ -1539,7 +1539,7 @@ SDValue MipsTargetLowering::lowerBlockAddress(SDValue Op,
|
|||||||
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !IsN64)
|
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !IsN64)
|
||||||
return getAddrNonPIC(N, Ty, DAG);
|
return getAddrNonPIC(N, Ty, DAG);
|
||||||
|
|
||||||
return getAddrLocal(N, Ty, DAG, HasMips64);
|
return getAddrLocal(N, Ty, DAG, isN32() || IsN64);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue MipsTargetLowering::
|
SDValue MipsTargetLowering::
|
||||||
@ -1632,7 +1632,7 @@ lowerJumpTable(SDValue Op, SelectionDAG &DAG) const
|
|||||||
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !IsN64)
|
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !IsN64)
|
||||||
return getAddrNonPIC(N, Ty, DAG);
|
return getAddrNonPIC(N, Ty, DAG);
|
||||||
|
|
||||||
return getAddrLocal(N, Ty, DAG, HasMips64);
|
return getAddrLocal(N, Ty, DAG, isN32() || IsN64);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue MipsTargetLowering::
|
SDValue MipsTargetLowering::
|
||||||
@ -1653,7 +1653,7 @@ lowerConstantPool(SDValue Op, SelectionDAG &DAG) const
|
|||||||
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !IsN64)
|
if (getTargetMachine().getRelocationModel() != Reloc::PIC_ && !IsN64)
|
||||||
return getAddrNonPIC(N, Ty, DAG);
|
return getAddrNonPIC(N, Ty, DAG);
|
||||||
|
|
||||||
return getAddrLocal(N, Ty, DAG, HasMips64);
|
return getAddrLocal(N, Ty, DAG, isN32() || IsN64);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue MipsTargetLowering::lowerVASTART(SDValue Op, SelectionDAG &DAG) const {
|
SDValue MipsTargetLowering::lowerVASTART(SDValue Op, SelectionDAG &DAG) const {
|
||||||
@ -2510,7 +2510,7 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
|||||||
InternalLinkage = Val->hasInternalLinkage();
|
InternalLinkage = Val->hasInternalLinkage();
|
||||||
|
|
||||||
if (InternalLinkage)
|
if (InternalLinkage)
|
||||||
Callee = getAddrLocal(G, Ty, DAG, HasMips64);
|
Callee = getAddrLocal(G, Ty, DAG, isN32() || IsN64);
|
||||||
else if (LargeGOT)
|
else if (LargeGOT)
|
||||||
Callee = getAddrGlobalLargeGOT(G, Ty, DAG, MipsII::MO_CALL_HI16,
|
Callee = getAddrGlobalLargeGOT(G, Ty, DAG, MipsII::MO_CALL_HI16,
|
||||||
MipsII::MO_CALL_LO16, Chain,
|
MipsII::MO_CALL_LO16, Chain,
|
||||||
|
@ -258,17 +258,17 @@ namespace llvm {
|
|||||||
// computing a local symbol's address:
|
// computing a local symbol's address:
|
||||||
//
|
//
|
||||||
// (add (load (wrapper $gp, %got(sym)), %lo(sym))
|
// (add (load (wrapper $gp, %got(sym)), %lo(sym))
|
||||||
template<class NodeTy>
|
template <class NodeTy>
|
||||||
SDValue getAddrLocal(NodeTy *N, EVT Ty, SelectionDAG &DAG,
|
SDValue getAddrLocal(NodeTy *N, EVT Ty, SelectionDAG &DAG,
|
||||||
bool HasMips64) const {
|
bool IsN32OrN64) const {
|
||||||
SDLoc DL(N);
|
SDLoc DL(N);
|
||||||
unsigned GOTFlag = HasMips64 ? MipsII::MO_GOT_PAGE : MipsII::MO_GOT;
|
unsigned GOTFlag = IsN32OrN64 ? MipsII::MO_GOT_PAGE : MipsII::MO_GOT;
|
||||||
SDValue GOT = DAG.getNode(MipsISD::Wrapper, DL, Ty, getGlobalReg(DAG, Ty),
|
SDValue GOT = DAG.getNode(MipsISD::Wrapper, DL, Ty, getGlobalReg(DAG, Ty),
|
||||||
getTargetNode(N, Ty, DAG, GOTFlag));
|
getTargetNode(N, Ty, DAG, GOTFlag));
|
||||||
SDValue Load = DAG.getLoad(Ty, DL, DAG.getEntryNode(), GOT,
|
SDValue Load = DAG.getLoad(Ty, DL, DAG.getEntryNode(), GOT,
|
||||||
MachinePointerInfo::getGOT(), false, false,
|
MachinePointerInfo::getGOT(), false, false,
|
||||||
false, 0);
|
false, 0);
|
||||||
unsigned LoFlag = HasMips64 ? MipsII::MO_GOT_OFST : MipsII::MO_ABS_LO;
|
unsigned LoFlag = IsN32OrN64 ? MipsII::MO_GOT_OFST : MipsII::MO_ABS_LO;
|
||||||
SDValue Lo = DAG.getNode(MipsISD::Lo, DL, Ty,
|
SDValue Lo = DAG.getNode(MipsISD::Lo, DL, Ty,
|
||||||
getTargetNode(N, Ty, DAG, LoFlag));
|
getTargetNode(N, Ty, DAG, LoFlag));
|
||||||
return DAG.getNode(ISD::ADD, DL, Ty, Load, Lo);
|
return DAG.getNode(ISD::ADD, DL, Ty, Load, Lo);
|
||||||
@ -434,6 +434,8 @@ namespace llvm {
|
|||||||
|
|
||||||
bool HasMips64, IsN64, IsO32;
|
bool HasMips64, IsN64, IsO32;
|
||||||
|
|
||||||
|
bool isN32() const { return Subtarget->isABI_N32(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Create a TargetGlobalAddress node.
|
// Create a TargetGlobalAddress node.
|
||||||
SDValue getTargetNode(GlobalAddressSDNode *N, EVT Ty, SelectionDAG &DAG,
|
SDValue getTargetNode(GlobalAddressSDNode *N, EVT Ty, SelectionDAG &DAG,
|
||||||
|
Loading…
Reference in New Issue
Block a user