mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +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 printOperand(const MachineInstr *MI, int opNum);
|
||||
void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true);
|
||||
void printModuleLevelGV(const GlobalVariable* GVar);
|
||||
bool runOnMachineFunction(MachineFunction &F);
|
||||
bool doInitialization(Module &M);
|
||||
bool doFinalization(Module &M);
|
||||
@@ -201,28 +202,30 @@ bool AlphaAsmPrinter::doInitialization(Module &M)
|
||||
return AsmPrinter::doInitialization(M);
|
||||
}
|
||||
|
||||
bool AlphaAsmPrinter::doFinalization(Module &M) {
|
||||
void AlphaAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
|
||||
for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) {
|
||||
|
||||
if (!I->hasInitializer()) continue; // External global require no code
|
||||
if (!GVar->hasInitializer()) return; // External global require no code
|
||||
|
||||
// Check to see if this is a special global used by LLVM, if so, emit it.
|
||||
if (EmitSpecialLLVMGlobal(I))
|
||||
continue;
|
||||
if (EmitSpecialLLVMGlobal(GVar))
|
||||
return;
|
||||
|
||||
std::string name = Mang->getValueName(I);
|
||||
Constant *C = I->getInitializer();
|
||||
std::string SectionName = TAI->SectionForGlobal(GVar);
|
||||
std::string name = Mang->getValueName(GVar);
|
||||
Constant *C = GVar->getInitializer();
|
||||
unsigned Size = TD->getABITypeSize(C->getType());
|
||||
unsigned Align = TD->getPreferredAlignmentLog(I);
|
||||
unsigned Align = TD->getPreferredAlignmentLog(GVar);
|
||||
|
||||
//1: hidden?
|
||||
if (I->hasHiddenVisibility())
|
||||
// 0: Switch to section
|
||||
SwitchToDataSection(SectionName.c_str());
|
||||
|
||||
// 1: Check visibility
|
||||
if (GVar->hasHiddenVisibility())
|
||||
O << TAI->getHiddenDirective() << name << "\n";
|
||||
|
||||
//2: kind
|
||||
switch (I->getLinkage()) {
|
||||
// 2: Kind
|
||||
switch (GVar->getLinkage()) {
|
||||
case GlobalValue::LinkOnceLinkage:
|
||||
case GlobalValue::WeakLinkage:
|
||||
case GlobalValue::CommonLinkage:
|
||||
@@ -230,7 +233,7 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
|
||||
break;
|
||||
case GlobalValue::AppendingLinkage:
|
||||
case GlobalValue::ExternalLinkage:
|
||||
O << "\t.globl " << name << "\n";
|
||||
O << TAI->getGlobalDirective() << name << "\n";
|
||||
break;
|
||||
case GlobalValue::InternalLinkage:
|
||||
break;
|
||||
@@ -240,24 +243,13 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
|
||||
abort();
|
||||
}
|
||||
|
||||
//3: Section (if changed)
|
||||
if (I->hasSection() &&
|
||||
(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
|
||||
// 3: Type, Size, Align
|
||||
if (TAI->hasDotTypeDotSizeDirective()) {
|
||||
O << "\t.type\t" << name << ", @object\n";
|
||||
O << "\t.size\t" << name << ", " << Size << "\n";
|
||||
EmitAlignment(Align, I);
|
||||
}
|
||||
|
||||
EmitAlignment(Align, GVar);
|
||||
|
||||
O << name << ":\n";
|
||||
|
||||
@@ -271,6 +263,11 @@ bool AlphaAsmPrinter::doFinalization(Module &M) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user