bool printInstruction(const MachineInstr *MI);
void printMachineInstruction(const MachineInstr *MI);
- void printOp(const MachineOperand &MO, bool IsCallOp = false);
+ void printOp(const MachineOperand &MO);
void printOperand(const MachineInstr *MI, unsigned OpNo, MVT::ValueType VT){
const MachineOperand &MO = MI->getOperand(OpNo);
if (MI->getOperand(OpNo).isImmediate()) {
O << "$+" << MI->getOperand(OpNo).getImmedValue();
} else {
- printOp(MI->getOperand(OpNo),
- TM.getInstrInfo()->isCall(MI->getOpcode()));
+ printOp(MI->getOperand(OpNo));
+ }
+ }
+ void printCallOperand(const MachineInstr *MI, unsigned OpNo,
+ MVT::ValueType VT) {
+ const MachineOperand &MO = MI->getOperand(OpNo);
+ if (MO.getType() == MachineOperand::MO_ExternalSymbol) {
+ std::string Name(GlobalPrefix); Name += MO.getSymbolName();
+ FnStubs.insert(Name);
+ O << "L" << Name << "$stub";
+ } else if (MO.getType() == MachineOperand::MO_GlobalAddress &&
+ isa<Function>(MO.getGlobal()) &&
+ cast<Function>(MO.getGlobal())->isExternal()) {
+ // Dynamically-resolved functions need a stub for the function.
+ std::string Name = Mang->getValueName(MO.getGlobal());
+ FnStubs.insert(Name);
+ O << "L" << Name << "$stub";
+ } else {
+ printOp(MI->getOperand(OpNo));
}
}
+ void printAbsAddrOperand(const MachineInstr *MI, unsigned OpNo,
+ MVT::ValueType VT) {
+ O << (int)MI->getOperand(OpNo).getImmedValue()*4;
+ }
void printPICLabel(const MachineInstr *MI, unsigned OpNo,
MVT::ValueType VT) {
// FIXME: should probably be converted to cout.width and cout.fill
// Include the auto-generated portion of the assembly writer
#include "PPCGenAsmWriter.inc"
-void PPCAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
+void PPCAsmPrinter::printOp(const MachineOperand &MO) {
const MRegisterInfo &RI = *TM.getRegisterInfo();
int new_symbol;
return;
case MachineOperand::MO_ExternalSymbol:
- if (IsCallOp) {
- std::string Name(GlobalPrefix); Name += MO.getSymbolName();
- FnStubs.insert(Name);
- O << "L" << Name << "$stub";
- return;
- }
O << GlobalPrefix << MO.getSymbolName();
return;
GlobalValue *GV = MO.getGlobal();
std::string Name = Mang->getValueName(GV);
- // Dynamically-resolved functions need a stub for the function. Be
- // wary however not to output $stub for external functions whose addresses
- // are taken. Those should be emitted as $non_lazy_ptr below.
- Function *F = dyn_cast<Function>(GV);
- if (F && IsCallOp && F->isExternal()) {
- FnStubs.insert(Name);
- O << "L" << Name << "$stub";
- return;
- }
-
// External or weakly linked global variables need non-lazily-resolved stubs
if ((GV->isExternal() || GV->hasWeakLinkage() || GV->hasLinkOnceLinkage())){
if (GV->hasLinkOnceLinkage())
if (CP.empty()) return;
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
- O << "\t.const\n";
+ SwitchSection(".const", 0);
// FIXME: force doubles to be naturally aligned. We should handle this
// more correctly in the future.
if (Type::DoubleTy == CP[i]->getType())
} else {
switch (I->getLinkage()) {
case GlobalValue::LinkOnceLinkage:
+ SwitchSection("", 0);
O << ".section __TEXT,__textcoal_nt,coalesced,no_toc\n"
<< ".weak_definition " << name << '\n'
<< ".private_extern " << name << '\n'
if (CP.empty()) return;
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
- O << "\t.const\n";
+ SwitchSection(".const", 0);
O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
<< "\n";
O << "LCPI" << FunctionNumber << '_' << i << ":\t\t\t\t\t;"