mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 00:21:03 +00:00
Switch Alpha to new section handling stuff
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54457 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -46,6 +46,7 @@ namespace {
|
|||||||
void printOp(const MachineOperand &MO, bool IsCallOp = false);
|
void printOp(const MachineOperand &MO, bool IsCallOp = false);
|
||||||
void printOperand(const MachineInstr *MI, int opNum);
|
void printOperand(const MachineInstr *MI, int opNum);
|
||||||
void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true);
|
void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true);
|
||||||
|
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
bool doInitialization(Module &M);
|
bool doInitialization(Module &M);
|
||||||
bool doFinalization(Module &M);
|
bool doFinalization(Module &M);
|
||||||
@@ -201,28 +202,30 @@ bool AlphaAsmPrinter::doInitialization(Module &M)
|
|||||||
return AsmPrinter::doInitialization(M);
|
return AsmPrinter::doInitialization(M);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AlphaAsmPrinter::doFinalization(Module &M) {
|
void AlphaAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||||
const TargetData *TD = TM.getTargetData();
|
const TargetData *TD = TM.getTargetData();
|
||||||
|
|
||||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) {
|
if (!GVar->hasInitializer()) return; // External global require no code
|
||||||
|
|
||||||
if (!I->hasInitializer()) continue; // External global require no code
|
|
||||||
|
|
||||||
// Check to see if this is a special global used by LLVM, if so, emit it.
|
// Check to see if this is a special global used by LLVM, if so, emit it.
|
||||||
if (EmitSpecialLLVMGlobal(I))
|
if (EmitSpecialLLVMGlobal(GVar))
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
std::string name = Mang->getValueName(I);
|
std::string SectionName = TAI->SectionForGlobal(GVar);
|
||||||
Constant *C = I->getInitializer();
|
std::string name = Mang->getValueName(GVar);
|
||||||
|
Constant *C = GVar->getInitializer();
|
||||||
unsigned Size = TD->getABITypeSize(C->getType());
|
unsigned Size = TD->getABITypeSize(C->getType());
|
||||||
unsigned Align = TD->getPreferredAlignmentLog(I);
|
unsigned Align = TD->getPreferredAlignmentLog(GVar);
|
||||||
|
|
||||||
//1: hidden?
|
// 0: Switch to section
|
||||||
if (I->hasHiddenVisibility())
|
SwitchToDataSection(SectionName.c_str());
|
||||||
|
|
||||||
|
// 1: Check visibility
|
||||||
|
if (GVar->hasHiddenVisibility())
|
||||||
O << TAI->getHiddenDirective() << name << "\n";
|
O << TAI->getHiddenDirective() << name << "\n";
|
||||||
|
|
||||||
//2: kind
|
// 2: Kind
|
||||||
switch (I->getLinkage()) {
|
switch (GVar->getLinkage()) {
|
||||||
case GlobalValue::LinkOnceLinkage:
|
case GlobalValue::LinkOnceLinkage:
|
||||||
case GlobalValue::WeakLinkage:
|
case GlobalValue::WeakLinkage:
|
||||||
case GlobalValue::CommonLinkage:
|
case GlobalValue::CommonLinkage:
|
||||||
@@ -230,7 +233,7 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
|
|||||||
break;
|
break;
|
||||||
case GlobalValue::AppendingLinkage:
|
case GlobalValue::AppendingLinkage:
|
||||||
case GlobalValue::ExternalLinkage:
|
case GlobalValue::ExternalLinkage:
|
||||||
O << "\t.globl " << name << "\n";
|
O << TAI->getGlobalDirective() << name << "\n";
|
||||||
break;
|
break;
|
||||||
case GlobalValue::InternalLinkage:
|
case GlobalValue::InternalLinkage:
|
||||||
break;
|
break;
|
||||||
@@ -240,24 +243,13 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
//3: Section (if changed)
|
// 3: Type, Size, Align
|
||||||
if (I->hasSection() &&
|
if (TAI->hasDotTypeDotSizeDirective()) {
|
||||||
(I->getSection() == ".ctors" ||
|
|
||||||
I->getSection() == ".dtors")) {
|
|
||||||
std::string SectionName = ".section\t" + I->getSection()
|
|
||||||
+ ",\"aw\",@progbits";
|
|
||||||
SwitchToDataSection(SectionName.c_str());
|
|
||||||
} else {
|
|
||||||
if (C->isNullValue())
|
|
||||||
SwitchToDataSection("\t.section\t.bss", I);
|
|
||||||
else
|
|
||||||
SwitchToDataSection("\t.section\t.data", I);
|
|
||||||
}
|
|
||||||
|
|
||||||
//4: Type, Size, Align
|
|
||||||
O << "\t.type\t" << name << ", @object\n";
|
O << "\t.type\t" << name << ", @object\n";
|
||||||
O << "\t.size\t" << name << ", " << Size << "\n";
|
O << "\t.size\t" << name << ", " << Size << "\n";
|
||||||
EmitAlignment(Align, I);
|
}
|
||||||
|
|
||||||
|
EmitAlignment(Align, GVar);
|
||||||
|
|
||||||
O << name << ":\n";
|
O << name << ":\n";
|
||||||
|
|
||||||
@@ -269,7 +261,12 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
|
|||||||
|
|
||||||
EmitGlobalConstant(C);
|
EmitGlobalConstant(C);
|
||||||
O << '\n';
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AlphaAsmPrinter::doFinalization(Module &M) {
|
||||||
|
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
|
||||||
|
I != E; ++I)
|
||||||
|
printModuleLevelGV(I);
|
||||||
|
|
||||||
return AsmPrinter::doFinalization(M);
|
return AsmPrinter::doFinalization(M);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user