Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 1 | //=====-- PIC16TargetAsmInfo.h - PIC16 asm properties ---------*- C++ -*--====// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains the declaration of the PIC16TargetAsmInfo class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef PIC16TARGETASMINFO_H |
| 15 | #define PIC16TARGETASMINFO_H |
| 16 | |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 17 | #include "PIC16.h" |
Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetAsmInfo.h" |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 19 | #include <vector> |
| 20 | #include "llvm/Module.h" |
| 21 | #define DataBankSize 80 |
Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 22 | namespace llvm { |
| 23 | |
| 24 | // Forward declaration. |
| 25 | class PIC16TargetMachine; |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 26 | class GlobalVariable; |
Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 27 | |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 28 | // PIC16 Splits the global data into mulitple udata and idata sections. |
| 29 | // Each udata and idata section needs to contain a list of globals that |
| 30 | // they contain, in order to avoid scanning over all the global values |
| 31 | // again and printing only those that match the current section. |
| 32 | // Keeping values inside the sections make printing a section much easier. |
| 33 | struct PIC16Section { |
| 34 | const Section *S_; // Connection to actual Section. |
| 35 | unsigned Size; // Total size of the objects contained. |
Sanjiv Gupta | 69a97ce | 2009-06-09 15:31:19 +0000 | [diff] [blame] | 36 | bool SectionPrinted; |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 37 | std::vector<const GlobalVariable*> Items; |
| 38 | |
Sanjiv Gupta | 69a97ce | 2009-06-09 15:31:19 +0000 | [diff] [blame] | 39 | PIC16Section (const Section *s) { S_ = s; Size = 0; |
| 40 | SectionPrinted = false;} |
| 41 | bool isPrinted() { return SectionPrinted ; } |
| 42 | void setPrintedStatus(bool status) { SectionPrinted = status ;} |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 43 | }; |
| 44 | |
Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 45 | struct PIC16TargetAsmInfo : public TargetAsmInfo { |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 46 | std::string getSectionNameForSym(const std::string &Sym) const; |
Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 47 | PIC16TargetAsmInfo(const PIC16TargetMachine &TM); |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 48 | mutable std::vector<PIC16Section *> BSSSections; |
| 49 | mutable std::vector<PIC16Section *> IDATASections; |
Sanjiv Gupta | dbe7911 | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 50 | mutable std::vector<PIC16Section *> AutosSections; |
Sanjiv Gupta | bb399cf | 2009-07-06 10:18:37 +0000 | [diff] [blame] | 51 | mutable std::vector<PIC16Section *> ROSections; |
Sanjiv Gupta | 5ade9e8 | 2009-05-13 15:13:17 +0000 | [diff] [blame] | 52 | mutable PIC16Section *ExternalVarDecls; |
| 53 | mutable PIC16Section *ExternalVarDefs; |
Sanjiv Gupta | ca549b7 | 2009-05-10 05:23:47 +0000 | [diff] [blame] | 54 | virtual ~PIC16TargetAsmInfo(); |
| 55 | |
| 56 | private: |
Sanjiv Gupta | dc2943d | 2009-01-30 04:25:10 +0000 | [diff] [blame] | 57 | const char *RomData8bitsDirective; |
| 58 | const char *RomData16bitsDirective; |
| 59 | const char *RomData32bitsDirective; |
Sanjiv Gupta | 46fc9fe | 2009-02-02 16:53:06 +0000 | [diff] [blame] | 60 | const char *getRomDirective(unsigned size) const; |
Chris Lattner | c8859c5 | 2009-07-20 17:12:46 +0000 | [diff] [blame^] | 61 | virtual const char *getDataASDirective(unsigned size, unsigned AS) const; |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 62 | const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const; |
| 63 | const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const; |
Sanjiv Gupta | dbe7911 | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 64 | const Section *getSectionForAuto(const GlobalVariable *GV) const; |
Sanjiv Gupta | bb399cf | 2009-07-06 10:18:37 +0000 | [diff] [blame] | 65 | const Section *CreateBSSSectionForGlobal(const GlobalVariable *GV, |
| 66 | std::string Addr = "") const; |
| 67 | const Section *CreateIDATASectionForGlobal(const GlobalVariable *GV, |
| 68 | std::string Addr = "") const; |
| 69 | const Section *getROSectionForGlobal(const GlobalVariable *GV) const; |
| 70 | const Section *CreateROSectionForGlobal(const GlobalVariable *GV, |
| 71 | std::string Addr = "") const; |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 72 | virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const; |
Sanjiv Gupta | bb399cf | 2009-07-06 10:18:37 +0000 | [diff] [blame] | 73 | const Section * CreateSectionForGlobal(const GlobalValue *GV, |
| 74 | std::string Addr = "") const; |
Sanjiv Gupta | bb4a5c7 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 75 | public: |
| 76 | void SetSectionForGVs(Module &M); |
| 77 | std::vector<PIC16Section *> getBSSSections() const { |
| 78 | return BSSSections; |
| 79 | } |
| 80 | std::vector<PIC16Section *> getIDATASections() const { |
| 81 | return IDATASections; |
| 82 | } |
Sanjiv Gupta | dbe7911 | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 83 | std::vector<PIC16Section *> getAutosSections() const { |
| 84 | return AutosSections; |
| 85 | } |
Sanjiv Gupta | bb399cf | 2009-07-06 10:18:37 +0000 | [diff] [blame] | 86 | std::vector<PIC16Section *> getROSections() const { |
| 87 | return ROSections; |
| 88 | } |
| 89 | virtual const Section* SectionForGlobal(const GlobalValue *GV) const; |
Sanjiv Gupta | 09bb420 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 90 | }; |
| 91 | |
| 92 | } // namespace llvm |
| 93 | |
| 94 | #endif |