blob: b7292b8ea78aef16da7de02733426e29b9cc2c4e [file] [log] [blame]
Sanjiv Gupta09bb4202008-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 Guptabb4a5c72009-05-06 08:02:01 +000017#include "PIC16.h"
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000018#include "llvm/Target/TargetAsmInfo.h"
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000019#include <vector>
20#include "llvm/Module.h"
21#define DataBankSize 80
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000022namespace llvm {
23
24 // Forward declaration.
25 class PIC16TargetMachine;
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000026 class GlobalVariable;
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000027
Sanjiv Guptabb4a5c72009-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.
Sanjiv Gupta69a97ce2009-06-09 15:31:19 +000036 bool SectionPrinted;
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000037 std::vector<const GlobalVariable*> Items;
38
Sanjiv Gupta69a97ce2009-06-09 15:31:19 +000039 PIC16Section (const Section *s) { S_ = s; Size = 0;
40 SectionPrinted = false;}
41 bool isPrinted() { return SectionPrinted ; }
42 void setPrintedStatus(bool status) { SectionPrinted = status ;}
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000043 };
44
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000045 struct PIC16TargetAsmInfo : public TargetAsmInfo {
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000046 std::string getSectionNameForSym(const std::string &Sym) const;
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000047 PIC16TargetAsmInfo(const PIC16TargetMachine &TM);
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000048 mutable std::vector<PIC16Section *> BSSSections;
49 mutable std::vector<PIC16Section *> IDATASections;
Sanjiv Guptadbe79112009-05-12 17:07:27 +000050 mutable std::vector<PIC16Section *> AutosSections;
51 mutable PIC16Section *ROSection;
Sanjiv Gupta5ade9e82009-05-13 15:13:17 +000052 mutable PIC16Section *ExternalVarDecls;
53 mutable PIC16Section *ExternalVarDefs;
Sanjiv Guptaca549b72009-05-10 05:23:47 +000054 virtual ~PIC16TargetAsmInfo();
55
56 private:
Sanjiv Guptadc2943d2009-01-30 04:25:10 +000057 const char *RomData8bitsDirective;
58 const char *RomData16bitsDirective;
59 const char *RomData32bitsDirective;
Sanjiv Gupta46fc9fe2009-02-02 16:53:06 +000060 const char *getRomDirective(unsigned size) const;
61 virtual const char *getASDirective(unsigned size, unsigned AS) const;
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000062 const Section *getBSSSectionForGlobal(const GlobalVariable *GV) const;
63 const Section *getIDATASectionForGlobal(const GlobalVariable *GV) const;
Sanjiv Guptadbe79112009-05-12 17:07:27 +000064 const Section *getSectionForAuto(const GlobalVariable *GV) const;
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000065 virtual const Section *SelectSectionForGlobal(const GlobalValue *GV) const;
Sanjiv Gupta5ade9e82009-05-13 15:13:17 +000066
67
Sanjiv Guptabb4a5c72009-05-06 08:02:01 +000068 public:
69 void SetSectionForGVs(Module &M);
70 std::vector<PIC16Section *> getBSSSections() const {
71 return BSSSections;
72 }
73 std::vector<PIC16Section *> getIDATASections() const {
74 return IDATASections;
75 }
Sanjiv Guptadbe79112009-05-12 17:07:27 +000076 std::vector<PIC16Section *> getAutosSections() const {
77 return AutosSections;
78 }
Sanjiv Gupta09bb4202008-05-13 09:02:57 +000079 };
80
81} // namespace llvm
82
83#endif