blob: a39209daaf65180a720e64ec7539057f2bef77ff [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 Gupta211f3622009-05-10 05:23:47 +000048 virtual ~PIC16TargetAsmInfo();
49
50 private:
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000051 const char *RomData8bitsDirective;
52 const char *RomData16bitsDirective;
53 const char *RomData32bitsDirective;
Sanjiv Gupta3b020fe2009-02-02 16:53:06 +000054 const char *getRomDirective(unsigned size) const;
55 virtual const char *getASDirective(unsigned size, unsigned AS) const;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000056 const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const;
57 const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const;
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +000058 const Section *getSectionForAuto(const GlobalVariable *GV) const;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000059 virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
60 public:
61 void SetSectionForGVs(Module &M);
62 std::vector<PIC16Section *> getBSSSections() const {
63 return BSSSections;
64 }
65 std::vector<PIC16Section *> getIDATASections() const {
66 return IDATASections;
67 }
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +000068 std::vector<PIC16Section *> getAutosSections() const {
69 return AutosSections;
70 }
Sanjiv Gupta0e687712008-05-13 09:02:57 +000071 };
72
73} // namespace llvm
74
75#endif