diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:09:10 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2009-05-03 13:09:10 +0000 |
commit | 1deea5f3a7191eeeb076d81cc9647d0e661650df (patch) | |
tree | 3f8723a6b227b758804521b1016f18e01abcde29 /lib/Target | |
parent | 0eb6af40e3f7ea5949667bd90d5eb39df125e593 (diff) | |
download | external_llvm-1deea5f3a7191eeeb076d81cc9647d0e661650df.zip external_llvm-1deea5f3a7191eeeb076d81cc9647d0e661650df.tar.gz external_llvm-1deea5f3a7191eeeb076d81cc9647d0e661650df.tar.bz2 |
Correct asmprinting of memory operands
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70732 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/MSP430/MSP430AsmPrinter.cpp | 30 | ||||
-rw-r--r-- | lib/Target/MSP430/MSP430ISelDAGToDAG.cpp | 16 |
2 files changed, 25 insertions, 21 deletions
diff --git a/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp index a9a2711..fb64283 100644 --- a/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -162,17 +162,23 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum, void MSP430AsmPrinter::printSrcMemOperand(const MachineInstr *MI, int OpNum, const char* Modifier) { const MachineOperand &Disp = MI->getOperand(OpNum); - assert(Disp.isImm() && "Displacement can be only immediate!"); - - // Special case: 0(Reg) -> @Reg - if (Disp.getImm() == 0) { - O << "@"; - printOperand(MI, OpNum + 1); - } else { - printOperand(MI, OpNum, "nohash"); - O << '('; - printOperand(MI, OpNum + 1); - O << ')'; - } + const MachineOperand &Base = MI->getOperand(OpNum+1); + + if (Disp.isGlobal()) + printOperand(MI, OpNum, "mem"); + else if (Disp.isImm() && !Base.getReg()) + printOperand(MI, OpNum); + else if (Base.getReg()) { + if (Disp.getImm()) { + printOperand(MI, OpNum, "nohash"); + O << '('; + printOperand(MI, OpNum + 1); + O << ')'; + } else { + O << '@'; + printOperand(MI, OpNum + 1); + } + } else + assert(0 && "Unsupported memory operand"); } diff --git a/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp b/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp index e564e63..c057d69 100644 --- a/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp +++ b/lib/Target/MSP430/MSP430ISelDAGToDAG.cpp @@ -72,6 +72,7 @@ FunctionPass *llvm::createMSP430ISelDag(MSP430TargetMachine &TM) { return new MSP430DAGToDAGISel(TM); } +// FIXME: This is pretty dummy routine and needs to be rewritten in the future. bool MSP430DAGToDAGISel::SelectAddr(SDValue Op, SDValue Addr, SDValue &Disp, SDValue &Base) { // We don't support frame index stuff yet. @@ -99,20 +100,17 @@ bool MSP430DAGToDAGISel::SelectAddr(SDValue Op, SDValue Addr, case MSP430ISD::Wrapper: SDValue N0 = Addr.getOperand(0); if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(N0)) { - // We can match addresses of globals without any offsets - if (!G->getOffset()) { - Base = CurDAG->getTargetGlobalAddress(G->getGlobal(), - MVT::i16, 0); - Disp = CurDAG->getTargetConstant(0, MVT::i16); + Base = CurDAG->getRegister(0, MVT::i16); + Disp = CurDAG->getTargetGlobalAddress(G->getGlobal(), + MVT::i16, G->getOffset()); - return true; - } + return true; } break; }; - Base = Addr; - Disp = CurDAG->getTargetConstant(0, MVT::i16); + Base = CurDAG->getRegister(0, MVT::i16); + Disp = Addr; return true; } |