char AsmPrinter::ID = 0;
AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm,
const TargetAsmInfo *T)
- : MachineFunctionPass((intptr_t)&ID), O(o), TM(tm), TAI(T)
+ : MachineFunctionPass((intptr_t)&ID), FunctionNumber(0), O(o), TM(tm), TAI(T)
{}
std::string AsmPrinter::getSectionForFunction(const Function &F) const {
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
// What's my mangled name?
CurrentFnName = Mang->getValueName(MF.getFunction());
+ IncrementFunctionNumber();
}
/// EmitConstantPool - Print to the current output stream assembly
SwitchToDataSection(Section);
EmitAlignment(Alignment);
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
- O << TAI->getPrivateGlobalPrefix() << "CPI" << CP[i].second
- << '_' << CurrentFnName
- << ":\t\t\t\t\t" << TAI->getCommentString() << ' ';
+ O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_'
+ << CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << " ";
WriteTypeSymbolic(O, CP[i].first.getType(), 0) << '\n';
if (CP[i].first.isMachineConstantPoolEntry())
EmitMachineConstantPoolValue(CP[i].first.Val.MachineCPVal);
// the assembler and linker the extents of the jump table object. The
// second label is actually referenced by the code.
if (const char *JTLabelPrefix = TAI->getJumpTableSpecialLabelPrefix())
- O << JTLabelPrefix << "JTI" << i << '_' << CurrentFnName << ":\n";
+ O << JTLabelPrefix << "JTI" << getFunctionNumber() << '_' << i << ":\n";
- O << TAI->getPrivateGlobalPrefix() << "JTI" << i
- << '_' << CurrentFnName << ":\n";
+ O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
+ << '_' << i << ":\n";
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
O << JTEntryDirective << ' ';
// If we're emitting non-PIC code, then emit the entries as direct
// references to the target basic blocks.
if (!EmittedSets.empty()) {
- O << TAI->getPrivateGlobalPrefix() << i
- << '_' << "_set_" << JTBBs[ii]->getNumber() << '_' << CurrentFnName;
+ O << TAI->getPrivateGlobalPrefix() << getFunctionNumber()
+ << '_' << i << "_set_" << JTBBs[ii]->getNumber();
} else if (IsPic) {
printBasicBlockLabel(JTBBs[ii], false, false);
// If the arch uses custom Jump Table directives, don't calc relative to
// JT
if (!HadJTEntryDirective)
O << '-' << TAI->getPrivateGlobalPrefix() << "JTI"
- << i << '_' << CurrentFnName;
+ << getFunctionNumber() << '_' << i;
} else {
printBasicBlockLabel(JTBBs[ii], false, false);
}
void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
bool printColon,
bool printComment) const {
- O << TAI->getPrivateGlobalPrefix() << "BB" << MBB->getNumber() << '_'
- << CurrentFnName;
+ O << TAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << "_"
+ << MBB->getNumber();
if (printColon)
O << ':';
if (printComment && MBB->getBasicBlock())
return;
O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
- << uid << "_set_" << MBB->getNumber() << '_' << CurrentFnName << ',';
+ << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ',';
printBasicBlockLabel(MBB, false, false);
- O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << uid
- << '_' << CurrentFnName << '\n';
+ O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
+ << '_' << uid << '\n';
}
void AsmPrinter::printSetLabel(unsigned uid, unsigned uid2,
return;
O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix()
- << uid << '_' << uid2
- << "_set_" << MBB->getNumber() << '_' << CurrentFnName << ',';
+ << getFunctionNumber() << '_' << uid << '_' << uid2
+ << "_set_" << MBB->getNumber() << ',';
printBasicBlockLabel(MBB, false, false);
- O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << uid
- << '_' << uid2 << '_' << CurrentFnName << '\n';
+ O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
+ << '_' << uid << '_' << uid2 << '\n';
}
/// printDataDirective - This method prints the asm directive for the