diff options
Diffstat (limited to 'llvm/lib/Target/VE/VEAsmPrinter.cpp')
-rw-r--r-- | llvm/lib/Target/VE/VEAsmPrinter.cpp | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/llvm/lib/Target/VE/VEAsmPrinter.cpp b/llvm/lib/Target/VE/VEAsmPrinter.cpp index 86e3aa3d3fa1..08a75b6b8c55 100644 --- a/llvm/lib/Target/VE/VEAsmPrinter.cpp +++ b/llvm/lib/Target/VE/VEAsmPrinter.cpp @@ -60,6 +60,9 @@ public: static const char *getRegisterName(unsigned RegNo) { return VEInstPrinter::getRegisterName(RegNo); } + void printOperand(const MachineInstr *MI, int OpNum, raw_ostream &OS); + bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, + const char *ExtraCode, raw_ostream &O) override; }; } // end of anonymous namespace @@ -203,7 +206,7 @@ void VEAsmPrinter::lowerGETGOTAndEmitMCInsts(const MachineInstr *MI, // lea %got, _GLOBAL_OFFSET_TABLE_@PC_LO(-24) // and %got, %got, (32)0 // sic %plt - // lea.sl %got, _GLOBAL_OFFSET_TABLE_@PC_HI(%got, %plt) + // lea.sl %got, _GLOBAL_OFFSET_TABLE_@PC_HI(%plt, %got) MCOperand cim24 = MCOperand::createImm(-24); MCOperand loImm = createGOTRelExprOp(VEMCExpr::VK_VE_PC_LO32, GOTLabel, OutContext); @@ -248,10 +251,10 @@ void VEAsmPrinter::lowerGETFunPLTAndEmitMCInsts(const MachineInstr *MI, MCOperand RegPLT = MCOperand::createReg(VE::SX16); // PLT - // lea %dst, %plt_lo(func)(-24) + // lea %dst, func@plt_lo(-24) // and %dst, %dst, (32)0 // sic %plt ; FIXME: is it safe to use %plt here? - // lea.sl %dst, %plt_hi(func)(%dst, %plt) + // lea.sl %dst, func@plt_hi(%plt, %dst) MCOperand cim24 = MCOperand::createImm(-24); MCOperand loImm = createGOTRelExprOp(VEMCExpr::VK_VE_PLT_LO32, AddrSym, OutContext); @@ -295,7 +298,7 @@ void VEAsmPrinter::lowerGETTLSAddrAndEmitMCInsts(const MachineInstr *MI, // lea %s0, sym@tls_gd_lo(-24) // and %s0, %s0, (32)0 // sic %lr - // lea.sl %s0, sym@tls_gd_hi(%s0, %lr) + // lea.sl %s0, sym@tls_gd_hi(%lr, %s0) // lea %s12, __tls_get_addr@plt_lo(8) // and %s12, %s12, (32)0 // lea.sl %s12, __tls_get_addr@plt_hi(%s12, %lr) @@ -349,7 +352,42 @@ void VEAsmPrinter::emitInstruction(const MachineInstr *MI) { } while ((++I != E) && I->isInsideBundle()); // Delay slot check. } +void VEAsmPrinter::printOperand(const MachineInstr *MI, int OpNum, + raw_ostream &O) { + const MachineOperand &MO = MI->getOperand(OpNum); + + switch (MO.getType()) { + case MachineOperand::MO_Register: + O << "%" << StringRef(getRegisterName(MO.getReg())).lower(); + break; + default: + llvm_unreachable("<unknown operand type>"); + } +} + +// PrintAsmOperand - Print out an operand for an inline asm expression. +bool VEAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, + const char *ExtraCode, raw_ostream &O) { + if (ExtraCode && ExtraCode[0]) { + if (ExtraCode[1] != 0) + return true; // Unknown modifier. + + switch (ExtraCode[0]) { + default: + // See if this is a generic print operand + return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, O); + case 'r': + case 'v': + break; + } + } + + printOperand(MI, OpNo, O); + + return false; +} + // Force static initialization. -extern "C" void LLVMInitializeVEAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeVEAsmPrinter() { RegisterAsmPrinter<VEAsmPrinter> X(getTheVETarget()); } |