blob: e8f216d09958cb0982548d9e623f737f15d612af [file] [log] [blame]
Sanjiv Gupta0e687712008-05-13 09:02:57 +00001//===-- PIC16TargetAsmInfo.cpp - PIC16 asm properties ---------------------===//
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 declarations of the PIC16TargetAsmInfo properties.
11//
12//===----------------------------------------------------------------------===//
13
14#include "PIC16TargetAsmInfo.h"
Dan Gohman8f092252008-11-03 18:22:42 +000015#include "PIC16TargetMachine.h"
Sanjiv Gupta1b046942009-01-13 19:18:47 +000016#include "llvm/GlobalValue.h"
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000017#include "llvm/GlobalVariable.h"
18#include "llvm/DerivedTypes.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000019
20using namespace llvm;
21
22PIC16TargetAsmInfo::
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000023PIC16TargetAsmInfo(const PIC16TargetMachine &TM)
Dan Gohman8f092252008-11-03 18:22:42 +000024 : TargetAsmInfo(TM) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +000025 CommentString = ";";
Sanjiv Gupta211f3622009-05-10 05:23:47 +000026 GlobalPrefix = PAN::getTagName(PAN::PREFIX_SYMBOL);
27 GlobalDirective = "\tglobal\t";
28 ExternDirective = "\textern\t";
29
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000030 Data8bitsDirective = " db ";
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000031 Data16bitsDirective = " dw ";
32 Data32bitsDirective = " dl ";
Sanjiv Gupta53cf8292009-07-06 18:09:11 +000033 Data64bitsDirective = NULL;
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000034 RomData8bitsDirective = " dw ";
35 RomData16bitsDirective = " rom_di ";
Sanjiv Gupta3b020fe2009-02-02 16:53:06 +000036 RomData32bitsDirective = " rom_dl ";
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000037 ZeroDirective = NULL;
Sanjiv Gupta1b046942009-01-13 19:18:47 +000038 AsciiDirective = " dt ";
39 AscizDirective = NULL;
40 BSSSection_ = getNamedSection("udata.# UDATA",
Chris Lattnerb4fc4192009-07-25 18:57:34 +000041 SectionFlags::Writable | SectionFlags::BSS);
Sanjiv Gupta1b046942009-01-13 19:18:47 +000042 ReadOnlySection = getNamedSection("romdata.# ROMDATA", SectionFlags::None);
Chris Lattnerb4fc4192009-07-25 18:57:34 +000043 DataSection = getNamedSection("idata.# IDATA", SectionFlags::Writable);
Sanjiv Gupta1b046942009-01-13 19:18:47 +000044 SwitchToSectionDirective = "";
Sanjiv Guptac1fa70c2009-04-08 06:24:04 +000045 // Need because otherwise a .text symbol is emitted by DwarfWriter
46 // in BeginModule, and gpasm cribbs for that .text symbol.
47 TextSection = getUnnamedSection("", SectionFlags::Code);
Sanjiv Gupta505996f2009-07-06 10:18:37 +000048 PIC16Section *ROSection = new PIC16Section(getReadOnlySection());
49 ROSections.push_back(ROSection);
Sanjiv Guptaad6585b2009-05-13 15:13:17 +000050 ExternalVarDecls = new PIC16Section(getNamedSection("ExternalVarDecls"));
51 ExternalVarDefs = new PIC16Section(getNamedSection("ExternalVarDefs"));
Sanjiv Guptadd4694b2009-05-28 18:24:11 +000052 // Set it to false because we weed to generate c file name and not bc file
53 // name.
54 HasSingleParameterDotFile = false;
Sanjiv Gupta0e687712008-05-13 09:02:57 +000055}
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000056
Chris Lattner83757c72009-07-20 17:12:46 +000057const char *PIC16TargetAsmInfo::getRomDirective(unsigned Size) const {
58 switch (Size) {
59 case 8: return RomData8bitsDirective;
60 case 16: return RomData16bitsDirective;
61 case 32: return RomData32bitsDirective;
62 default: return NULL;
63 }
Sanjiv Gupta3b020fe2009-02-02 16:53:06 +000064}
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000065
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000066
Chris Lattner83757c72009-07-20 17:12:46 +000067const char *PIC16TargetAsmInfo::
68getDataASDirective(unsigned Size, unsigned AS) const {
Sanjiv Gupta3b020fe2009-02-02 16:53:06 +000069 if (AS == PIC16ISD::ROM_SPACE)
Chris Lattner83757c72009-07-20 17:12:46 +000070 return getRomDirective(Size);
71 return NULL;
Sanjiv Gupta3b020fe2009-02-02 16:53:06 +000072}
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +000073
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000074const Section *
75PIC16TargetAsmInfo::getBSSSectionForGlobal(const GlobalVariable *GV) const {
Chris Lattnera46cb522009-07-21 17:20:18 +000076 assert(GV->hasInitializer() && "This global doesn't need space");
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000077 Constant *C = GV->getInitializer();
Chris Lattnera46cb522009-07-21 17:20:18 +000078 assert(C->isNullValue() && "Unitialized globals has non-zero initializer");
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000079
80 // Find how much space this global needs.
81 const TargetData *TD = TM.getTargetData();
82 const Type *Ty = C->getType();
Duncan Sands777d2302009-05-09 07:06:46 +000083 unsigned ValSize = TD->getTypeAllocSize(Ty);
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000084
85 // Go through all BSS Sections and assign this variable
86 // to the first available section having enough space.
87 PIC16Section *FoundBSS = NULL;
88 for (unsigned i = 0; i < BSSSections.size(); i++) {
89 if (DataBankSize - BSSSections[i]->Size >= ValSize) {
90 FoundBSS = BSSSections[i];
91 break;
92 }
93 }
94
95 // No BSS section spacious enough was found. Crate a new one.
Chris Lattnera46cb522009-07-21 17:20:18 +000096 if (!FoundBSS) {
Sanjiv Gupta211f3622009-05-10 05:23:47 +000097 std::string name = PAN::getUdataSectionName(BSSSections.size());
Chris Lattnera46cb522009-07-21 17:20:18 +000098 const Section *NewSection = getNamedSection(name.c_str());
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000099
100 FoundBSS = new PIC16Section(NewSection);
101
102 // Add this newly created BSS section to the list of BSSSections.
103 BSSSections.push_back(FoundBSS);
104 }
105
106 // Insert the GV into this BSS.
107 FoundBSS->Items.push_back(GV);
108 FoundBSS->Size += ValSize;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000109 return FoundBSS->S_;
110}
111
112const Section *
113PIC16TargetAsmInfo::getIDATASectionForGlobal(const GlobalVariable *GV) const {
Chris Lattnera46cb522009-07-21 17:20:18 +0000114 assert(GV->hasInitializer() && "This global doesn't need space");
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000115 Constant *C = GV->getInitializer();
Chris Lattnera46cb522009-07-21 17:20:18 +0000116 assert(!C->isNullValue() && "initialized globals has zero initializer");
117 assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE &&
118 "can split initialized RAM data only");
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000119
120 // Find how much space this global needs.
121 const TargetData *TD = TM.getTargetData();
122 const Type *Ty = C->getType();
Duncan Sands777d2302009-05-09 07:06:46 +0000123 unsigned ValSize = TD->getTypeAllocSize(Ty);
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000124
125 // Go through all IDATA Sections and assign this variable
126 // to the first available section having enough space.
127 PIC16Section *FoundIDATA = NULL;
128 for (unsigned i = 0; i < IDATASections.size(); i++) {
Chris Lattnera46cb522009-07-21 17:20:18 +0000129 if (DataBankSize - IDATASections[i]->Size >= ValSize) {
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000130 FoundIDATA = IDATASections[i];
131 break;
132 }
133 }
134
135 // No IDATA section spacious enough was found. Crate a new one.
Chris Lattnera46cb522009-07-21 17:20:18 +0000136 if (!FoundIDATA) {
Sanjiv Gupta211f3622009-05-10 05:23:47 +0000137 std::string name = PAN::getIdataSectionName(IDATASections.size());
Chris Lattnera46cb522009-07-21 17:20:18 +0000138 const Section *NewSection = getNamedSection(name.c_str());
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000139
140 FoundIDATA = new PIC16Section(NewSection);
141
142 // Add this newly created IDATA section to the list of IDATASections.
143 IDATASections.push_back(FoundIDATA);
144 }
145
146 // Insert the GV into this IDATA.
147 FoundIDATA->Items.push_back(GV);
148 FoundIDATA->Size += ValSize;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000149 return FoundIDATA->S_;
150}
151
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +0000152// Get the section for an automatic variable of a function.
153// For PIC16 they are globals only with mangled names.
154const Section *
155PIC16TargetAsmInfo::getSectionForAuto(const GlobalVariable *GV) const {
156
157 const std::string name = PAN::getSectionNameForSym(GV->getName());
158
159 // Go through all Auto Sections and assign this variable
160 // to the appropriate section.
161 PIC16Section *FoundAutoSec = NULL;
162 for (unsigned i = 0; i < AutosSections.size(); i++) {
Chris Lattnera46cb522009-07-21 17:20:18 +0000163 if (AutosSections[i]->S_->getName() == name) {
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +0000164 FoundAutoSec = AutosSections[i];
165 break;
166 }
167 }
168
169 // No Auto section was found. Crate a new one.
Chris Lattnera46cb522009-07-21 17:20:18 +0000170 if (!FoundAutoSec) {
171 const Section *NewSection = getNamedSection(name.c_str());
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +0000172
173 FoundAutoSec = new PIC16Section(NewSection);
174
175 // Add this newly created autos section to the list of AutosSections.
176 AutosSections.push_back(FoundAutoSec);
177 }
178
179 // Insert the auto into this section.
180 FoundAutoSec->Items.push_back(GV);
181
182 return FoundAutoSec->S_;
183}
184
185
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000186// Override default implementation to put the true globals into
187// multiple data sections if required.
188const Section*
Chris Lattnerf20f2502009-07-24 18:42:53 +0000189PIC16TargetAsmInfo::SelectSectionForGlobal(const GlobalValue *GV1,
Chris Lattner460d51e2009-07-25 23:21:55 +0000190 SectionKind Kind) const {
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000191 // We select the section based on the initializer here, so it really
192 // has to be a GlobalVariable.
Sanjiv Gupta211f3622009-05-10 05:23:47 +0000193 const GlobalVariable *GV = dyn_cast<GlobalVariable>(GV1);
Sanjiv Guptaad6585b2009-05-13 15:13:17 +0000194 if (!GV)
Chris Lattnerf20f2502009-07-24 18:42:53 +0000195 return TargetAsmInfo::SelectSectionForGlobal(GV1, Kind);
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000196
Chris Lattnerf20f2502009-07-24 18:42:53 +0000197 // Record External Var Decls.
Sanjiv Guptaad6585b2009-05-13 15:13:17 +0000198 if (GV->isDeclaration()) {
199 ExternalVarDecls->Items.push_back(GV);
200 return ExternalVarDecls->S_;
201 }
202
Chris Lattnera46cb522009-07-21 17:20:18 +0000203 assert(GV->hasInitializer() && "A def without initializer?");
Sanjiv Guptaad6585b2009-05-13 15:13:17 +0000204
Sanjiv Gupta211f3622009-05-10 05:23:47 +0000205 // First, if this is an automatic variable for a function, get the section
206 // name for it and return.
Chris Lattner7420ab22009-07-24 18:34:27 +0000207 std::string name = GV->getName();
208 if (PAN::isLocalName(name))
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +0000209 return getSectionForAuto(GV);
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000210
Sanjiv Guptaad6585b2009-05-13 15:13:17 +0000211 // Record Exteranl Var Defs.
Chris Lattner7420ab22009-07-24 18:34:27 +0000212 if (GV->hasExternalLinkage() || GV->hasCommonLinkage())
Sanjiv Guptaad6585b2009-05-13 15:13:17 +0000213 ExternalVarDefs->Items.push_back(GV);
Sanjiv Guptaad6585b2009-05-13 15:13:17 +0000214
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000215 // See if this is an uninitialized global.
Sanjiv Gupta211f3622009-05-10 05:23:47 +0000216 const Constant *C = GV->getInitializer();
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000217 if (C->isNullValue())
218 return getBSSSectionForGlobal(GV);
219
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +0000220 // If this is initialized data in RAM. Put it in the correct IDATA section.
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000221 if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE)
222 return getIDATASectionForGlobal(GV);
223
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +0000224 // This is initialized data in rom, put it in the readonly section.
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000225 if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE)
226 return getROSectionForGlobal(GV);
Sanjiv Gupta2364cfe2009-05-12 17:07:27 +0000227
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000228 // Else let the default implementation take care of it.
Chris Lattnerf20f2502009-07-24 18:42:53 +0000229 return TargetAsmInfo::SelectSectionForGlobal(GV, Kind);
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000230}
231
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000232PIC16TargetAsmInfo::~PIC16TargetAsmInfo() {
Chris Lattnerb3e71892009-07-20 22:23:48 +0000233 for (unsigned i = 0; i < BSSSections.size(); i++)
234 delete BSSSections[i];
235 for (unsigned i = 0; i < IDATASections.size(); i++)
236 delete IDATASections[i];
237 for (unsigned i = 0; i < AutosSections.size(); i++)
238 delete AutosSections[i];
239 for (unsigned i = 0; i < ROSections.size(); i++)
240 delete ROSections[i];
Sanjiv Guptaad6585b2009-05-13 15:13:17 +0000241 delete ExternalVarDecls;
242 delete ExternalVarDefs;
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000243}
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000244
Chris Lattner7420ab22009-07-24 18:34:27 +0000245
246/// getSpecialCasedSectionGlobals - Allow the target to completely override
247/// section assignment of a global.
248const Section *
249PIC16TargetAsmInfo::getSpecialCasedSectionGlobals(const GlobalValue *GV,
Chris Lattner460d51e2009-07-25 23:21:55 +0000250 SectionKind Kind) const {
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000251 // If GV has a sectin name or section address create that section now.
252 if (GV->hasSection()) {
Chris Lattner7c023d62009-07-24 17:13:27 +0000253 if (const GlobalVariable *GVar = cast<GlobalVariable>(GV)) {
254 std::string SectName = GVar->getSection();
255 // If address for a variable is specified, get the address and create
256 // section.
257 std::string AddrStr = "Address=";
258 if (SectName.compare(0, AddrStr.length(), AddrStr) == 0) {
259 std::string SectAddr = SectName.substr(AddrStr.length());
260 return CreateSectionForGlobal(GVar, SectAddr);
261 }
Chris Lattner74fb5452009-07-26 18:08:15 +0000262
263 // Create the section specified with section attribute.
264 return CreateSectionForGlobal(GVar);
Chris Lattner796131e2009-07-24 04:59:43 +0000265 }
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000266 }
Chris Lattner7420ab22009-07-24 18:34:27 +0000267
268 return 0;
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000269}
270
271// Create a new section for global variable. If Addr is given then create
272// section at that address else create by name.
273const Section *
Chris Lattner7c023d62009-07-24 17:13:27 +0000274PIC16TargetAsmInfo::CreateSectionForGlobal(const GlobalVariable *GV,
275 const std::string &Addr) const {
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000276 // See if this is an uninitialized global.
277 const Constant *C = GV->getInitializer();
278 if (C->isNullValue())
279 return CreateBSSSectionForGlobal(GV, Addr);
280
281 // If this is initialized data in RAM. Put it in the correct IDATA section.
282 if (GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE)
283 return CreateIDATASectionForGlobal(GV, Addr);
284
285 // This is initialized data in rom, put it in the readonly section.
286 if (GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE)
287 return CreateROSectionForGlobal(GV, Addr);
288
289 // Else let the default implementation take care of it.
290 return TargetAsmInfo::SectionForGlobal(GV);
291}
292
293// Create uninitialized section for a variable.
294const Section *
295PIC16TargetAsmInfo::CreateBSSSectionForGlobal(const GlobalVariable *GV,
296 std::string Addr) const {
Chris Lattnera46cb522009-07-21 17:20:18 +0000297 assert(GV->hasInitializer() && "This global doesn't need space");
298 assert(GV->getInitializer()->isNullValue() &&
299 "Unitialized global has non-zero initializer");
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000300 std::string Name;
301 // If address is given then create a section at that address else create a
302 // section by section name specified in GV.
303 PIC16Section *FoundBSS = NULL;
304 if (Addr.empty()) {
305 Name = GV->getSection() + " UDATA";
306 for (unsigned i = 0; i < BSSSections.size(); i++) {
307 if (BSSSections[i]->S_->getName() == Name) {
308 FoundBSS = BSSSections[i];
309 break;
310 }
311 }
Chris Lattnera46cb522009-07-21 17:20:18 +0000312 } else {
Daniel Dunbarf6ccee52009-07-24 08:24:36 +0000313 std::string Prefix = GV->getNameStr() + "." + Addr + ".";
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000314 Name = PAN::getUdataSectionName(BSSSections.size(), Prefix) + " " + Addr;
315 }
316
317 PIC16Section *NewBSS = FoundBSS;
318 if (NewBSS == NULL) {
Chris Lattnera46cb522009-07-21 17:20:18 +0000319 const Section *NewSection = getNamedSection(Name.c_str());
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000320 NewBSS = new PIC16Section(NewSection);
321 BSSSections.push_back(NewBSS);
322 }
323
324 // Insert the GV into this BSS.
325 NewBSS->Items.push_back(GV);
326
327 // We do not want to put any GV without explicit section into this section
328 // so set its size to DatabankSize.
329 NewBSS->Size = DataBankSize;
330 return NewBSS->S_;
331}
332
333// Get rom section for a variable. Currently there can be only one rom section
334// unless a variable explicitly requests a section.
335const Section *
336PIC16TargetAsmInfo::getROSectionForGlobal(const GlobalVariable *GV) const {
337 ROSections[0]->Items.push_back(GV);
338 return ROSections[0]->S_;
339}
340
341// Create initialized data section for a variable.
342const Section *
343PIC16TargetAsmInfo::CreateIDATASectionForGlobal(const GlobalVariable *GV,
344 std::string Addr) const {
Chris Lattnera46cb522009-07-21 17:20:18 +0000345 assert(GV->hasInitializer() && "This global doesn't need space");
346 assert(!GV->getInitializer()->isNullValue() &&
347 "initialized global has zero initializer");
348 assert(GV->getType()->getAddressSpace() == PIC16ISD::RAM_SPACE &&
349 "can be used for initialized RAM data only");
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000350
351 std::string Name;
352 // If address is given then create a section at that address else create a
353 // section by section name specified in GV.
354 PIC16Section *FoundIDATASec = NULL;
355 if (Addr.empty()) {
356 Name = GV->getSection() + " IDATA";
357 for (unsigned i = 0; i < IDATASections.size(); i++) {
358 if (IDATASections[i]->S_->getName() == Name) {
359 FoundIDATASec = IDATASections[i];
360 break;
361 }
362 }
Chris Lattnera46cb522009-07-21 17:20:18 +0000363 } else {
Daniel Dunbarf6ccee52009-07-24 08:24:36 +0000364 std::string Prefix = GV->getNameStr() + "." + Addr + ".";
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000365 Name = PAN::getIdataSectionName(IDATASections.size(), Prefix) + " " + Addr;
366 }
367
368 PIC16Section *NewIDATASec = FoundIDATASec;
369 if (NewIDATASec == NULL) {
Chris Lattnera46cb522009-07-21 17:20:18 +0000370 const Section *NewSection = getNamedSection(Name.c_str());
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000371 NewIDATASec = new PIC16Section(NewSection);
372 IDATASections.push_back(NewIDATASec);
373 }
374 // Insert the GV into this IDATA Section.
375 NewIDATASec->Items.push_back(GV);
376 // We do not want to put any GV without explicit section into this section
377 // so set its size to DatabankSize.
378 NewIDATASec->Size = DataBankSize;
379 return NewIDATASec->S_;
380}
381
382// Create a section in rom for a variable.
383const Section *
384PIC16TargetAsmInfo::CreateROSectionForGlobal(const GlobalVariable *GV,
385 std::string Addr) const {
Chris Lattnera46cb522009-07-21 17:20:18 +0000386 assert(GV->getType()->getAddressSpace() == PIC16ISD::ROM_SPACE &&
387 "can be used for ROM data only");
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000388
389 std::string Name;
390 // If address is given then create a section at that address else create a
391 // section by section name specified in GV.
392 PIC16Section *FoundROSec = NULL;
393 if (Addr.empty()) {
394 Name = GV->getSection() + " ROMDATA";
395 for (unsigned i = 1; i < ROSections.size(); i++) {
396 if (ROSections[i]->S_->getName() == Name) {
397 FoundROSec = ROSections[i];
398 break;
399 }
400 }
Chris Lattnera46cb522009-07-21 17:20:18 +0000401 } else {
Daniel Dunbarf6ccee52009-07-24 08:24:36 +0000402 std::string Prefix = GV->getNameStr() + "." + Addr + ".";
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000403 Name = PAN::getRomdataSectionName(ROSections.size(), Prefix) + " " + Addr;
404 }
405
406 PIC16Section *NewRomSec = FoundROSec;
407 if (NewRomSec == NULL) {
Chris Lattnera46cb522009-07-21 17:20:18 +0000408 const Section *NewSection = getNamedSection(Name.c_str());
Sanjiv Gupta505996f2009-07-06 10:18:37 +0000409 NewRomSec = new PIC16Section(NewSection);
410 ROSections.push_back(NewRomSec);
411 }
412
413 // Insert the GV into this ROM Section.
414 NewRomSec->Items.push_back(GV);
415 return NewRomSec->S_;
416}
417