mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Start using SwitchSection, allowing globals and functions to be emitted
to specific sections. Delete some dead functions copied from the X86 backend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24449 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7b6e53cde7
commit
4bfa3a3eb0
@ -46,33 +46,6 @@ namespace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isScale(const MachineOperand &MO) {
|
|
||||||
return MO.isImmediate() &&
|
|
||||||
(MO.getImmedValue() == 1 || MO.getImmedValue() == 2 ||
|
|
||||||
MO.getImmedValue() == 4 || MO.getImmedValue() == 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isMem(const MachineInstr *MI, unsigned Op) {
|
|
||||||
if (MI->getOperand(Op).isFrameIndex()) return true;
|
|
||||||
if (MI->getOperand(Op).isConstantPoolIndex()) return true;
|
|
||||||
return Op+4 <= MI->getNumOperands() &&
|
|
||||||
MI->getOperand(Op ).isRegister() && isScale(MI->getOperand(Op+1)) &&
|
|
||||||
MI->getOperand(Op+2).isRegister() && (MI->getOperand(Op+3).isImmediate() ||
|
|
||||||
MI->getOperand(Op+3).isGlobalAddress());
|
|
||||||
}
|
|
||||||
|
|
||||||
// switchSection - Switch to the specified section of the executable if we are
|
|
||||||
// not already in it!
|
|
||||||
//
|
|
||||||
static void switchSection(std::ostream &OS, std::string &CurSection,
|
|
||||||
const char *NewSection) {
|
|
||||||
if (CurSection != NewSection) {
|
|
||||||
CurSection = NewSection;
|
|
||||||
if (!CurSection.empty())
|
|
||||||
OS << "\t" << NewSection << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// printConstantPool - Print to the current output stream assembly
|
/// printConstantPool - Print to the current output stream assembly
|
||||||
/// representations of the constants in the constant pool MCP. This is
|
/// representations of the constants in the constant pool MCP. This is
|
||||||
/// used to print out constants which have been "spilled to memory" by
|
/// used to print out constants which have been "spilled to memory" by
|
||||||
@ -84,8 +57,8 @@ void IA64SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|||||||
|
|
||||||
if (CP.empty()) return;
|
if (CP.empty()) return;
|
||||||
|
|
||||||
O << "\n\t.section .data, \"aw\", \"progbits\"\n";
|
// FIXME: would be nice to have rodata (no 'w') when appropriate?
|
||||||
// FIXME: would be nice to have rodata (no 'w') when appropriate?
|
SwitchSection("\n\t.section .data, \"aw\", \"progbits\"\n", 0);
|
||||||
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
||||||
emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
|
emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
|
||||||
O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i
|
O << PrivateGlobalPrefix << "CPI" << CurrentFnName << "_" << i
|
||||||
@ -96,7 +69,6 @@ void IA64SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|||||||
|
|
||||||
bool IA64SharedAsmPrinter::doFinalization(Module &M) {
|
bool IA64SharedAsmPrinter::doFinalization(Module &M) {
|
||||||
const TargetData &TD = TM.getTargetData();
|
const TargetData &TD = TM.getTargetData();
|
||||||
std::string CurSection;
|
|
||||||
|
|
||||||
// Print out module-level global variables here.
|
// Print out module-level global variables here.
|
||||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||||
@ -111,7 +83,7 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
if (C->isNullValue() &&
|
if (C->isNullValue() &&
|
||||||
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
|
(I->hasLinkOnceLinkage() || I->hasInternalLinkage() ||
|
||||||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
|
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
|
||||||
switchSection(O, CurSection, ".data");
|
SwitchSection(".data", I);
|
||||||
if (I->hasInternalLinkage()) {
|
if (I->hasInternalLinkage()) {
|
||||||
O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType())
|
O << "\t.lcomm " << name << "," << TD.getTypeSize(C->getType())
|
||||||
<< "," << (1 << Align);
|
<< "," << (1 << Align);
|
||||||
@ -129,9 +101,9 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
|
case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
|
||||||
// Nonnull linkonce -> weak
|
// Nonnull linkonce -> weak
|
||||||
O << "\t.weak " << name << "\n";
|
O << "\t.weak " << name << "\n";
|
||||||
switchSection(O, CurSection, "");
|
|
||||||
O << "\t.section\t.llvm.linkonce.d." << name
|
O << "\t.section\t.llvm.linkonce.d." << name
|
||||||
<< ", \"aw\", \"progbits\"\n";
|
<< ", \"aw\", \"progbits\"\n";
|
||||||
|
SwitchSection("", I);
|
||||||
break;
|
break;
|
||||||
case GlobalValue::AppendingLinkage:
|
case GlobalValue::AppendingLinkage:
|
||||||
// FIXME: appending linkage variables should go into a section of
|
// FIXME: appending linkage variables should go into a section of
|
||||||
@ -141,10 +113,7 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
O << "\t.global " << name << "\n";
|
O << "\t.global " << name << "\n";
|
||||||
// FALL THROUGH
|
// FALL THROUGH
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
if (C->isNullValue())
|
SwitchSection(C->isNullValue() ? ".bss" : ".data", I);
|
||||||
switchSection(O, CurSection, ".bss");
|
|
||||||
else
|
|
||||||
switchSection(O, CurSection, ".data");
|
|
||||||
break;
|
break;
|
||||||
case GlobalValue::GhostLinkage:
|
case GlobalValue::GhostLinkage:
|
||||||
std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";
|
std::cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";
|
||||||
@ -298,8 +267,8 @@ bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
printConstantPool(MF.getConstantPool());
|
printConstantPool(MF.getConstantPool());
|
||||||
|
|
||||||
// Print out labels for the function.
|
// Print out labels for the function.
|
||||||
O << "\n\t.section .text, \"ax\", \"progbits\"\n";
|
SwitchSection("\n\t.section .text, \"ax\", \"progbits\"\n", MF.getFunction());
|
||||||
// ^^ means "Allocated instruXions in mem, initialized"
|
// ^^ means "Allocated instruXions in mem, initialized"
|
||||||
emitAlignment(5);
|
emitAlignment(5);
|
||||||
O << "\t.global\t" << CurrentFnName << "\n";
|
O << "\t.global\t" << CurrentFnName << "\n";
|
||||||
O << "\t.type\t" << CurrentFnName << ", @function\n";
|
O << "\t.type\t" << CurrentFnName << ", @function\n";
|
||||||
@ -413,7 +382,6 @@ void IA64AsmPrinter::printOp(const MachineOperand &MO,
|
|||||||
/// MI to the current output stream.
|
/// MI to the current output stream.
|
||||||
///
|
///
|
||||||
void IA64AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
void IA64AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
||||||
|
|
||||||
++EmittedInsts;
|
++EmittedInsts;
|
||||||
|
|
||||||
// Call the autogenerated instruction printer routines.
|
// Call the autogenerated instruction printer routines.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user