1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

add MCInstLower support for lowering ARM::PICADD, a pseudo op for pic stuffola.

llvm-svn: 84553
This commit is contained in:
Chris Lattner 2009-10-19 22:23:04 +00:00
parent 06714a71a9
commit ce9e652b8a
3 changed files with 34 additions and 5 deletions

View File

@ -1313,6 +1313,7 @@ extern "C" void LLVMInitializeARMAsmPrinter() {
void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) { void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
ARMMCInstLower MCInstLowering(OutContext, *Mang, getFunctionNumber(), *MAI); ARMMCInstLower MCInstLowering(OutContext, *Mang, getFunctionNumber(), *MAI);
switch (MI->getOpcode()) { switch (MI->getOpcode()) {
default: break;
case TargetInstrInfo::DBG_LABEL: case TargetInstrInfo::DBG_LABEL:
case TargetInstrInfo::EH_LABEL: case TargetInstrInfo::EH_LABEL:
case TargetInstrInfo::GC_LABEL: case TargetInstrInfo::GC_LABEL:
@ -1327,7 +1328,29 @@ void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
case TargetInstrInfo::IMPLICIT_DEF: case TargetInstrInfo::IMPLICIT_DEF:
printImplicitDef(MI); printImplicitDef(MI);
return; 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; MCInst TmpInst;

View File

@ -157,3 +157,10 @@ void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum) {
} }
O << "}"; O << "}";
} }
void ARMInstPrinter::printPCLabel(const MCInst *MI, unsigned OpNum) {
// FIXME: remove this.
abort();
}

View File

@ -71,7 +71,6 @@ public:
void printPredicateOperand(const MCInst *MI, unsigned OpNum) {} void printPredicateOperand(const MCInst *MI, unsigned OpNum) {}
void printSBitModifierOperand(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 printRegisterList(const MCInst *MI, unsigned OpNum);
void printCPInstOperand(const MCInst *MI, unsigned OpNum, void printCPInstOperand(const MCInst *MI, unsigned OpNum,
const char *Modifier) {} const char *Modifier) {}
@ -80,8 +79,8 @@ public:
void printTBAddrMode(const MCInst *MI, unsigned OpNum) {} void printTBAddrMode(const MCInst *MI, unsigned OpNum) {}
void printNoHashImmediate(const MCInst *MI, unsigned OpNum) {} void printNoHashImmediate(const MCInst *MI, unsigned OpNum) {}
void printPCLabel(const MCInst *MI, unsigned OpNum);
// FIXME: // FIXME: Implement.
void PrintSpecial(const MCInst *MI, const char *Kind) {} void PrintSpecial(const MCInst *MI, const char *Kind) {}
}; };