mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-01 18:33:56 +00:00
Cleaned up some code. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84251 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b46aea1032
commit
5386a35c5a
@ -73,9 +73,6 @@ bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
||||
|
||||
DbgInfo.BeginFunction(MF);
|
||||
|
||||
// Emit the autos section of function.
|
||||
// EmitAutos(CurrentFnName);
|
||||
|
||||
// Now emit the instructions of function in its code section.
|
||||
const MCSection *fCodeSection
|
||||
= getObjFileLowering().SectionForCode(CurrentFnName);
|
||||
@ -329,15 +326,11 @@ void PIC16AsmPrinter::EmitDefinedVars(Module &M) {
|
||||
|
||||
// Emit initialized data placed in ROM.
|
||||
void PIC16AsmPrinter::EmitRomData(Module &M) {
|
||||
// Print ROM Data section.
|
||||
const PIC16Section *ROSection = PTOF->ROMDATASection();
|
||||
if (ROSection == NULL) return;
|
||||
EmitInitializedDataSection(ROSection);
|
||||
EmitSingleSection(PTOF->ROMDATASection());
|
||||
}
|
||||
|
||||
bool PIC16AsmPrinter::doFinalization(Module &M) {
|
||||
printLibcallDecls();
|
||||
// EmitRemainingAutos();
|
||||
DbgInfo.EndModule(M);
|
||||
O << "\n\t" << "END\n";
|
||||
return AsmPrinter::doFinalization(M);
|
||||
@ -402,20 +395,13 @@ void PIC16AsmPrinter::EmitInitializedDataSection(const PIC16Section *S) {
|
||||
}
|
||||
}
|
||||
|
||||
// Print all IDATA sections.
|
||||
void PIC16AsmPrinter::EmitIData(Module &M) {
|
||||
|
||||
// Print all IDATA sections.
|
||||
const std::vector<PIC16Section *> &IDATASections = PTOF->IDATASections();
|
||||
for (unsigned i = 0; i < IDATASections.size(); i++) {
|
||||
O << "\n";
|
||||
if (IDATASections[i]->getName().find("llvm.") != std::string::npos)
|
||||
continue;
|
||||
|
||||
EmitInitializedDataSection(IDATASections[i]);
|
||||
}
|
||||
EmitSectionList (M, PTOF->IDATASections());
|
||||
}
|
||||
|
||||
void PIC16AsmPrinter::EmitUninitializedDataSection(const PIC16Section *S) {
|
||||
void PIC16AsmPrinter::
|
||||
EmitUninitializedDataSection(const PIC16Section *S) {
|
||||
const TargetData *TD = TM.getTargetData();
|
||||
OutStreamer.SwitchSection(S);
|
||||
std::vector<const GlobalVariable*> Items = S->Items;
|
||||
@ -428,41 +414,52 @@ void PIC16AsmPrinter::EmitUninitializedDataSection(const PIC16Section *S) {
|
||||
}
|
||||
}
|
||||
|
||||
// Print all UDATA sections.
|
||||
void PIC16AsmPrinter::EmitUData(Module &M) {
|
||||
// Print all UDATA sections.
|
||||
const std::vector<PIC16Section*> &UDATASections = PTOF->UDATASections();
|
||||
for (unsigned i = 0; i < UDATASections.size(); i++) {
|
||||
O << "\n";
|
||||
EmitUninitializedDataSection(UDATASections[i]);
|
||||
}
|
||||
EmitSectionList (M, PTOF->UDATASections());
|
||||
}
|
||||
|
||||
// Print all USER sections.
|
||||
void PIC16AsmPrinter::EmitUserSections(Module &M) {
|
||||
const std::vector<PIC16Section*> &USERSections = PTOF->USERSections();
|
||||
for (unsigned i = 0; i < USERSections.size(); i++) {
|
||||
O << "\n";
|
||||
const PIC16Section *S = USERSections[i];
|
||||
if (S->isUDATA_Type()) {
|
||||
EmitUninitializedDataSection(S);
|
||||
} else if (S->isIDATA_Type() || S->isROMDATA_Type()) {
|
||||
EmitInitializedDataSection(S);
|
||||
} else {
|
||||
llvm_unreachable ("unknow user section type");
|
||||
}
|
||||
}
|
||||
EmitSectionList (M, PTOF->USERSections());
|
||||
}
|
||||
|
||||
// Print all AUTO sections.
|
||||
void PIC16AsmPrinter::EmitAllAutos(Module &M) {
|
||||
// Print all AUTO sections.
|
||||
const std::vector<PIC16Section*> &AUTOSections = PTOF->AUTOSections();
|
||||
for (unsigned i = 0; i < AUTOSections.size(); i++) {
|
||||
O << "\n";
|
||||
EmitUninitializedDataSection(AUTOSections[i]);
|
||||
}
|
||||
EmitSectionList (M, PTOF->AUTOSections());
|
||||
}
|
||||
|
||||
extern "C" void LLVMInitializePIC16AsmPrinter() {
|
||||
RegisterAsmPrinter<PIC16AsmPrinter> X(ThePIC16Target);
|
||||
}
|
||||
|
||||
// Emit one data section using correct section emitter based on section type.
|
||||
void PIC16AsmPrinter::EmitSingleSection(const PIC16Section *S) {
|
||||
if (S == NULL) return;
|
||||
|
||||
switch (S->getType()) {
|
||||
default: llvm_unreachable ("unknow user section type");
|
||||
case UDATA:
|
||||
case UDATA_SHR:
|
||||
case UDATA_OVR:
|
||||
EmitUninitializedDataSection(S);
|
||||
break;
|
||||
case IDATA:
|
||||
case ROMDATA:
|
||||
EmitInitializedDataSection(S);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Emit a list of sections.
|
||||
void PIC16AsmPrinter::
|
||||
EmitSectionList(Module &M, const std::vector<PIC16Section *> &SList) {
|
||||
for (unsigned i = 0; i < SList.size(); i++) {
|
||||
// Exclude llvm specific metadata sections.
|
||||
if (SList[i]->getName().find("llvm.") != std::string::npos)
|
||||
continue;
|
||||
O << "\n";
|
||||
EmitSingleSection(SList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,9 @@ namespace llvm {
|
||||
void printLibcallDecls();
|
||||
void EmitUninitializedDataSection(const PIC16Section *S);
|
||||
void EmitInitializedDataSection(const PIC16Section *S);
|
||||
void EmitSingleSection(const PIC16Section *S);
|
||||
void EmitSectionList(Module &M,
|
||||
const std::vector< PIC16Section *> &SList);
|
||||
protected:
|
||||
bool doInitialization(Module &M);
|
||||
bool doFinalization(Module &M);
|
||||
|
@ -40,6 +40,7 @@ namespace llvm {
|
||||
// Global variables do not have any '.' in their names.
|
||||
// These are maily function names and global variable names.
|
||||
// Example - @foo, @i
|
||||
// Static local variables - @<func>.<var>
|
||||
// -------------------------------------------------------
|
||||
// Functions and auto variables.
|
||||
// Names are mangled as <prefix><funcname>.<tag>.<varname>
|
||||
@ -67,8 +68,12 @@ namespace llvm {
|
||||
// SECTION Names
|
||||
// uninitialized globals - @udata.<num>.#
|
||||
// initialized globals - @idata.<num>.#
|
||||
// Program memory data - @romdata.#
|
||||
// Variables with user defined section name - <user_defined_section>
|
||||
// Variables with user defined address - @<var>.user_section.<address>.#
|
||||
// Function frame - @<func>.frame_section.
|
||||
// Function autos - @<func>.autos_section.
|
||||
// Overlay sections - @<color>.##
|
||||
// Declarations - Enclosed in comments. No section for them.
|
||||
//----------------------------------------------------------
|
||||
|
||||
|
@ -22,6 +22,9 @@ using namespace llvm;
|
||||
PIC16TargetObjectFile::PIC16TargetObjectFile() {
|
||||
}
|
||||
|
||||
PIC16TargetObjectFile::~PIC16TargetObjectFile() {
|
||||
}
|
||||
|
||||
/// Find a pic16 section. If not found, create one.
|
||||
PIC16Section *PIC16TargetObjectFile::
|
||||
getPIC16Section(const std::string &Name, PIC16SectionType Ty,
|
||||
@ -104,19 +107,11 @@ getPIC16UserSection(const std::string &Name, PIC16SectionType Ty,
|
||||
return Entry;
|
||||
}
|
||||
|
||||
/// Do some standard llvm stuff. PIC16 really does not need any of this.
|
||||
/// Do some standard initialization.
|
||||
void PIC16TargetObjectFile::Initialize(MCContext &Ctx, const TargetMachine &tm){
|
||||
TargetLoweringObjectFile::Initialize(Ctx, tm);
|
||||
TM = &tm;
|
||||
|
||||
// BSSSection = getPIC16DataSection("udata.#", UDATA);
|
||||
// ReadOnlySection = getPIC16DataSection("romdata.#", ROMDATA);
|
||||
// DataSection = getPIC16DataSection("idata.#", IDATA);
|
||||
|
||||
// Need because otherwise a .text symbol is emitted by DwarfWriter
|
||||
// in BeginModule, and gpasm cribbs for that .text symbol.
|
||||
// FIXME: below
|
||||
// TextSection = getPIC16DataSection("", UDATA);
|
||||
ROMDATASection_ = NULL;
|
||||
}
|
||||
|
||||
@ -254,22 +249,7 @@ PIC16TargetObjectFile::SelectSectionForGlobal(const GlobalValue *GV1,
|
||||
return TargetLoweringObjectFile::SelectSectionForGlobal(GV, Kind, Mang,TM);
|
||||
}
|
||||
|
||||
PIC16TargetObjectFile::~PIC16TargetObjectFile() {
|
||||
#if 0
|
||||
for (unsigned i = 0; i < UDATASections_.size(); i++)
|
||||
delete UDATASections_[i];
|
||||
for (unsigned i = 0; i < IDATASections_.size(); i++)
|
||||
delete IDATASections_[i];
|
||||
|
||||
delete ROMDATASection_;
|
||||
|
||||
for (unsigned i = 0; i < AUTOSections_.size(); i++)
|
||||
delete AUTOSections_[i];
|
||||
|
||||
for (unsigned i = 0; i < USERSections_.size(); i++)
|
||||
delete USERSections_[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/// getExplicitSectionGlobal - Allow the target to completely override
|
||||
|
Loading…
x
Reference in New Issue
Block a user