diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index 4685c0e2e37..139477221a4 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -1313,6 +1313,7 @@ extern "C" void LLVMInitializeARMAsmPrinter() { void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) { ARMMCInstLower MCInstLowering(OutContext, *Mang, getFunctionNumber(), *MAI); switch (MI->getOpcode()) { + default: break; case TargetInstrInfo::DBG_LABEL: case TargetInstrInfo::EH_LABEL: case TargetInstrInfo::GC_LABEL: @@ -1327,7 +1328,29 @@ void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) { case TargetInstrInfo::IMPLICIT_DEF: printImplicitDef(MI); return; - default: break; + case ARM::PICADD: { // FIXME: Remove asm string from td file. + // This is a pseudo op for a label + instruction sequence, which looks like: + // LPC0: + // add r0, pc, r0 + // This adds the address of LPC0 to r0. + + // Emit the label. + // FIXME: MOVE TO SHARED PLACE. + SmallString<60> Name; + int Id = (int)MI->getOperand(2).getImm(); + raw_svector_ostream(Name) << MAI->getPrivateGlobalPrefix() << "PC" << Id; + OutStreamer.EmitLabel(OutContext.GetOrCreateSymbol(Name.str())); + + + // Form and emit tha dd. + MCInst AddInst; + AddInst.setOpcode(ARM::ADDrr); + AddInst.addOperand(MCOperand::CreateReg(MI->getOperand(0).getReg())); + AddInst.addOperand(MCOperand::CreateReg(ARM::PC)); + AddInst.addOperand(MCOperand::CreateReg(MI->getOperand(1).getReg())); + printMCInst(&AddInst); + return; + } } MCInst TmpInst; diff --git a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp index 6738bbf27ca..4d9c592e64b 100644 --- a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp @@ -157,3 +157,10 @@ void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum) { } O << "}"; } + + + +void ARMInstPrinter::printPCLabel(const MCInst *MI, unsigned OpNum) { + // FIXME: remove this. + abort(); +} diff --git a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h index 4f744c400cb..d4f6033152c 100644 --- a/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h +++ b/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h @@ -71,7 +71,6 @@ public: void printPredicateOperand(const MCInst *MI, unsigned OpNum) {} void printSBitModifierOperand(const MCInst *MI, unsigned OpNum) {} - void printPCLabel(const MCInst *MI, unsigned OpNum) {} void printRegisterList(const MCInst *MI, unsigned OpNum); void printCPInstOperand(const MCInst *MI, unsigned OpNum, const char *Modifier) {} @@ -79,9 +78,9 @@ public: void printJT2BlockOperand(const MCInst *MI, unsigned OpNum) {} void printTBAddrMode(const MCInst *MI, unsigned OpNum) {} void printNoHashImmediate(const MCInst *MI, unsigned OpNum) {} - - - // FIXME: + + void printPCLabel(const MCInst *MI, unsigned OpNum); + // FIXME: Implement. void PrintSpecial(const MCInst *MI, const char *Kind) {} };