Sanjiv Gupta | 0e68771 | 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 | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 17 | #include "PIC16.h" |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetAsmInfo.h" |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 19 | #include <vector> |
| 20 | #include "llvm/Module.h" |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 21 | |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 22 | namespace llvm { |
| 23 | |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 24 | enum { DataBankSize = 80 }; |
| 25 | |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 26 | // Forward declaration. |
| 27 | class PIC16TargetMachine; |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 28 | class GlobalVariable; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 29 | |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 30 | /// PIC16 Splits the global data into mulitple udata and idata sections. |
| 31 | /// Each udata and idata section needs to contain a list of globals that |
| 32 | /// they contain, in order to avoid scanning over all the global values |
| 33 | /// again and printing only those that match the current section. |
| 34 | /// Keeping values inside the sections make printing a section much easier. |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 35 | struct PIC16Section { |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 36 | const Section *S_; // Connection to actual Section. |
| 37 | unsigned Size; // Total size of the objects contained. |
| 38 | bool SectionPrinted; |
| 39 | std::vector<const GlobalVariable*> Items; |
| 40 | |
| 41 | PIC16Section(const Section *s) { |
| 42 | S_ = s; |
| 43 | Size = 0; |
| 44 | SectionPrinted = false; |
| 45 | } |
| 46 | bool isPrinted() const { return SectionPrinted; } |
| 47 | void setPrintedStatus(bool status) { SectionPrinted = status; } |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 48 | }; |
| 49 | |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 50 | struct PIC16TargetAsmInfo : public TargetAsmInfo { |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 51 | std::string getSectionNameForSym(const std::string &Sym) const; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 52 | PIC16TargetAsmInfo(const PIC16TargetMachine &TM); |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 53 | mutable std::vector<PIC16Section *> BSSSections; |
| 54 | mutable std::vector<PIC16Section *> IDATASections; |
Sanjiv Gupta | 2364cfe | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 55 | mutable std::vector<PIC16Section *> AutosSections; |
Sanjiv Gupta | 505996f | 2009-07-06 10:18:37 +0000 | [diff] [blame] | 56 | mutable std::vector<PIC16Section *> ROSections; |
Sanjiv Gupta | ad6585b | 2009-05-13 15:13:17 +0000 | [diff] [blame] | 57 | mutable PIC16Section *ExternalVarDecls; |
| 58 | mutable PIC16Section *ExternalVarDefs; |
Sanjiv Gupta | 211f362 | 2009-05-10 05:23:47 +0000 | [diff] [blame] | 59 | virtual ~PIC16TargetAsmInfo(); |
| 60 | |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 61 | private: |
Sanjiv Gupta | c8d7bc8 | 2009-01-30 04:25:10 +0000 | [diff] [blame] | 62 | const char *RomData8bitsDirective; |
| 63 | const char *RomData16bitsDirective; |
| 64 | const char *RomData32bitsDirective; |
Sanjiv Gupta | 3b020fe | 2009-02-02 16:53:06 +0000 | [diff] [blame] | 65 | const char *getRomDirective(unsigned size) const; |
Chris Lattner | 83757c7 | 2009-07-20 17:12:46 +0000 | [diff] [blame] | 66 | virtual const char *getDataASDirective(unsigned size, unsigned AS) const; |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 67 | const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const; |
| 68 | const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const; |
Sanjiv Gupta | 2364cfe | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 69 | const Section *getSectionForAuto(const GlobalVariable *GV) const; |
Sanjiv Gupta | 505996f | 2009-07-06 10:18:37 +0000 | [diff] [blame] | 70 | const Section *CreateBSSSectionForGlobal(const GlobalVariable *GV, |
| 71 | std::string Addr = "") const; |
| 72 | const Section *CreateIDATASectionForGlobal(const GlobalVariable *GV, |
| 73 | std::string Addr = "") const; |
| 74 | const Section *getROSectionForGlobal(const GlobalVariable *GV) const; |
| 75 | const Section *CreateROSectionForGlobal(const GlobalVariable *GV, |
| 76 | std::string Addr = "") const; |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 77 | virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const; |
Sanjiv Gupta | 505996f | 2009-07-06 10:18:37 +0000 | [diff] [blame] | 78 | const Section * CreateSectionForGlobal(const GlobalValue *GV, |
| 79 | std::string Addr = "") const; |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 80 | public: |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 81 | void SetSectionForGVs(Module &M); |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 82 | const std::vector<PIC16Section*> &getBSSSections() const { |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 83 | return BSSSections; |
| 84 | } |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 85 | const std::vector<PIC16Section*> &getIDATASections() const { |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 86 | return IDATASections; |
| 87 | } |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 88 | const std::vector<PIC16Section*> &getAutosSections() const { |
Sanjiv Gupta | 2364cfe | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 89 | return AutosSections; |
| 90 | } |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 91 | const std::vector<PIC16Section*> &getROSections() const { |
Sanjiv Gupta | 505996f | 2009-07-06 10:18:37 +0000 | [diff] [blame] | 92 | return ROSections; |
| 93 | } |
Chris Lattner | a46cb52 | 2009-07-21 17:20:18 +0000 | [diff] [blame^] | 94 | virtual const Section *SectionForGlobal(const GlobalValue *GV) const; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | } // namespace llvm |
| 98 | |
| 99 | #endif |