blob: e464e36f7887e4ed2dc5e67e3c3e3f4054e466e2 [file] [log] [blame]
Sanjiv Gupta0e687712008-05-13 09:02:57 +00001//=====-- 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 Guptad8d27f42009-05-06 08:02:01 +000017#include "PIC16.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000018#include "llvm/Target/TargetAsmInfo.h"
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000019#include <vector>
20#include "llvm/Module.h"
21#define DataBankSize 80
Sanjiv Gupta0e687712008-05-13 09:02:57 +000022namespace llvm {
23
24 // Forward declaration.
25 class PIC16TargetMachine;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000026 class GlobalVariable;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000027
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000028 // 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 Gupta0e687712008-05-13 09:02:57 +000041 struct PIC16TargetAsmInfo : public TargetAsmInfo {
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000042 std::string getSectionNameForSym(const std::string &Sym) const;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000043 PIC16TargetAsmInfo(const PIC16TargetMachine &TM);
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000044 mutable std::vector<PIC16Section *> BSSSections;
45 mutable std::vector<PIC16Section *> IDATASections;
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +000046 mutable std::vector<PIC16Section *> AutosSections;
47 mutable PIC16Section *ROSection;
Sanjiv Guptaad6585b2009-05-13 15:13:17 +000048 mutable PIC16Section *ExternalVarDecls;
49 mutable PIC16Section *ExternalVarDefs;
Sanjiv Gupta211f3622009-05-10 05:23:47 +000050 virtual ~PIC16TargetAsmInfo();
51
52 private:
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000053 const char *RomData8bitsDirective;
54 const char *RomData16bitsDirective;
55 const char *RomData32bitsDirective;
Sanjiv Gupta3b020fe2009-02-02 16:53:06 +000056 const char *getRomDirective(unsigned size) const;
57 virtual const char *getASDirective(unsigned size, unsigned AS) const;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000058 const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const;
59 const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const;
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +000060 const Section *getSectionForAuto(const GlobalVariable *GV) const;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000061 virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
Sanjiv Guptaad6585b2009-05-13 15:13:17 +000062
63
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000064 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 Gupta2364cfe2009-05-12 17:07:27 +000072 std::vector<PIC16Section *> getAutosSections() const {
73 return AutosSections;
74 }
Sanjiv Gupta0e687712008-05-13 09:02:57 +000075 };
76
77} // namespace llvm
78
79#endif