Merge branch 'master' into msp430
[llvm/msp430.git] / lib / Target / PIC16 / PIC16TargetAsmInfo.h
blobe464e36f7887e4ed2dc5e67e3c3e3f4054e466e2
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.
12 //===----------------------------------------------------------------------===//
14 #ifndef PIC16TARGETASMINFO_H
15 #define PIC16TARGETASMINFO_H
17 #include "PIC16.h"
18 #include "llvm/Target/TargetAsmInfo.h"
19 #include <vector>
20 #include "llvm/Module.h"
21 #define DataBankSize 80
22 namespace llvm {
24 // Forward declaration.
25 class PIC16TargetMachine;
26 class GlobalVariable;
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;
38 PIC16Section (const Section *s) { S_ = s; Size = 0; }
41 struct PIC16TargetAsmInfo : public TargetAsmInfo {
42 std::string getSectionNameForSym(const std::string &Sym) const;
43 PIC16TargetAsmInfo(const PIC16TargetMachine &TM);
44 mutable std::vector<PIC16Section *> BSSSections;
45 mutable std::vector<PIC16Section *> IDATASections;
46 mutable std::vector<PIC16Section *> AutosSections;
47 mutable PIC16Section *ROSection;
48 mutable PIC16Section *ExternalVarDecls;
49 mutable PIC16Section *ExternalVarDefs;
50 virtual ~PIC16TargetAsmInfo();
52 private:
53 const char *RomData8bitsDirective;
54 const char *RomData16bitsDirective;
55 const char *RomData32bitsDirective;
56 const char *getRomDirective(unsigned size) const;
57 virtual const char *getASDirective(unsigned size, unsigned AS) const;
58 const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const;
59 const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const;
60 const Section *getSectionForAuto(const GlobalVariable *GV) const;
61 virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
64 public:
65 void SetSectionForGVs(Module &M);
66 std::vector<PIC16Section *> getBSSSections() const {
67 return BSSSections;
69 std::vector<PIC16Section *> getIDATASections() const {
70 return IDATASections;
72 std::vector<PIC16Section *> getAutosSections() const {
73 return AutosSections;
77 } // namespace llvm
79 #endif