blob: 8eaa48a96dce9cb54f15ff569bdf4809bd5af343 [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 Gupta211f3622009-05-10 05:23:47 +000046 virtual ~PIC16TargetAsmInfo();
47
48 private:
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000049 const char *RomData8bitsDirective;
50 const char *RomData16bitsDirective;
51 const char *RomData32bitsDirective;
Sanjiv Gupta3b020fe2009-02-02 16:53:06 +000052 const char *getRomDirective(unsigned size) const;
53 virtual const char *getASDirective(unsigned size, unsigned AS) const;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000054 const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const;
55 const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const;
56 virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
57 public:
58 void SetSectionForGVs(Module &M);
59 std::vector<PIC16Section *> getBSSSections() const {
60 return BSSSections;
61 }
62 std::vector<PIC16Section *> getIDATASections() const {
63 return IDATASections;
64 }
Sanjiv Gupta0e687712008-05-13 09:02:57 +000065 };
66
67} // namespace llvm
68
69#endif