mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-04 19:17:12 +00:00
Avoid unnecessary string construction during asm printing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@53215 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -351,6 +351,7 @@ namespace llvm {
|
|||||||
/// printSuffixedName - This prints a name with preceding
|
/// printSuffixedName - This prints a name with preceding
|
||||||
/// getPrivateGlobalPrefix and the specified suffix, handling quoted names
|
/// getPrivateGlobalPrefix and the specified suffix, handling quoted names
|
||||||
/// correctly.
|
/// correctly.
|
||||||
|
void printSuffixedName(const char *Name, const char* Suffix);
|
||||||
void printSuffixedName(std::string &Name, const char* Suffix);
|
void printSuffixedName(std::string &Name, const char* Suffix);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -1377,7 +1377,7 @@ void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
|
|||||||
O << ':';
|
O << ':';
|
||||||
if (printComment && MBB->getBasicBlock())
|
if (printComment && MBB->getBasicBlock())
|
||||||
O << '\t' << TAI->getCommentString() << ' '
|
O << '\t' << TAI->getCommentString() << ' '
|
||||||
<< MBB->getBasicBlock()->getName();
|
<< MBB->getBasicBlock()->getNameStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printPICJumpTableSetLabel - This method prints a set label for the
|
/// printPICJumpTableSetLabel - This method prints a set label for the
|
||||||
@@ -1445,10 +1445,14 @@ void AsmPrinter::printDataDirective(const Type *type) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::printSuffixedName(std::string &Name, const char* Suffix) {
|
void AsmPrinter::printSuffixedName(const char *Name, const char* Suffix) {
|
||||||
if (Name[0]=='\"')
|
if (Name[0]=='\"')
|
||||||
O << '\"' << TAI->getPrivateGlobalPrefix() <<
|
O << '\"' << TAI->getPrivateGlobalPrefix() <<
|
||||||
Name.substr(1, Name.length()-2) << Suffix << '\"';
|
Name[1] << Suffix << '\"';
|
||||||
else
|
else
|
||||||
O << TAI->getPrivateGlobalPrefix() << Name << Suffix;
|
O << TAI->getPrivateGlobalPrefix() << Name << Suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AsmPrinter::printSuffixedName(std::string &Name, const char* Suffix) {
|
||||||
|
printSuffixedName(Name.c_str(), Suffix);
|
||||||
|
}
|
||||||
|
@@ -974,6 +974,16 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
|||||||
EmitGlobalConstant(C);
|
EmitGlobalConstant(C);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// printGVStub - Print stub for a global value.
|
||||||
|
///
|
||||||
|
void X86ATTAsmPrinter::printGVStub(const char *GV, const char *Prefix) {
|
||||||
|
if (Prefix) O << Prefix;
|
||||||
|
printSuffixedName(GV, "$non_lazy_ptr");
|
||||||
|
O << ":\n\t.indirect_symbol ";
|
||||||
|
if (Prefix) O << Prefix;
|
||||||
|
O << GV << "\n\t.long\t0\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
||||||
// Print out module-level global variables here.
|
// Print out module-level global variables here.
|
||||||
@@ -1012,7 +1022,7 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
|||||||
i != e; ++i, ++j) {
|
i != e; ++i, ++j) {
|
||||||
SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
|
SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs,"
|
||||||
"self_modifying_code+pure_instructions,5", 0);
|
"self_modifying_code+pure_instructions,5", 0);
|
||||||
std::string p = i->getKeyData();
|
const char *p = i->getKeyData();
|
||||||
printSuffixedName(p, "$stub");
|
printSuffixedName(p, "$stub");
|
||||||
O << ":\n"
|
O << ":\n"
|
||||||
"\t.indirect_symbol " << p << "\n"
|
"\t.indirect_symbol " << p << "\n"
|
||||||
@@ -1021,28 +1031,32 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
|
|||||||
|
|
||||||
O << '\n';
|
O << '\n';
|
||||||
|
|
||||||
|
// Print global value stubs.
|
||||||
|
bool InStubSection = false;
|
||||||
if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
|
if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
|
||||||
// Add the (possibly multiple) personalities to the set of global values.
|
// Add the (possibly multiple) personalities to the set of global values.
|
||||||
// Only referenced functions get into the Personalities list.
|
// Only referenced functions get into the Personalities list.
|
||||||
const std::vector<Function *>& Personalities = MMI->getPersonalities();
|
const std::vector<Function *>& Personalities = MMI->getPersonalities();
|
||||||
|
|
||||||
for (std::vector<Function *>::const_iterator I = Personalities.begin(),
|
for (std::vector<Function *>::const_iterator I = Personalities.begin(),
|
||||||
E = Personalities.end(); I != E; ++I)
|
E = Personalities.end(); I != E; ++I) {
|
||||||
if (*I) GVStubs.insert('_' + (*I)->getName());
|
if (!*I)
|
||||||
|
continue;
|
||||||
|
if (!InStubSection) {
|
||||||
|
SwitchToDataSection(
|
||||||
|
"\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
|
||||||
|
InStubSection = true;
|
||||||
|
}
|
||||||
|
printGVStub((*I)->getNameStart(), "_");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Output stubs for external and common global variables.
|
// Output stubs for external and common global variables.
|
||||||
if (!GVStubs.empty())
|
if (!InStubSection && !GVStubs.empty())
|
||||||
SwitchToDataSection(
|
SwitchToDataSection(
|
||||||
"\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
|
"\t.section __IMPORT,__pointers,non_lazy_symbol_pointers");
|
||||||
for (StringSet<>::iterator i = GVStubs.begin(), e = GVStubs.end();
|
for (StringSet<>::iterator i = GVStubs.begin(), e = GVStubs.end();
|
||||||
i != e; ++i) {
|
i != e; ++i)
|
||||||
std::string p = i->getKeyData();
|
printGVStub(i->getKeyData());
|
||||||
printSuffixedName(p, "$non_lazy_ptr");
|
|
||||||
O << ":\n"
|
|
||||||
"\t.indirect_symbol " << p << "\n"
|
|
||||||
"\t.long\t0\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Emit final debug information.
|
// Emit final debug information.
|
||||||
DW.EndModule();
|
DW.EndModule();
|
||||||
|
@@ -120,6 +120,8 @@ struct VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {
|
|||||||
void printPICLabel(const MachineInstr *MI, unsigned Op);
|
void printPICLabel(const MachineInstr *MI, unsigned Op);
|
||||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||||
|
|
||||||
|
void printGVStub(const char *GV, const char *Prefix = NULL);
|
||||||
|
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
|
|
||||||
/// getSectionForFunction - Return the section that we should emit the
|
/// getSectionForFunction - Return the section that we should emit the
|
||||||
|
Reference in New Issue
Block a user