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" |
| 21 | #define DataBankSize 80 |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 22 | namespace llvm { |
| 23 | |
| 24 | // Forward declaration. |
| 25 | class PIC16TargetMachine; |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 26 | class GlobalVariable; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 27 | |
Sanjiv Gupta | d8d27f4 | 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. |
| 36 | std::vector<const GlobalVariable*> Items; |
| 37 | |
| 38 | PIC16Section (const Section *s) { S_ = s; Size = 0; } |
| 39 | }; |
| 40 | |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 41 | struct PIC16TargetAsmInfo : public TargetAsmInfo { |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 42 | std::string getSectionNameForSym(const std::string &Sym) const; |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 43 | PIC16TargetAsmInfo(const PIC16TargetMachine &TM); |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 44 | mutable std::vector<PIC16Section *> BSSSections; |
| 45 | mutable std::vector<PIC16Section *> IDATASections; |
Sanjiv Gupta | 2364cfe | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 46 | mutable std::vector<PIC16Section *> AutosSections; |
| 47 | mutable PIC16Section *ROSection; |
Sanjiv Gupta | ad6585b | 2009-05-13 15:13:17 +0000 | [diff] [blame^] | 48 | mutable PIC16Section *ExternalVarDecls; |
| 49 | mutable PIC16Section *ExternalVarDefs; |
Sanjiv Gupta | 211f362 | 2009-05-10 05:23:47 +0000 | [diff] [blame] | 50 | virtual ~PIC16TargetAsmInfo(); |
| 51 | |
| 52 | private: |
Sanjiv Gupta | c8d7bc8 | 2009-01-30 04:25:10 +0000 | [diff] [blame] | 53 | const char *RomData8bitsDirective; |
| 54 | const char *RomData16bitsDirective; |
| 55 | const char *RomData32bitsDirective; |
Sanjiv Gupta | 3b020fe | 2009-02-02 16:53:06 +0000 | [diff] [blame] | 56 | const char *getRomDirective(unsigned size) const; |
| 57 | virtual const char *getASDirective(unsigned size, unsigned AS) const; |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 58 | const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const; |
| 59 | const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const; |
Sanjiv Gupta | 2364cfe | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 60 | const Section *getSectionForAuto(const GlobalVariable *GV) const; |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 61 | virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const; |
Sanjiv Gupta | ad6585b | 2009-05-13 15:13:17 +0000 | [diff] [blame^] | 62 | |
| 63 | |
Sanjiv Gupta | d8d27f4 | 2009-05-06 08:02:01 +0000 | [diff] [blame] | 64 | public: |
| 65 | void SetSectionForGVs(Module &M); |
| 66 | std::vector<PIC16Section *> getBSSSections() const { |
| 67 | return BSSSections; |
| 68 | } |
| 69 | std::vector<PIC16Section *> getIDATASections() const { |
| 70 | return IDATASections; |
| 71 | } |
Sanjiv Gupta | 2364cfe | 2009-05-12 17:07:27 +0000 | [diff] [blame] | 72 | std::vector<PIC16Section *> getAutosSections() const { |
| 73 | return AutosSections; |
| 74 | } |
Sanjiv Gupta | 0e68771 | 2008-05-13 09:02:57 +0000 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | } // namespace llvm |
| 78 | |
| 79 | #endif |