mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-26 09:18:56 +00:00
Increment the label number in runOnFunction() rather than while printing out
some instruction. Patch by Nate Begeman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15236 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -56,8 +56,8 @@ namespace {
|
|||||||
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
||||||
std::set<std::string> Strings;
|
std::set<std::string> Strings;
|
||||||
|
|
||||||
Printer(std::ostream &o, TargetMachine &tm) : O(o),
|
Printer(std::ostream &o, TargetMachine &tm) : O(o),
|
||||||
TM(reinterpret_cast<PowerPCTargetMachine&>(tm)), labelNumber(0) { }
|
TM(reinterpret_cast<PowerPCTargetMachine&>(tm)), LabelNumber(0) {}
|
||||||
|
|
||||||
/// Cache of mangled name for current function. This is
|
/// Cache of mangled name for current function. This is
|
||||||
/// recalculated at the beginning of each call to
|
/// recalculated at the beginning of each call to
|
||||||
@@ -65,11 +65,10 @@ namespace {
|
|||||||
///
|
///
|
||||||
std::string CurrentFnName;
|
std::string CurrentFnName;
|
||||||
|
|
||||||
/// Unique incrementer for label values for referencing
|
/// Unique incrementer for label values for referencing Global values.
|
||||||
/// Global values.
|
|
||||||
///
|
///
|
||||||
unsigned int labelNumber;
|
unsigned LabelNumber;
|
||||||
|
|
||||||
virtual const char *getPassName() const {
|
virtual const char *getPassName() const {
|
||||||
return "PowerPC Assembly Printer";
|
return "PowerPC Assembly Printer";
|
||||||
}
|
}
|
||||||
@@ -396,6 +395,7 @@ bool Printer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
printMachineInstruction(II);
|
printMachineInstruction(II);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++LabelNumber;
|
||||||
|
|
||||||
// We didn't modify anything.
|
// We didn't modify anything.
|
||||||
return false;
|
return false;
|
||||||
@@ -526,8 +526,8 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
return;
|
return;
|
||||||
} else if (Opcode == PPC32::MovePCtoLR) {
|
} else if (Opcode == PPC32::MovePCtoLR) {
|
||||||
// FIXME: should probably be converted to cout.width and cout.fill
|
// FIXME: should probably be converted to cout.width and cout.fill
|
||||||
O << "bl \"L0000" << labelNumber << "$pb\"\n";
|
O << "bl \"L0000" << LabelNumber << "$pb\"\n";
|
||||||
O << "\"L0000" << labelNumber << "$pb\":\n";
|
O << "\"L0000" << LabelNumber << "$pb\":\n";
|
||||||
O << "\tmflr ";
|
O << "\tmflr ";
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << "\n";
|
O << "\n";
|
||||||
@@ -539,8 +539,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << ", lo16(";
|
O << ", lo16(";
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2));
|
||||||
O << "-\"L0000" << labelNumber << "$pb\")";
|
O << "-\"L0000" << LabelNumber << "$pb\")";
|
||||||
labelNumber++;
|
|
||||||
O << "(";
|
O << "(";
|
||||||
if (MI->getOperand(1).getReg() == PPC32::R0)
|
if (MI->getOperand(1).getReg() == PPC32::R0)
|
||||||
O << "0";
|
O << "0";
|
||||||
@@ -556,7 +555,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
printOp(MI->getOperand(1));
|
printOp(MI->getOperand(1));
|
||||||
O << ", ha16(" ;
|
O << ", ha16(" ;
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2));
|
||||||
O << "-\"L0000" << labelNumber << "$pb\")\n";
|
O << "-\"L0000" << LabelNumber << "$pb\")\n";
|
||||||
} else if (ArgCount == 3 && ArgType[1] == PPC32II::Disimm16) {
|
} else if (ArgCount == 3 && ArgType[1] == PPC32II::Disimm16) {
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << ", ";
|
O << ", ";
|
||||||
|
@@ -56,8 +56,8 @@ namespace {
|
|||||||
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
||||||
std::set<std::string> Strings;
|
std::set<std::string> Strings;
|
||||||
|
|
||||||
Printer(std::ostream &o, TargetMachine &tm) : O(o),
|
Printer(std::ostream &o, TargetMachine &tm) : O(o),
|
||||||
TM(reinterpret_cast<PowerPCTargetMachine&>(tm)), labelNumber(0) { }
|
TM(reinterpret_cast<PowerPCTargetMachine&>(tm)), LabelNumber(0) {}
|
||||||
|
|
||||||
/// Cache of mangled name for current function. This is
|
/// Cache of mangled name for current function. This is
|
||||||
/// recalculated at the beginning of each call to
|
/// recalculated at the beginning of each call to
|
||||||
@@ -65,11 +65,10 @@ namespace {
|
|||||||
///
|
///
|
||||||
std::string CurrentFnName;
|
std::string CurrentFnName;
|
||||||
|
|
||||||
/// Unique incrementer for label values for referencing
|
/// Unique incrementer for label values for referencing Global values.
|
||||||
/// Global values.
|
|
||||||
///
|
///
|
||||||
unsigned int labelNumber;
|
unsigned LabelNumber;
|
||||||
|
|
||||||
virtual const char *getPassName() const {
|
virtual const char *getPassName() const {
|
||||||
return "PowerPC Assembly Printer";
|
return "PowerPC Assembly Printer";
|
||||||
}
|
}
|
||||||
@@ -396,6 +395,7 @@ bool Printer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
printMachineInstruction(II);
|
printMachineInstruction(II);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++LabelNumber;
|
||||||
|
|
||||||
// We didn't modify anything.
|
// We didn't modify anything.
|
||||||
return false;
|
return false;
|
||||||
@@ -526,8 +526,8 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
return;
|
return;
|
||||||
} else if (Opcode == PPC32::MovePCtoLR) {
|
} else if (Opcode == PPC32::MovePCtoLR) {
|
||||||
// FIXME: should probably be converted to cout.width and cout.fill
|
// FIXME: should probably be converted to cout.width and cout.fill
|
||||||
O << "bl \"L0000" << labelNumber << "$pb\"\n";
|
O << "bl \"L0000" << LabelNumber << "$pb\"\n";
|
||||||
O << "\"L0000" << labelNumber << "$pb\":\n";
|
O << "\"L0000" << LabelNumber << "$pb\":\n";
|
||||||
O << "\tmflr ";
|
O << "\tmflr ";
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << "\n";
|
O << "\n";
|
||||||
@@ -539,8 +539,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << ", lo16(";
|
O << ", lo16(";
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2));
|
||||||
O << "-\"L0000" << labelNumber << "$pb\")";
|
O << "-\"L0000" << LabelNumber << "$pb\")";
|
||||||
labelNumber++;
|
|
||||||
O << "(";
|
O << "(";
|
||||||
if (MI->getOperand(1).getReg() == PPC32::R0)
|
if (MI->getOperand(1).getReg() == PPC32::R0)
|
||||||
O << "0";
|
O << "0";
|
||||||
@@ -556,7 +555,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
printOp(MI->getOperand(1));
|
printOp(MI->getOperand(1));
|
||||||
O << ", ha16(" ;
|
O << ", ha16(" ;
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2));
|
||||||
O << "-\"L0000" << labelNumber << "$pb\")\n";
|
O << "-\"L0000" << LabelNumber << "$pb\")\n";
|
||||||
} else if (ArgCount == 3 && ArgType[1] == PPC32II::Disimm16) {
|
} else if (ArgCount == 3 && ArgType[1] == PPC32II::Disimm16) {
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << ", ";
|
O << ", ";
|
||||||
|
@@ -56,8 +56,8 @@ namespace {
|
|||||||
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
|
||||||
std::set<std::string> Strings;
|
std::set<std::string> Strings;
|
||||||
|
|
||||||
Printer(std::ostream &o, TargetMachine &tm) : O(o),
|
Printer(std::ostream &o, TargetMachine &tm) : O(o),
|
||||||
TM(reinterpret_cast<PowerPCTargetMachine&>(tm)), labelNumber(0) { }
|
TM(reinterpret_cast<PowerPCTargetMachine&>(tm)), LabelNumber(0) {}
|
||||||
|
|
||||||
/// Cache of mangled name for current function. This is
|
/// Cache of mangled name for current function. This is
|
||||||
/// recalculated at the beginning of each call to
|
/// recalculated at the beginning of each call to
|
||||||
@@ -65,11 +65,10 @@ namespace {
|
|||||||
///
|
///
|
||||||
std::string CurrentFnName;
|
std::string CurrentFnName;
|
||||||
|
|
||||||
/// Unique incrementer for label values for referencing
|
/// Unique incrementer for label values for referencing Global values.
|
||||||
/// Global values.
|
|
||||||
///
|
///
|
||||||
unsigned int labelNumber;
|
unsigned LabelNumber;
|
||||||
|
|
||||||
virtual const char *getPassName() const {
|
virtual const char *getPassName() const {
|
||||||
return "PowerPC Assembly Printer";
|
return "PowerPC Assembly Printer";
|
||||||
}
|
}
|
||||||
@@ -396,6 +395,7 @@ bool Printer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
printMachineInstruction(II);
|
printMachineInstruction(II);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
++LabelNumber;
|
||||||
|
|
||||||
// We didn't modify anything.
|
// We didn't modify anything.
|
||||||
return false;
|
return false;
|
||||||
@@ -526,8 +526,8 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
return;
|
return;
|
||||||
} else if (Opcode == PPC32::MovePCtoLR) {
|
} else if (Opcode == PPC32::MovePCtoLR) {
|
||||||
// FIXME: should probably be converted to cout.width and cout.fill
|
// FIXME: should probably be converted to cout.width and cout.fill
|
||||||
O << "bl \"L0000" << labelNumber << "$pb\"\n";
|
O << "bl \"L0000" << LabelNumber << "$pb\"\n";
|
||||||
O << "\"L0000" << labelNumber << "$pb\":\n";
|
O << "\"L0000" << LabelNumber << "$pb\":\n";
|
||||||
O << "\tmflr ";
|
O << "\tmflr ";
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << "\n";
|
O << "\n";
|
||||||
@@ -539,8 +539,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << ", lo16(";
|
O << ", lo16(";
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2));
|
||||||
O << "-\"L0000" << labelNumber << "$pb\")";
|
O << "-\"L0000" << LabelNumber << "$pb\")";
|
||||||
labelNumber++;
|
|
||||||
O << "(";
|
O << "(";
|
||||||
if (MI->getOperand(1).getReg() == PPC32::R0)
|
if (MI->getOperand(1).getReg() == PPC32::R0)
|
||||||
O << "0";
|
O << "0";
|
||||||
@@ -556,7 +555,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
printOp(MI->getOperand(1));
|
printOp(MI->getOperand(1));
|
||||||
O << ", ha16(" ;
|
O << ", ha16(" ;
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2));
|
||||||
O << "-\"L0000" << labelNumber << "$pb\")\n";
|
O << "-\"L0000" << LabelNumber << "$pb\")\n";
|
||||||
} else if (ArgCount == 3 && ArgType[1] == PPC32II::Disimm16) {
|
} else if (ArgCount == 3 && ArgType[1] == PPC32II::Disimm16) {
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << ", ";
|
O << ", ";
|
||||||
|
Reference in New Issue
Block a user