aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/PIC16/PIC16TargetObjectFile.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-07-28 03:13:23 +0000
committerChris Lattner <sabre@nondot.org>2009-07-28 03:13:23 +0000
commitf0144127b98425d214e59e4a1a4b342b78e3642b (patch)
treecfcb5bc95b5b8060f71ee1b251f0f3e93fbfff2a /lib/Target/PIC16/PIC16TargetObjectFile.h
parent7988aff079c54583d7f4d0011ffcfa3d62ff6a85 (diff)
downloadexternal_llvm-f0144127b98425d214e59e4a1a4b342b78e3642b.zip
external_llvm-f0144127b98425d214e59e4a1a4b342b78e3642b.tar.gz
external_llvm-f0144127b98425d214e59e4a1a4b342b78e3642b.tar.bz2
Rip all of the global variable lowering logic out of TargetAsmInfo. Since
it is highly specific to the object file that will be generated in the end, this introduces a new TargetLoweringObjectFile interface that is implemented for each of ELF/MachO/COFF/Alpha/PIC16 and XCore. Though still is still a brutal and ugly refactoring, this is a major step towards goodness. This patch also: 1. fixes a bunch of dangling pointer problems in the PIC16 backend. 2. disables the TargetLowering copy ctor which PIC16 was accidentally using. 3. gets us closer to xcore having its own crazy target section flags and pic16 not having to shadow sections with its own objects. 4. fixes wierdness where ELF targets would set CStringSection but not CStringSection_. Factor the code better. 5. fixes some bugs in string lowering on ELF targets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77294 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PIC16/PIC16TargetObjectFile.h')
-rw-r--r--lib/Target/PIC16/PIC16TargetObjectFile.h100
1 files changed, 100 insertions, 0 deletions
diff --git a/lib/Target/PIC16/PIC16TargetObjectFile.h b/lib/Target/PIC16/PIC16TargetObjectFile.h
new file mode 100644
index 0000000..77aea78
--- /dev/null
+++ b/lib/Target/PIC16/PIC16TargetObjectFile.h
@@ -0,0 +1,100 @@
+//===-- PIC16TargetObjectFile.h - PIC16 Object Info -------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
+#define LLVM_TARGET_PIC16_TARGETOBJECTFILE_H
+
+#include "llvm/Target/TargetLoweringObjectFile.h"
+#include <vector>
+
+namespace llvm {
+ class GlobalVariable;
+ class Module;
+ class PIC16TargetMachine;
+
+ enum { DataBankSize = 80 };
+
+ /// PIC16 Splits the global data into mulitple udata and idata sections.
+ /// Each udata and idata section needs to contain a list of globals that
+ /// they contain, in order to avoid scanning over all the global values
+ /// again and printing only those that match the current section.
+ /// Keeping values inside the sections make printing a section much easier.
+ ///
+ /// FIXME: Reimplement by inheriting from MCSection.
+ ///
+ struct PIC16Section {
+ const Section *S_; // Connection to actual Section.
+ unsigned Size; // Total size of the objects contained.
+ bool SectionPrinted;
+ std::vector<const GlobalVariable*> Items;
+
+ PIC16Section(const Section *s) {
+ S_ = s;
+ Size = 0;
+ SectionPrinted = false;
+ }
+ bool isPrinted() const { return SectionPrinted; }
+ void setPrintedStatus(bool status) { SectionPrinted = status; }
+ };
+
+ class PIC16TargetObjectFile : public TargetLoweringObjectFile {
+ const PIC16TargetMachine &TM;
+ public:
+ mutable std::vector<PIC16Section*> BSSSections;
+ mutable std::vector<PIC16Section*> IDATASections;
+ mutable std::vector<PIC16Section*> AutosSections;
+ mutable std::vector<PIC16Section*> ROSections;
+ mutable PIC16Section *ExternalVarDecls;
+ mutable PIC16Section *ExternalVarDefs;
+
+ PIC16TargetObjectFile(const PIC16TargetMachine &TM);
+ ~PIC16TargetObjectFile();
+
+ /// getSpecialCasedSectionGlobals - Allow the target to completely override
+ /// section assignment of a global.
+ virtual const Section *
+ getSpecialCasedSectionGlobals(const GlobalValue *GV,
+ SectionKind Kind) const;
+ virtual const Section *SelectSectionForGlobal(const GlobalValue *GV,
+ SectionKind Kind,
+ const TargetMachine&) const;
+ private:
+ std::string getSectionNameForSym(const std::string &Sym) const;
+
+ const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const;
+ const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const;
+ const Section *getSectionForAuto(const GlobalVariable *GV) const;
+ const Section *CreateBSSSectionForGlobal(const GlobalVariable *GV,
+ std::string Addr = "") const;
+ const Section *CreateIDATASectionForGlobal(const GlobalVariable *GV,
+ std::string Addr = "") const;
+ const Section *getROSectionForGlobal(const GlobalVariable *GV) const;
+ const Section *CreateROSectionForGlobal(const GlobalVariable *GV,
+ std::string Addr = "") const;
+ const Section *CreateSectionForGlobal(const GlobalVariable *GV,
+ const std::string &Addr = "") const;
+ public:
+ void SetSectionForGVs(Module &M);
+ const std::vector<PIC16Section*> &getBSSSections() const {
+ return BSSSections;
+ }
+ const std::vector<PIC16Section*> &getIDATASections() const {
+ return IDATASections;
+ }
+ const std::vector<PIC16Section*> &getAutosSections() const {
+ return AutosSections;
+ }
+ const std::vector<PIC16Section*> &getROSections() const {
+ return ROSections;
+ }
+
+ };
+} // end namespace llvm
+
+#endif