- void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
- const MachineOperand &MO = MI->getOperand(OpNo);
- if (TM.getRelocationModel() != Reloc::Static) {
- if (MO.getType() == MachineOperand::MO_GlobalAddress) {
- GlobalValue *GV = MO.getGlobal();
- if (((GV->isDeclaration() || GV->hasWeakLinkage() ||
- GV->hasLinkOnceLinkage() || GV->hasCommonLinkage()))) {
- // Dynamically-resolved functions need a stub for the function.
- std::string Name = Mang->getValueName(GV);
- FnStubs.insert(Name);
- printSuffixedName(Name, "$stub");
- if (GV->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(GV);
- return;
- }
- }
- if (MO.getType() == MachineOperand::MO_ExternalSymbol) {
- std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName();
- FnStubs.insert(Name);
- printSuffixedName(Name, "$stub");
- return;
- }
- }
-
- printOp(MI->getOperand(OpNo));
- }
- void printAbsAddrOperand(const MachineInstr *MI, unsigned OpNo) {
- O << (int)MI->getOperand(OpNo).getImm()*4;
- }
- void printPICLabel(const MachineInstr *MI, unsigned OpNo) {
- O << "\"L" << getFunctionNumber() << "$pb\"\n";
- O << "\"L" << getFunctionNumber() << "$pb\":";
- }
- void printSymbolHi(const MachineInstr *MI, unsigned OpNo) {
- if (MI->getOperand(OpNo).isImmediate()) {
- printS16ImmOperand(MI, OpNo);
- } else {
- if (Subtarget.isDarwin()) O << "ha16(";
- printOp(MI->getOperand(OpNo));
- if (TM.getRelocationModel() == Reloc::PIC_)
- O << "-\"L" << getFunctionNumber() << "$pb\"";
- if (Subtarget.isDarwin())
- O << ')';
- else
- O << "@ha";
- }
- }
- void printSymbolLo(const MachineInstr *MI, unsigned OpNo) {
- if (MI->getOperand(OpNo).isImmediate()) {
- printS16ImmOperand(MI, OpNo);
- } else {
- if (Subtarget.isDarwin()) O << "lo16(";
- printOp(MI->getOperand(OpNo));
- if (TM.getRelocationModel() == Reloc::PIC_)
- O << "-\"L" << getFunctionNumber() << "$pb\"";
- if (Subtarget.isDarwin())
- O << ')';
- else
- O << "@l";
- }
- }
- void printcrbitm(const MachineInstr *MI, unsigned OpNo) {
- unsigned CCReg = MI->getOperand(OpNo).getReg();
- unsigned RegNo = enumRegToMachineReg(CCReg);
- O << (0x80 >> RegNo);
- }
- // The new addressing mode printers.
- void printMemRegImm(const MachineInstr *MI, unsigned OpNo) {
- printSymbolLo(MI, OpNo);
- O << '(';
- if (MI->getOperand(OpNo+1).isRegister() &&
- MI->getOperand(OpNo+1).getReg() == PPC::R0)
- O << "0";
- else
- printOperand(MI, OpNo+1);
- O << ')';
- }
- void printMemRegImmShifted(const MachineInstr *MI, unsigned OpNo) {
- if (MI->getOperand(OpNo).isImmediate())
- printS16X4ImmOperand(MI, OpNo);
- else
- printSymbolLo(MI, OpNo);
- O << '(';
- if (MI->getOperand(OpNo+1).isRegister() &&
- MI->getOperand(OpNo+1).getReg() == PPC::R0)
- O << "0";
- else
- printOperand(MI, OpNo+1);
- O << ')';
- }
-
- void printMemRegReg(const MachineInstr *MI, unsigned OpNo) {
- // When used as the base register, r0 reads constant zero rather than
- // the value contained in the register. For this reason, the darwin
- // assembler requires that we print r0 as 0 (no r) when used as the base.
- const MachineOperand &MO = MI->getOperand(OpNo);
- printRegister(MO, true);
- O << ", ";
- printOperand(MI, OpNo+1);
- }
-
- void printPredicateOperand(const MachineInstr *MI, unsigned OpNo,
- const char *Modifier);
-
- virtual bool runOnMachineFunction(MachineFunction &F) = 0;
- virtual bool doFinalization(Module &M) = 0;
-
- virtual void EmitExternalGlobal(const GlobalVariable *GV);