mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-29 22:52:18 +00:00
Properly handle ExternalSymbol's
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8725bd22bf
commit
5d59f68ade
@ -155,6 +155,15 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||
|
||||
return;
|
||||
}
|
||||
case MachineOperand::MO_ExternalSymbol: {
|
||||
bool isCallOp = Modifier && !strcmp(Modifier, "call");
|
||||
std::string Name(TAI->getGlobalPrefix());
|
||||
Name += MO.getSymbolName();
|
||||
if (isCallOp)
|
||||
O << '#';
|
||||
O << Name;
|
||||
return;
|
||||
}
|
||||
default:
|
||||
assert(0 && "Not implemented yet!");
|
||||
}
|
||||
|
@ -107,6 +107,9 @@ bool MSP430DAGToDAGISel::SelectAddr(SDValue Op, SDValue Addr,
|
||||
MVT::i16, G->getOffset());
|
||||
Disp = CurDAG->getTargetConstant(0, MVT::i16);
|
||||
return true;
|
||||
} else if (ExternalSymbolSDNode *E = dyn_cast<ExternalSymbolSDNode>(N0)) {
|
||||
Base = CurDAG->getTargetExternalSymbol(E->getSymbol(), MVT::i16);
|
||||
Disp = CurDAG->getTargetConstant(0, MVT::i16);
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
@ -71,6 +71,7 @@ MSP430TargetLowering::MSP430TargetLowering(MSP430TargetMachine &tm) :
|
||||
setOperationAction(ISD::SHL, MVT::i16, Custom);
|
||||
setOperationAction(ISD::RET, MVT::Other, Custom);
|
||||
setOperationAction(ISD::GlobalAddress, MVT::i16, Custom);
|
||||
setOperationAction(ISD::ExternalSymbol, MVT::i16, Custom);
|
||||
setOperationAction(ISD::BR_CC, MVT::Other, Expand);
|
||||
setOperationAction(ISD::BRCOND, MVT::Other, Custom);
|
||||
setOperationAction(ISD::SETCC, MVT::i8, Custom);
|
||||
@ -95,6 +96,7 @@ SDValue MSP430TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) {
|
||||
case ISD::RET: return LowerRET(Op, DAG);
|
||||
case ISD::CALL: return LowerCALL(Op, DAG);
|
||||
case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG);
|
||||
case ISD::ExternalSymbol: return LowerExternalSymbol(Op, DAG);
|
||||
case ISD::SETCC: return LowerSETCC(Op, DAG);
|
||||
case ISD::BRCOND: return LowerBRCOND(Op, DAG);
|
||||
case ISD::SELECT: return LowerSELECT(Op, DAG);
|
||||
@ -459,6 +461,16 @@ SDValue MSP430TargetLowering::LowerGlobalAddress(SDValue Op, SelectionDAG &DAG)
|
||||
getPointerTy(), Result);
|
||||
}
|
||||
|
||||
SDValue MSP430TargetLowering::LowerExternalSymbol(SDValue Op,
|
||||
SelectionDAG &DAG) {
|
||||
DebugLoc dl = Op.getDebugLoc();
|
||||
const char *Sym = cast<ExternalSymbolSDNode>(Op)->getSymbol();
|
||||
SDValue Result = DAG.getTargetExternalSymbol(Sym, getPointerTy());
|
||||
|
||||
return DAG.getNode(MSP430ISD::Wrapper, dl, getPointerTy(), Result);;
|
||||
}
|
||||
|
||||
|
||||
MVT MSP430TargetLowering::getSetCCResultType(MVT VT) const {
|
||||
return MVT::i8;
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ namespace llvm {
|
||||
SDValue LowerCCCArguments(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerShifts(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerBRCOND(SDValue Op, SelectionDAG &DAG);
|
||||
SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG);
|
||||
|
@ -718,15 +718,25 @@ def : Pat<(extloadi16i8 addr:$src), (MOVZX16rm8 addr:$src)>;
|
||||
def : Pat<(i8 (trunc GR16:$src)),
|
||||
(EXTRACT_SUBREG GR16:$src, subreg_8bit)>;
|
||||
|
||||
// GlobalAddress
|
||||
// GlobalAddress, ExternalSymbol
|
||||
def : Pat<(i16 (MSP430Wrapper tglobaladdr:$dst)), (MOV16ri tglobaladdr:$dst)>;
|
||||
def : Pat<(i16 (MSP430Wrapper texternalsym:$dst)), (MOV16ri texternalsym:$dst)>;
|
||||
|
||||
def : Pat<(add GR16:$src1, (MSP430Wrapper tglobaladdr :$src2)),
|
||||
(ADD16ri GR16:$src1, tglobaladdr:$src2)>;
|
||||
def : Pat<(add GR16:$src1, (MSP430Wrapper texternalsym:$src2)),
|
||||
(ADD16ri GR16:$src1, texternalsym:$src2)>;
|
||||
|
||||
def : Pat<(store (i16 (MSP430Wrapper tglobaladdr:$src)), addr:$dst),
|
||||
(MOV16mi addr:$dst, tglobaladdr:$src)>;
|
||||
def : Pat<(store (i16 (MSP430Wrapper texternalsym:$src)), addr:$dst),
|
||||
(MOV16mi addr:$dst, texternalsym:$src)>;
|
||||
|
||||
// calls
|
||||
def : Pat<(MSP430call (i16 tglobaladdr:$dst)),
|
||||
(CALLi tglobaladdr:$dst)>;
|
||||
def : Pat<(MSP430call (i16 texternalsym:$dst)),
|
||||
(CALLi texternalsym:$dst)>;
|
||||
|
||||
// add and sub always produce carry
|
||||
def : Pat<(addc GR16:$src1, GR16:$src2),
|
||||
|
Loading…
x
Reference in New Issue
Block a user