diff options
| author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-09-01 17:27:58 +0000 | 
|---|---|---|
| committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-09-01 17:27:58 +0000 | 
| commit | 0f20a5b338c403b93d359614746946c4ab5a4916 (patch) | |
| tree | 812ca071f6a26850d33252fbd159916e298da3bb /llvm/lib/Target/Mips/MipsISelLowering.cpp | |
| parent | d51896311d5b888a4cd38d3b713f0d954ebe545e (diff) | |
| download | bcm5719-llvm-0f20a5b338c403b93d359614746946c4ab5a4916.tar.gz bcm5719-llvm-0f20a5b338c403b93d359614746946c4ab5a4916.zip  | |
Reapply 80278
Add MO flags to simplify the printing of relocations.
Remove the support for printing large code model relocs (which
aren't supported anyway).
llvm-svn: 80691
Diffstat (limited to 'llvm/lib/Target/Mips/MipsISelLowering.cpp')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsISelLowering.cpp | 32 | 
1 files changed, 22 insertions, 10 deletions
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp index 710bc945ef2..8b84c51c356 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp @@ -488,7 +488,6 @@ SDValue MipsTargetLowering::LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) {    // FIXME there isn't actually debug info here    DebugLoc dl = Op.getDebugLoc();    GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal(); -  SDValue GA = DAG.getTargetGlobalAddress(GV, MVT::i32);    if (getTargetMachine().getRelocationModel() != Reloc::PIC_) {      SDVTList VTs = DAG.getVTList(MVT::i32); @@ -497,16 +496,22 @@ SDValue MipsTargetLowering::LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) {      // %gp_rel relocation      if (TLOF.IsGlobalInSmallSection(GV, getTargetMachine())) {  +      SDValue GA = DAG.getTargetGlobalAddress(GV, MVT::i32, 0,  +                                              MipsII::MO_GPREL);        SDValue GPRelNode = DAG.getNode(MipsISD::GPRel, dl, VTs, &GA, 1);        SDValue GOT = DAG.getGLOBAL_OFFSET_TABLE(MVT::i32);        return DAG.getNode(ISD::ADD, dl, MVT::i32, GOT, GPRelNode);       }      // %hi/%lo relocation +    SDValue GA = DAG.getTargetGlobalAddress(GV, MVT::i32, 0, +                                            MipsII::MO_ABS_HILO);      SDValue HiPart = DAG.getNode(MipsISD::Hi, dl, VTs, &GA, 1);      SDValue Lo = DAG.getNode(MipsISD::Lo, dl, MVT::i32, GA);      return DAG.getNode(ISD::ADD, dl, MVT::i32, HiPart, Lo); -  } else { // Abicall relocations, TODO: make this cleaner. +  } else { +    SDValue GA = DAG.getTargetGlobalAddress(GV, MVT::i32, 0, +                                            MipsII::MO_GOT);      SDValue ResNode = DAG.getLoad(MVT::i32, dl,                                     DAG.getEntryNode(), GA, NULL, 0);      // On functions and global targets not internal linked only @@ -535,15 +540,17 @@ LowerJumpTable(SDValue Op, SelectionDAG &DAG)    SDValue HiPart;     // FIXME there isn't actually debug info here    DebugLoc dl = Op.getDebugLoc(); +  bool IsPIC = getTargetMachine().getRelocationModel() == Reloc::PIC_; +  unsigned char OpFlag = IsPIC ? MipsII::MO_GOT : MipsII::MO_ABS_HILO;    EVT PtrVT = Op.getValueType();    JumpTableSDNode *JT  = cast<JumpTableSDNode>(Op); -  SDValue JTI = DAG.getTargetJumpTable(JT->getIndex(), PtrVT); -  if (getTargetMachine().getRelocationModel() != Reloc::PIC_) { -    SDVTList VTs = DAG.getVTList(MVT::i32); +  SDValue JTI = DAG.getTargetJumpTable(JT->getIndex(), PtrVT, OpFlag); + +  if (IsPIC) {      SDValue Ops[] = { JTI }; -    HiPart = DAG.getNode(MipsISD::Hi, dl, VTs, Ops, 1); +    HiPart = DAG.getNode(MipsISD::Hi, dl, DAG.getVTList(MVT::i32), Ops, 1);    } else // Emit Load from Global Pointer      HiPart = DAG.getLoad(MVT::i32, dl, DAG.getEntryNode(), JTI, NULL, 0); @@ -559,7 +566,8 @@ LowerConstantPool(SDValue Op, SelectionDAG &DAG)    SDValue ResNode;    ConstantPoolSDNode *N = cast<ConstantPoolSDNode>(Op);    Constant *C = N->getConstVal(); -  SDValue CP = DAG.getTargetConstantPool(C, MVT::i32, N->getAlignment()); +  SDValue CP = DAG.getTargetConstantPool(C, MVT::i32, N->getAlignment(),  +                                         MipsII::MO_ABS_HILO);    // FIXME there isn't actually debug info here    DebugLoc dl = Op.getDebugLoc(); @@ -684,6 +692,7 @@ MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,    MachineFunction &MF = DAG.getMachineFunction();    MachineFrameInfo *MFI = MF.getFrameInfo(); +  bool IsPIC = getTargetMachine().getRelocationModel() == Reloc::PIC_;    // Analyze operands of the call, assigning locations to each operand.    SmallVector<CCValAssign, 16> ArgLocs; @@ -792,10 +801,13 @@ MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,    // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every    // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol     // node so that legalize doesn't hack it.  +  unsigned char OpFlag = IsPIC ? MipsII::MO_GOT_CALL : MipsII::MO_NO_FLAG;    if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee))  -    Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy()); +    Callee = DAG.getTargetGlobalAddress(G->getGlobal(),  +                                getPointerTy(), 0, OpFlag);    else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) -    Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy()); +    Callee = DAG.getTargetExternalSymbol(S->getSymbol(),  +                                getPointerTy(), OpFlag);    // MipsJmpLink = #chain, #target_address, #opt_in_flags...    //             = Chain, Callee, Reg#1, Reg#2, ...   @@ -826,7 +838,7 @@ MipsTargetLowering::LowerCall(SDValue Chain, SDValue Callee,    // Create a stack location to hold GP when PIC is used. This stack     // location is used on function prologue to save GP and also after all     // emited CALL's to restore GP.  -  if (getTargetMachine().getRelocationModel() == Reloc::PIC_) { +  if (IsPIC) {        // Function can have an arbitrary number of calls, so         // hold the LastArgStackLoc with the biggest offset.        int FI;  | 

