cl::init(8));
namespace {
- struct VISIBILITY_HIDDEN XCoreAsmPrinter : public AsmPrinter {
- XCoreAsmPrinter(raw_ostream &O, XCoreTargetMachine &TM,
- const TargetAsmInfo *T)
- : AsmPrinter(O, TM, T), DW(O, this, T),
- Subtarget(*TM.getSubtargetImpl()) { }
-
- DwarfWriter DW;
+ class VISIBILITY_HIDDEN XCoreAsmPrinter : public AsmPrinter {
+ DwarfWriter *DW;
const XCoreSubtarget &Subtarget;
+ public:
+ explicit XCoreAsmPrinter(raw_ostream &O, XCoreTargetMachine &TM,
+ const TargetAsmInfo *T, CodeGenOpt::Level OL,
+ bool V)
+ : AsmPrinter(O, TM, T, OL, V), DW(0),
+ Subtarget(*TM.getSubtargetImpl()) {}
virtual const char *getPassName() const {
return "XCore Assembly Printer";
AsmPrinter::getAnalysisUsage(AU);
AU.setPreservesAll();
AU.addRequired<MachineModuleInfo>();
+ AU.addRequired<DwarfWriter>();
}
};
} // end of anonymous namespace
/// regardless of whether the function is in SSA form.
///
FunctionPass *llvm::createXCoreCodePrinterPass(raw_ostream &o,
- XCoreTargetMachine &tm) {
- return new XCoreAsmPrinter(o, tm, tm.getTargetAsmInfo());
+ XCoreTargetMachine &tm,
+ CodeGenOpt::Level OptLevel,
+ bool verbose) {
+ return new XCoreAsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose);
}
// PrintEscapedString - Print each character of the specified string, escaping
case GlobalValue::AppendingLinkage:
cerr << "AppendingLinkage is not supported by this target!\n";
abort();
- case GlobalValue::LinkOnceLinkage:
- case GlobalValue::WeakLinkage:
+ case GlobalValue::LinkOnceAnyLinkage:
+ case GlobalValue::LinkOnceODRLinkage:
+ case GlobalValue::WeakAnyLinkage:
+ case GlobalValue::WeakODRLinkage:
case GlobalValue::ExternalLinkage:
emitArrayBound(name, GV);
emitGlobalDirective(name);
}
// FALL THROUGH
case GlobalValue::InternalLinkage:
+ case GlobalValue::PrivateLinkage:
break;
case GlobalValue::GhostLinkage:
cerr << "Should not have any unmaterialized functions!\n";
EmitAlignment(Align, GV, 2);
- unsigned Size = TD->getABITypeSize(C->getType());
+ unsigned Size = TD->getTypeAllocSize(C->getType());
if (GV->isThreadLocal()) {
Size *= MaxThreads;
}
switch (F->getLinkage()) {
default: assert(0 && "Unknown linkage type!");
case Function::InternalLinkage: // Symbols default to internal.
+ case Function::PrivateLinkage:
break;
case Function::ExternalLinkage:
emitGlobalDirective(CurrentFnName);
break;
- case Function::LinkOnceLinkage:
- case Function::WeakLinkage:
+ case Function::LinkOnceAnyLinkage:
+ case Function::LinkOnceODRLinkage:
+ case Function::WeakAnyLinkage:
+ case Function::WeakODRLinkage:
// TODO Use COMDAT groups for LinkOnceLinkage
O << TAI->getGlobalDirective() << CurrentFnName << "\n";
O << TAI->getWeakDefDirective() << CurrentFnName << "\n";
///
bool XCoreAsmPrinter::runOnMachineFunction(MachineFunction &MF)
{
+ this->MF = &MF;
+
SetupMachineFunction(MF);
// Print out constants referenced by the function
// Print out jump tables referenced by the function
EmitJumpTableInfo(MF.getJumpTableInfo(), MF);
- // What's my mangled name?
- CurrentFnName = Mang->getValueName(MF.getFunction());
-
// Emit the function start directives
emitFunctionStart(MF);
// Emit pre-function debug information.
- DW.BeginFunction(&MF);
+ DW->BeginFunction(&MF);
// Print out code for the function.
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
emitFunctionEnd(MF);
// Emit post-function debug information.
- DW.EndFunction(&MF);
+ DW->EndFunction(&MF);
// We didn't modify anything.
return false;
printBasicBlockLabel(MO.getMBB());
break;
case MachineOperand::MO_GlobalAddress:
- O << Mang->getValueName(MO.getGlobal());
- if (MO.getGlobal()->hasExternalWeakLinkage())
- ExtWeakSymbols.insert(MO.getGlobal());
+ {
+ const GlobalValue *GV = MO.getGlobal();
+ O << Mang->getValueName(GV);
+ if (GV->hasExternalWeakLinkage())
+ ExtWeakSymbols.insert(GV);
+ }
break;
case MachineOperand::MO_ExternalSymbol:
O << MO.getSymbolName();
++EmittedInsts;
// Check for mov mnemonic
- unsigned src, dst;
- if (TM.getInstrInfo()->isMoveInstr(*MI, src, dst)) {
+ unsigned src, dst, srcSR, dstSR;
+ if (TM.getInstrInfo()->isMoveInstr(*MI, src, dst, srcSR, dstSR)) {
O << "\tmov ";
O << TM.getRegisterInfo()->get(dst).AsmName;
O << ", ";
}
// Emit initial debug information.
- DW.BeginModule(&M);
-
- DW.SetModuleInfo(getAnalysisToUpdate<MachineModuleInfo>());
+ DW = getAnalysisIfAvailable<DwarfWriter>();
+ assert(DW && "Dwarf Writer is not available");
+ DW->BeginModule(&M, getAnalysisIfAvailable<MachineModuleInfo>(),
+ O, this, TAI);
return Result;
}
}
// Emit final debug information.
- DW.EndModule();
+ DW->EndModule();
return AsmPrinter::doFinalization(M);
}