//===----------------------------------------------------------------------===//
#include "PIC16AsmPrinter.h"
+#include "PIC16Section.h"
#include "PIC16TargetAsmInfo.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
-#include "llvm/MC/MCSection.h"
#include "llvm/Target/TargetRegistry.h"
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
+#include <cstring>
using namespace llvm;
#include "PIC16GenAsmWriter.inc"
PIC16AsmPrinter::PIC16AsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
const TargetAsmInfo *T, bool V)
: AsmPrinter(O, TM, T, V), DbgInfo(O, T) {
- PTLI = static_cast<const PIC16TargetLowering*>(TM.getTargetLowering());
+ PTLI = static_cast<PIC16TargetLowering*>(TM.getTargetLowering());
PTAI = static_cast<const PIC16TargetAsmInfo*>(T);
PTOF = (PIC16TargetObjectFile*)&PTLI->getObjFileLowering();
}
EmitAutos(CurrentFnName);
// Now emit the instructions of function in its code section.
- std::string T = PAN::getCodeSectionName(CurrentFnName);
- const char *codeSection = T.c_str();
-
const MCSection *fCodeSection =
- getObjFileLowering().getOrCreateSection(codeSection, false,
- SectionKind::get(SectionKind::Text));
+ getObjFileLowering().getSectionForFunction(CurrentFnName);
// Start the Code Section.
O << "\n";
SwitchToSection(fCodeSection);
// This function is used to sort the decls list.
// should return true if s1 should come before s2.
static bool is_before(const char *s1, const char *s2) {
- std::string str1 = s1;
- std::string str2 = s2;
- int i = str1.compare(str2);
- // Return true if s1 is smaller or equal.
- if (i <= 0) return true;
- // false if s1 should come after s2.
- return false;
+ return strcmp(s1, s2) <= 0;
}
// This is used by list::unique below.
// unique will filter out duplicates if it knows them.
static bool is_duplicate(const char *s1, const char *s2) {
- std::string str1 = s1;
- std::string str2 = s2;
- return str1 == str2;
+ return !strcmp(s1, s2);
}
/// printLibcallDecls - print the extern declarations for compiler
// Set the section names for all globals.
for (Module::global_iterator I = M.global_begin(), E = M.global_end();
I != E; ++I)
- I->setSection(getObjFileLowering().SectionForGlobal(I, Mang,TM)->getName());
+ if (!I->isDeclaration() && !I->hasAvailableExternallyLinkage()) {
+ const MCSection *S = getObjFileLowering().SectionForGlobal(I, Mang, TM);
+
+ I->setSection(((const MCSectionPIC16*)S)->getName());
+ }
DbgInfo.BeginModule(M);
EmitFunctionDecls(M);
const TargetData *TD = TM.getTargetData();
// Emit the data section name.
O << "\n";
- std::string T = PAN::getFrameSectionName(CurrentFnName);
- const char *SectionName = T.c_str();
-
+
const MCSection *fPDataSection =
- getObjFileLowering().getOrCreateSection(SectionName, false,
- SectionKind::get(SectionKind::DataRel));
+ getObjFileLowering().getSectionForFunctionFrame(CurrentFnName);
SwitchToSection(fPDataSection);
// Emit function frame label