mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 21:35:07 +00:00
Use the FunctionNumber provided by the AsmPrinter class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24462 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
77bc22866a
commit
0745536c00
@ -44,15 +44,11 @@ namespace {
|
|||||||
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
|
||||||
|
|
||||||
class PPCAsmPrinter : public AsmPrinter {
|
class PPCAsmPrinter : public AsmPrinter {
|
||||||
public:
|
public:
|
||||||
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
||||||
|
|
||||||
PPCAsmPrinter(std::ostream &O, TargetMachine &TM)
|
PPCAsmPrinter(std::ostream &O, TargetMachine &TM)
|
||||||
: AsmPrinter(O, TM), FunctionNumber(0) {}
|
: AsmPrinter(O, TM) {}
|
||||||
|
|
||||||
/// Unique incrementer for label values for referencing Global values.
|
|
||||||
///
|
|
||||||
unsigned FunctionNumber;
|
|
||||||
|
|
||||||
virtual const char *getPassName() const {
|
virtual const char *getPassName() const {
|
||||||
return "PowerPC Assembly Printer";
|
return "PowerPC Assembly Printer";
|
||||||
@ -163,8 +159,8 @@ namespace {
|
|||||||
void printPICLabel(const MachineInstr *MI, unsigned OpNo,
|
void printPICLabel(const MachineInstr *MI, unsigned OpNo,
|
||||||
MVT::ValueType VT) {
|
MVT::ValueType VT) {
|
||||||
// FIXME: should probably be converted to cout.width and cout.fill
|
// FIXME: should probably be converted to cout.width and cout.fill
|
||||||
O << "\"L0000" << FunctionNumber << "$pb\"\n";
|
O << "\"L0000" << getFunctionNumber() << "$pb\"\n";
|
||||||
O << "\"L0000" << FunctionNumber << "$pb\":";
|
O << "\"L0000" << getFunctionNumber() << "$pb\":";
|
||||||
}
|
}
|
||||||
void printSymbolHi(const MachineInstr *MI, unsigned OpNo,
|
void printSymbolHi(const MachineInstr *MI, unsigned OpNo,
|
||||||
MVT::ValueType VT) {
|
MVT::ValueType VT) {
|
||||||
@ -174,7 +170,7 @@ namespace {
|
|||||||
O << "ha16(";
|
O << "ha16(";
|
||||||
printOp(MI->getOperand(OpNo));
|
printOp(MI->getOperand(OpNo));
|
||||||
if (PICEnabled)
|
if (PICEnabled)
|
||||||
O << "-\"L0000" << FunctionNumber << "$pb\")";
|
O << "-\"L0000" << getFunctionNumber() << "$pb\")";
|
||||||
else
|
else
|
||||||
O << ')';
|
O << ')';
|
||||||
}
|
}
|
||||||
@ -187,7 +183,7 @@ namespace {
|
|||||||
O << "lo16(";
|
O << "lo16(";
|
||||||
printOp(MI->getOperand(OpNo));
|
printOp(MI->getOperand(OpNo));
|
||||||
if (PICEnabled)
|
if (PICEnabled)
|
||||||
O << "-\"L0000" << FunctionNumber << "$pb\")";
|
O << "-\"L0000" << getFunctionNumber() << "$pb\")";
|
||||||
else
|
else
|
||||||
O << ')';
|
O << ')';
|
||||||
}
|
}
|
||||||
@ -301,13 +297,13 @@ void PPCAsmPrinter::printOp(const MachineOperand &MO) {
|
|||||||
|
|
||||||
case MachineOperand::MO_MachineBasicBlock: {
|
case MachineOperand::MO_MachineBasicBlock: {
|
||||||
MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
|
MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
|
||||||
O << PrivateGlobalPrefix << "BB" << FunctionNumber << "_"
|
O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << "_"
|
||||||
<< MBBOp->getNumber() << "\t; " << MBBOp->getBasicBlock()->getName();
|
<< MBBOp->getNumber() << "\t; " << MBBOp->getBasicBlock()->getName();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
O << PrivateGlobalPrefix << "CPI" << FunctionNumber
|
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber()
|
||||||
<< '_' << MO.getConstantPoolIndex();
|
<< '_' << MO.getConstantPoolIndex();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -396,7 +392,7 @@ void PPCAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|||||||
if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
|
if (CP[i]->getType() == Type::DoubleTy && Alignment < 3) Alignment = 3;
|
||||||
|
|
||||||
EmitAlignment(Alignment);
|
EmitAlignment(Alignment);
|
||||||
O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
|
O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << '_' << i
|
||||||
<< ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
|
<< ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
|
||||||
EmitGlobalConstant(CP[i]);
|
EmitGlobalConstant(CP[i]);
|
||||||
}
|
}
|
||||||
@ -426,7 +422,7 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
// Print a label for the basic block.
|
// Print a label for the basic block.
|
||||||
if (I != MF.begin()) {
|
if (I != MF.begin()) {
|
||||||
O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_'
|
O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_'
|
||||||
<< I->getNumber() << ":\t";
|
<< I->getNumber() << ":\t";
|
||||||
if (!I->getBasicBlock()->getName().empty())
|
if (!I->getBasicBlock()->getName().empty())
|
||||||
O << CommentString << " " << I->getBasicBlock()->getName();
|
O << CommentString << " " << I->getBasicBlock()->getName();
|
||||||
@ -439,7 +435,6 @@ bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
printMachineInstruction(II);
|
printMachineInstruction(II);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++FunctionNumber;
|
|
||||||
|
|
||||||
// We didn't modify anything.
|
// We didn't modify anything.
|
||||||
return false;
|
return false;
|
||||||
@ -610,7 +605,8 @@ bool AIXAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
// Print a label for the basic block.
|
// Print a label for the basic block.
|
||||||
O << PrivateGlobalPrefix << "BB" << FunctionNumber << '_' << I->getNumber()
|
O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_'
|
||||||
|
<< I->getNumber()
|
||||||
<< ":\t" << CommentString << I->getBasicBlock()->getName() << '\n';
|
<< ":\t" << CommentString << I->getBasicBlock()->getName() << '\n';
|
||||||
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
|
||||||
II != E; ++II) {
|
II != E; ++II) {
|
||||||
@ -619,7 +615,6 @@ bool AIXAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
printMachineInstruction(II);
|
printMachineInstruction(II);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++FunctionNumber;
|
|
||||||
|
|
||||||
O << "LT.." << CurrentFnName << ":\n"
|
O << "LT.." << CurrentFnName << ":\n"
|
||||||
<< "\t.long 0\n"
|
<< "\t.long 0\n"
|
||||||
@ -669,14 +664,15 @@ bool AIXAsmPrinter::doInitialization(Module &M) {
|
|||||||
if (GV->isExternal() && GV->use_begin() == GV->use_end())
|
if (GV->isExternal() && GV->use_begin() == GV->use_end())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
IncrementFunctionNumber();
|
||||||
std::string Name = GV->getName();
|
std::string Name = GV->getName();
|
||||||
std::string Label = "LC.." + utostr(FunctionNumber++);
|
std::string Label = "LC.." + utostr(getFunctionNumber());
|
||||||
GVToLabelMap[GV] = Label;
|
GVToLabelMap[GV] = Label;
|
||||||
O << Label << ":\n"
|
O << Label << ":\n"
|
||||||
<< "\t.tc " << Name << "[TC]," << Name;
|
<< "\t.tc " << Name << "[TC]," << Name;
|
||||||
if (GV->isExternal()) O << "[RW]";
|
if (GV->isExternal()) O << "[RW]";
|
||||||
O << '\n';
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
AsmPrinter::doInitialization(M);
|
AsmPrinter::doInitialization(M);
|
||||||
return false; // success
|
return false; // success
|
||||||
|
Loading…
x
Reference in New Issue
Block a user