1 //===-- PIC16Section.cpp - PIC16 Section ----------- --------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "PIC16ABINames.h"
12 #include "PIC16Section.h"
13 #include "llvm/MC/MCContext.h"
14 #include "llvm/Support/raw_ostream.h"
18 // This is the only way to create a PIC16Section. Sections created here
19 // do not need to be explicitly deleted as they are managed by auto_ptrs.
20 PIC16Section *PIC16Section::Create(const StringRef &Name,
22 const std::string &Address,
23 int Color, MCContext &Ctx) {
25 /// Determine the internal SectionKind info.
26 /// Users of PIC16Section class should not need to know the internal
27 /// SectionKind. They should work only with PIC16SectionType.
29 /// PIC16 Terminology for section kinds is as below.
31 /// IDATA - initialized data (equiv to Metadata)
32 /// ROMDATA - ReadOnly.
33 /// UDATA_OVR - Sections that can be overlaid. Section of such type is
34 /// used to contain function autos an frame. We can think of
35 /// it as equiv to llvm ThreadBSS)
36 /// UDATA_SHR - Shared RAM. Memory area that is mapped to all banks.
40 default: llvm_unreachable ("can not create unknown section type");
42 K = SectionKind::getThreadBSS();
47 K = SectionKind::getBSS();
52 K = SectionKind::getMetadata();
56 K = SectionKind::getText();
62 // Create the Section.
63 PIC16Section *S = new (Ctx) PIC16Section(Name, K, Address, Color);
68 // A generic way to print all types of sections.
69 void PIC16Section::PrintSwitchToSection(const MCAsmInfo &MAI,
70 raw_ostream &OS) const {
72 // If the section is overlaid(i.e. it has a color), print overlay name for
73 // it. Otherwise print its normal name.
75 OS << PAN::getOverlayName(getName(), Color) << '\t';
77 OS << getName() << '\t';
81 default : llvm_unreachable ("unknown section type");
82 case UDATA: OS << "UDATA"; break;
83 case IDATA: OS << "IDATA"; break;
84 case ROMDATA: OS << "ROMDATA"; break;
85 case UDATA_SHR: OS << "UDATA_SHR"; break;
86 case UDATA_OVR: OS << "UDATA_OVR"; break;
87 case CODE: OS << "CODE"; break;