blob: 51787b85acf1820e5d48f18159092f6736d1f2ff [file] [log] [blame]
Sanjiv Gupta0e687712008-05-13 09:02:57 +00001//===-- PIC16AsmPrinter.cpp - PIC16 LLVM assembly writer ------------------===//
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 a printer that converts from our internal representation
11// of machine-dependent LLVM code to PIC16 assembly language.
12//
13//===----------------------------------------------------------------------===//
14
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000015#include "PIC16AsmPrinter.h"
16#include "PIC16TargetAsmInfo.h"
Bill Wendlingcb819f12009-02-18 23:12:06 +000017#include "llvm/DerivedTypes.h"
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000018#include "llvm/Function.h"
19#include "llvm/Module.h"
Bill Wendlingcb819f12009-02-18 23:12:06 +000020#include "llvm/CodeGen/DwarfWriter.h"
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000021#include "llvm/CodeGen/MachineFrameInfo.h"
Bill Wendlingcb819f12009-02-18 23:12:06 +000022#include "llvm/Support/raw_ostream.h"
23#include "llvm/Support/Mangler.h"
Sanjiv Gupta5274a4a2009-04-02 18:03:10 +000024#include "llvm/CodeGen/DwarfWriter.h"
25#include "llvm/CodeGen/MachineModuleInfo.h"
Sanjiv Gupta0e687712008-05-13 09:02:57 +000026
27using namespace llvm;
28
Sanjiv Gupta0e687712008-05-13 09:02:57 +000029#include "PIC16GenAsmWriter.inc"
Sanjiv Gupta1b046942009-01-13 19:18:47 +000030
Sanjiv Guptad0765702009-03-12 02:10:45 +000031inline static bool isLocalToFunc (std::string &FuncName, std::string &VarName) {
32 if (VarName.find(FuncName + ".auto.") != std::string::npos
33 || VarName.find(FuncName + ".arg.") != std::string::npos)
Sanjiv Gupta1b046942009-01-13 19:18:47 +000034 return true;
Sanjiv Gupta1b046942009-01-13 19:18:47 +000035
Sanjiv Guptad0765702009-03-12 02:10:45 +000036 return false;
37}
38
39inline static bool isLocalName (std::string &Name) {
40 if (Name.find(".auto.") != std::string::npos
41 || Name.find(".arg.") != std::string::npos)
42 return true;
43
Sanjiv Gupta1b046942009-01-13 19:18:47 +000044 return false;
45}
Sanjiv Gupta0e687712008-05-13 09:02:57 +000046
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000047bool PIC16AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000048 printInstruction(MI);
49 return true;
50}
51
52/// runOnMachineFunction - This uses the printInstruction()
53/// method to print assembly for each instruction.
54///
55bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
Bill Wendling57f0db82009-02-24 08:30:20 +000056 this->MF = &MF;
57
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000058 // This calls the base class function required to be called at beginning
59 // of runOnMachineFunction.
60 SetupMachineFunction(MF);
61
62 // Get the mangled name.
63 const Function *F = MF.getFunction();
64 CurrentFnName = Mang->getValueName(F);
65
66 // Emit the function variables.
67 emitFunctionData(MF);
68 std::string codeSection;
Sanjiv Gupta1b046942009-01-13 19:18:47 +000069 codeSection = "code." + CurrentFnName + ".# " + "CODE";
70 const Section *fCodeSection = TAI->getNamedSection(codeSection.c_str(),
71 SectionFlags::Code);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000072 O << "\n";
Sanjiv Gupta1b046942009-01-13 19:18:47 +000073 SwitchToSection (fCodeSection);
Sanjiv Guptac1fa70c2009-04-08 06:24:04 +000074
75 // Emit the frame address of the function at the beginning of code.
Sanjiv Guptad8d27f42009-05-06 08:02:01 +000076 O << " retlw low(" << FunctionLabelBegin<< CurrentFnName << ".frame.)\n";
77 O << " retlw high(" << FunctionLabelBegin<< CurrentFnName << ".frame.)\n";
Sanjiv Guptadd92dba2009-04-22 12:02:36 +000078 O << CurrentFnName << ":\n";
Sanjiv Gupta7836fc12009-04-08 05:38:48 +000079
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000080
81 // Print out code for the function.
82 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
83 I != E; ++I) {
84 // Print a label for the basic block.
85 if (I != MF.begin()) {
86 printBasicBlockLabel(I, true);
87 O << '\n';
88 }
Sanjiv Guptac1fa70c2009-04-08 06:24:04 +000089
90 // For emitting line directives, we need to keep track of the current
91 // source line. When it changes then only emit the line directive.
92 unsigned CurLine = 0;
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000093 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
94 II != E; ++II) {
Sanjiv Guptac1fa70c2009-04-08 06:24:04 +000095 // Emit the line directive if source line changed.
96 const DebugLoc DL = II->getDebugLoc();
97 if (!DL.isUnknown()) {
98 unsigned line = MF.getDebugLocTuple(DL).Line;
99 if (line != CurLine) {
100 O << "\t.line " << line << "\n";
101 CurLine = line;
102 }
103 }
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000104 // Print the assembly for the instruction.
Sanjiv Guptac1fa70c2009-04-08 06:24:04 +0000105 printMachineInstruction(II);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000106 }
107 }
108 return false; // we didn't modify anything.
109}
110
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000111/// createPIC16CodePrinterPass - Returns a pass that prints the PIC16
112/// assembly code for a MachineFunction to the given output stream,
113/// using the given target machine description. This should work
114/// regardless of whether the function is in SSA form.
115///
Owen Andersoncb371882008-08-21 00:14:44 +0000116FunctionPass *llvm::createPIC16CodePrinterPass(raw_ostream &o,
Bill Wendling57f0db82009-02-24 08:30:20 +0000117 PIC16TargetMachine &tm,
Bill Wendling98a366d2009-04-29 23:29:43 +0000118 CodeGenOpt::Level OptLevel,
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +0000119 bool verbose) {
120 return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose);
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000121}
122
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000123void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000124 const MachineOperand &MO = MI->getOperand(opNum);
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000125
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000126 switch (MO.getType()) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000127 case MachineOperand::MO_Register:
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000128 if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000129 O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000130 else
131 assert(0 && "not implemented");
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000132 return;
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000133
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000134 case MachineOperand::MO_Immediate:
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000135 O << (int)MO.getImm();
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000136 return;
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000137
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000138 case MachineOperand::MO_GlobalAddress: {
139 std::string Name = Mang->getValueName(MO.getGlobal());
140 if (isLocalName(Name))
141 O << FunctionLabelBegin << Mang->getValueName(MO.getGlobal());
142 else
143 O << Mang->getValueName(MO.getGlobal());
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000144 break;
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000145 }
146 case MachineOperand::MO_ExternalSymbol: {
147 std::string Name = MO.getSymbolName();
148 if (Name.find("__intrinsics.") != std::string::npos)
149 O << MO.getSymbolName();
150 else
151 O << FunctionLabelBegin << MO.getSymbolName();
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000152 break;
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000153 }
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000154 case MachineOperand::MO_MachineBasicBlock:
155 printBasicBlockLabel(MO.getMBB());
156 return;
157
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000158 default:
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000159 assert(0 && " Operand type not supported.");
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000160 }
161}
162
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000163void PIC16AsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) {
164 int CC = (int)MI->getOperand(opNum).getImm();
165 O << PIC16CondCodeToString((PIC16CC::CondCodes)CC);
166}
167
168
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000169bool PIC16AsmPrinter::doInitialization (Module &M) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000170 bool Result = AsmPrinter::doInitialization(M);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000171 // FIXME:: This is temporary solution to generate the include file.
172 // The processor should be passed to llc as in input and the header file
173 // should be generated accordingly.
174 O << "\t#include P16F1937.INC\n";
Sanjiv Gupta5274a4a2009-04-02 18:03:10 +0000175 MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
176 assert(MMI);
177 DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
178 assert(DW && "Dwarf Writer is not available");
179 DW->BeginModule(&M, MMI, O, this, TAI);
180
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000181 EmitExternsAndGlobals (M);
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000182 EmitGlobalData(M);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000183 EmitRomData(M);
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000184 return Result;
185}
186
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000187void PIC16AsmPrinter::EmitExternsAndGlobals (Module &M) {
188 // Emit declarations for external functions.
189 O << "section.0" <<"\n";
190 for (Module::iterator I = M.begin(), E = M.end(); I != E; I++) {
191 std::string Name = Mang->getValueName(I);
192 if (Name.compare("abort") == 0)
193 continue;
Sanjiv Gupta85be4082009-04-14 02:49:52 +0000194
195 // If it is llvm intrinsic call then don't emit
196 if (Name.find("llvm.") != std::string::npos)
197 continue;
198
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000199 if (I->isDeclaration()) {
200 O << "\textern " <<Name << "\n";
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000201 O << "\textern " << FunctionLabelBegin << Name << ".ret.\n";
202 O << "\textern " << FunctionLabelBegin << Name << ".args.\n";
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000203 }
204 else if (I->hasExternalLinkage()) {
205 O << "\tglobal " << Name << "\n";
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000206 O << "\tglobal " << FunctionLabelBegin << Name << ".ret.\n";
207 O << "\tglobal " << FunctionLabelBegin<< Name << ".args.\n";
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000208 }
209 }
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000210
211 // Emit header file to include declaration of library functions
212 O << "\t#include C16IntrinsicCalls.INC\n";
213
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000214 // Emit declarations for external globals.
215 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
216 I != E; I++) {
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000217 // Any variables reaching here with ".auto." in its name is a local scope
218 // variable and should not be printed in global data section.
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000219 std::string Name = Mang->getValueName(I);
Sanjiv Guptad0765702009-03-12 02:10:45 +0000220 if (isLocalName (Name))
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000221 continue;
222
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000223 if (I->isDeclaration())
224 O << "\textern "<< Name << "\n";
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000225 else if (I->hasCommonLinkage() || I->hasExternalLinkage())
Sanjiv Guptaa2d8b062009-02-06 18:24:59 +0000226 O << "\tglobal "<< Name << "\n";
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000227 }
228}
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000229
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000230void PIC16AsmPrinter::EmitRomData (Module &M)
231{
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000232 SwitchToSection(TAI->getReadOnlySection());
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000233 IsRomData = true;
Sanjiv Guptad0765702009-03-12 02:10:45 +0000234 for (Module::global_iterator I = M.global_begin(), E = M.global_end();
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000235 I != E; ++I) {
236 if (!I->hasInitializer()) // External global require no code.
237 continue;
238
239 Constant *C = I->getInitializer();
240 const PointerType *PtrTy = I->getType();
241 int AddrSpace = PtrTy->getAddressSpace();
242 if ((!C->isNullValue()) && (AddrSpace == PIC16ISD::ROM_SPACE)) {
243
244 if (EmitSpecialLLVMGlobal(I))
245 continue;
246
247 // Any variables reaching here with "." in its name is a local scope
248 // variable and should not be printed in global data section.
249 std::string name = Mang->getValueName(I);
250 if (name.find(".") != std::string::npos)
251 continue;
252
Sanjiv Guptad0765702009-03-12 02:10:45 +0000253 I->setSection(TAI->getReadOnlySection()->getName());
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000254 O << name;
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +0000255 EmitGlobalConstant(C, AddrSpace);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000256 O << "\n";
257 }
258 }
259 IsRomData = false;
260}
261
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000262bool PIC16AsmPrinter::doFinalization(Module &M) {
263 O << "\t" << "END\n";
264 bool Result = AsmPrinter::doFinalization(M);
265 return Result;
266}
267
268void PIC16AsmPrinter::emitFunctionData(MachineFunction &MF) {
269 const Function *F = MF.getFunction();
270 std::string FuncName = Mang->getValueName(F);
Sanjiv Guptad0765702009-03-12 02:10:45 +0000271 Module *M = const_cast<Module *>(F->getParent());
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000272 const TargetData *TD = TM.getTargetData();
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000273 unsigned FrameSize = 0;
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000274 // Emit the data section name.
275 O << "\n";
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000276 std::string SectionName = "fpdata." + CurrentFnName + ".# " + "UDATA_OVR";
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000277
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000278 const Section *fPDataSection = TAI->getNamedSection(SectionName.c_str(),
279 SectionFlags::Writeable);
280 SwitchToSection(fPDataSection);
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000281
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000282
283 // Emit function frame label
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000284 O << FunctionLabelBegin << CurrentFnName << ".frame.:\n";
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000285
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000286 const Type *RetType = F->getReturnType();
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000287 unsigned RetSize = 0;
288 if (RetType->getTypeID() != Type::VoidTyID)
Duncan Sands777d2302009-05-09 07:06:46 +0000289 RetSize = TD->getTypeAllocSize(RetType);
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000290
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000291 //Emit function return value space
292 if(RetSize > 0)
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000293 O << FunctionLabelBegin << CurrentFnName << ".ret. RES " << RetSize
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000294 << "\n";
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000295 else
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000296 O << FunctionLabelBegin << CurrentFnName << ".ret.:\n";
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000297
298 // Emit variable to hold the space for function arguments
299 unsigned ArgSize = 0;
300 for (Function::const_arg_iterator argi = F->arg_begin(),
301 arge = F->arg_end(); argi != arge ; ++argi) {
302 const Type *Ty = argi->getType();
Duncan Sands777d2302009-05-09 07:06:46 +0000303 ArgSize += TD->getTypeAllocSize(Ty);
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000304 }
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000305 O << FunctionLabelBegin << CurrentFnName << ".args. RES " << ArgSize
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000306 << "\n";
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000307
Sanjiv Gupta85be4082009-04-14 02:49:52 +0000308 // Emit temporary space
309 int TempSize = PTLI->GetTmpSize();
310 if (TempSize > 0 )
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000311 O << FunctionLabelBegin << CurrentFnName << ".temp. RES " << TempSize
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000312 <<"\n";
313
314 // Emit the section name for local variables.
315 O << "\n";
316 std::string SecNameLocals = "fadata." + CurrentFnName + ".# " + "UDATA_OVR";
317
318 const Section *fADataSection = TAI->getNamedSection(SecNameLocals.c_str(),
319 SectionFlags::Writeable);
320 SwitchToSection(fADataSection);
Sanjiv Gupta85be4082009-04-14 02:49:52 +0000321
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000322 // Emit the function variables.
323
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000324 // In PIC16 all the function arguments and local variables are global.
325 // Therefore to get the variable belonging to this function entire
326 // global list will be traversed and variables belonging to this function
327 // will be emitted in the current data section.
Sanjiv Guptad0765702009-03-12 02:10:45 +0000328 for (Module::global_iterator I = M->global_begin(), E = M->global_end();
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000329 I != E; ++I) {
330 std::string VarName = Mang->getValueName(I);
331
332 // The variables of a function are of form FuncName.* . If this variable
333 // does not belong to this function then continue.
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000334 // Static local varilabes of a function does not have .auto. in their
335 // name. They are not printed as part of function data but module
336 // level global data.
Sanjiv Guptad0765702009-03-12 02:10:45 +0000337 if (! isLocalToFunc(FuncName, VarName))
338 continue;
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000339
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000340 I->setSection("fadata." + CurrentFnName + ".#");
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000341 Constant *C = I->getInitializer();
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000342 const Type *Ty = C->getType();
Duncan Sands777d2302009-05-09 07:06:46 +0000343 unsigned Size = TD->getTypeAllocSize(Ty);
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000344 FrameSize += Size;
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000345 // Emit memory reserve directive.
Sanjiv Gupta2bdf4902009-04-20 16:59:35 +0000346 O << FunctionLabelBegin << VarName << " RES " << Size << "\n";
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000347 }
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000348}
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000349
350void PIC16AsmPrinter::EmitGlobalData (Module &M)
351{
352 const PIC16TargetAsmInfo *PTAI = static_cast<const PIC16TargetAsmInfo *>(TAI);
353 const_cast<PIC16TargetAsmInfo *>(PTAI)->SetSectionForGVs(M);
354 const TargetData *TD = TM.getTargetData();
355
356 std::vector <PIC16Section *>IDATASections = PTAI->getIDATASections();
357 for (unsigned i = 0; i < IDATASections.size(); i++) {
358 SwitchToSection(IDATASections[i]->S_);
359 std::vector<const GlobalVariable*> Items = IDATASections[i]->Items;
360 for (unsigned j = 0; j < Items.size(); j++) {
361 std::string Name = Mang->getValueName(Items[j]);
362 Constant *C = Items[j]->getInitializer();
363 int AddrSpace = Items[j]->getType()->getAddressSpace();
364 O << Name;
365 EmitGlobalConstant(C, AddrSpace);
366 }
367 }
368
369 std::vector <PIC16Section *>BSSSections = PTAI->getBSSSections();
370 for (unsigned i = 0; i < BSSSections.size(); i++) {
371 SwitchToSection(BSSSections[i]->S_);
372 std::vector<const GlobalVariable*> Items = BSSSections[i]->Items;
373 for (unsigned j = 0; j < Items.size(); j++) {
374 std::string Name = Mang->getValueName(Items[j]);
375 Constant *C = Items[j]->getInitializer();
376 const Type *Ty = C->getType();
Duncan Sands777d2302009-05-09 07:06:46 +0000377 unsigned Size = TD->getTypeAllocSize(Ty);
Sanjiv Guptad8d27f42009-05-06 08:02:01 +0000378
379 O << Name << " " <<"RES"<< " " << Size ;
380 O << "\n";
381 }
382 }
383}
384