blob: c0b1f6e86072b99a1d64c9ce13e4f90728f5c8d1 [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 Guptad0765702009-03-12 02:10:45 +000048 std::string NewBank = "";
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000049 unsigned Operands = MI->getNumOperands();
50 if (Operands > 1) {
51 // Global address or external symbol should be second operand from last
52 // if we want to print banksel for it.
Sanjiv Guptad0765702009-03-12 02:10:45 +000053 unsigned BankSelVar = Operands - 2;
54 // In cases where an instruction has a def or use defined in td file,
55 // that def or use becomes a machine instruction operand.
56 // eg. addfw_1 instruction defines STATUS register. So the machine
57 // instruction for it has MO_Register Operand as its last operand.
58 while ((MI->getOperand(BankSelVar + 1).getType() ==
59 MachineOperand::MO_Register) && (BankSelVar > 0))
60 BankSelVar--;
61 const MachineOperand &Op = MI->getOperand(BankSelVar);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000062 unsigned OpType = Op.getType();
63 if (OpType == MachineOperand::MO_GlobalAddress ||
Sanjiv Guptad0765702009-03-12 02:10:45 +000064 OpType == MachineOperand::MO_ExternalSymbol) {
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000065 if (OpType == MachineOperand::MO_GlobalAddress )
Sanjiv Guptad0765702009-03-12 02:10:45 +000066 NewBank = Op.getGlobal()->getSection();
67 else {
68 // External Symbol is generated for temp data. Temp data in in
69 // fdata.<functionname>.# section.
70 NewBank = "fdata." + CurrentFnName +".#";
71 }
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000072 // Operand after global address or external symbol should be banksel.
73 // Value 1 for this operand means we need to generate banksel else do not
74 // generate banksel.
Sanjiv Guptad0765702009-03-12 02:10:45 +000075 const MachineOperand &BS = MI->getOperand(BankSelVar+1);
76 // If Section names are same then the variables are in same section.
77 // This is not true for external variables as section names for global
78 // variables in all files are same at this time. For eg. initialized
79 // data in put in idata.# section in all files.
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000080 if (((int)BS.getImm() == 1) &&
Sanjiv Guptad0765702009-03-12 02:10:45 +000081 ((Op.isGlobal() && Op.getGlobal()->hasExternalLinkage()) ||
82 (NewBank.compare(CurBank) != 0))) {
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000083 O << "\tbanksel ";
Sanjiv Guptad0765702009-03-12 02:10:45 +000084 printOperand(MI, BankSelVar);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000085 O << "\n";
Sanjiv Guptad0765702009-03-12 02:10:45 +000086 CurBank = NewBank;
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +000087 }
88 }
89 }
90 printInstruction(MI);
91 return true;
92}
93
94/// runOnMachineFunction - This uses the printInstruction()
95/// method to print assembly for each instruction.
96///
97bool PIC16AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
Bill Wendling57f0db82009-02-24 08:30:20 +000098 this->MF = &MF;
99
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000100 // This calls the base class function required to be called at beginning
101 // of runOnMachineFunction.
102 SetupMachineFunction(MF);
103
104 // Get the mangled name.
105 const Function *F = MF.getFunction();
106 CurrentFnName = Mang->getValueName(F);
107
108 // Emit the function variables.
109 emitFunctionData(MF);
110 std::string codeSection;
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000111 codeSection = "code." + CurrentFnName + ".# " + "CODE";
112 const Section *fCodeSection = TAI->getNamedSection(codeSection.c_str(),
113 SectionFlags::Code);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000114 O << "\n";
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000115 SwitchToSection (fCodeSection);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000116
117 // Print out code for the function.
118 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
119 I != E; ++I) {
120 // Print a label for the basic block.
121 if (I != MF.begin()) {
122 printBasicBlockLabel(I, true);
123 O << '\n';
124 }
125 else
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000126 O << CurrentFnName << ":\n";
Sanjiv Guptad0765702009-03-12 02:10:45 +0000127 CurBank = "";
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000128 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
129 II != E; ++II) {
130 // Print the assembly for the instruction.
131 printMachineInstruction(II);
132 }
133 }
134 return false; // we didn't modify anything.
135}
136
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000137/// createPIC16CodePrinterPass - Returns a pass that prints the PIC16
138/// assembly code for a MachineFunction to the given output stream,
139/// using the given target machine description. This should work
140/// regardless of whether the function is in SSA form.
141///
Owen Andersoncb371882008-08-21 00:14:44 +0000142FunctionPass *llvm::createPIC16CodePrinterPass(raw_ostream &o,
Bill Wendling57f0db82009-02-24 08:30:20 +0000143 PIC16TargetMachine &tm,
Evan Cheng42bf74b2009-03-25 01:47:28 +0000144 bool fast, bool verbose) {
145 return new PIC16AsmPrinter(o, tm, tm.getTargetAsmInfo(), fast, verbose);
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000146}
147
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000148void PIC16AsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000149 const MachineOperand &MO = MI->getOperand(opNum);
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000150
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000151 switch (MO.getType()) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000152 case MachineOperand::MO_Register:
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000153 if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000154 O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000155 else
156 assert(0 && "not implemented");
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000157 return;
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000158
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000159 case MachineOperand::MO_Immediate:
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000160 O << (int)MO.getImm();
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000161 return;
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000162
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000163 case MachineOperand::MO_GlobalAddress:
164 O << Mang->getValueName(MO.getGlobal());
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000165 break;
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000166
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000167 case MachineOperand::MO_ExternalSymbol:
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000168 O << MO.getSymbolName();
169 break;
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000170
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000171 case MachineOperand::MO_MachineBasicBlock:
172 printBasicBlockLabel(MO.getMBB());
173 return;
174
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000175 default:
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000176 assert(0 && " Operand type not supported.");
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000177 }
178}
179
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000180void PIC16AsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) {
181 int CC = (int)MI->getOperand(opNum).getImm();
182 O << PIC16CondCodeToString((PIC16CC::CondCodes)CC);
183}
184
185
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000186bool PIC16AsmPrinter::doInitialization (Module &M) {
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000187 bool Result = AsmPrinter::doInitialization(M);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000188 // FIXME:: This is temporary solution to generate the include file.
189 // The processor should be passed to llc as in input and the header file
190 // should be generated accordingly.
191 O << "\t#include P16F1937.INC\n";
Sanjiv Gupta5274a4a2009-04-02 18:03:10 +0000192 MachineModuleInfo *MMI = getAnalysisIfAvailable<MachineModuleInfo>();
193 assert(MMI);
194 DwarfWriter *DW = getAnalysisIfAvailable<DwarfWriter>();
195 assert(DW && "Dwarf Writer is not available");
196 DW->BeginModule(&M, MMI, O, this, TAI);
197
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000198 EmitExternsAndGlobals (M);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000199 EmitInitData (M);
200 EmitUnInitData(M);
201 EmitRomData(M);
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000202 return Result;
203}
204
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000205void PIC16AsmPrinter::EmitExternsAndGlobals (Module &M) {
206 // Emit declarations for external functions.
207 O << "section.0" <<"\n";
208 for (Module::iterator I = M.begin(), E = M.end(); I != E; I++) {
209 std::string Name = Mang->getValueName(I);
210 if (Name.compare("abort") == 0)
211 continue;
212 if (I->isDeclaration()) {
213 O << "\textern " <<Name << "\n";
214 O << "\textern " << Name << ".retval\n";
215 O << "\textern " << Name << ".args\n";
216 }
217 else if (I->hasExternalLinkage()) {
218 O << "\tglobal " << Name << "\n";
219 O << "\tglobal " << Name << ".retval\n";
220 O << "\tglobal " << Name << ".args\n";
221 }
222 }
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000223
224 // Emit header file to include declaration of library functions
225 O << "\t#include C16IntrinsicCalls.INC\n";
226
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000227 // Emit declarations for external globals.
228 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
229 I != E; I++) {
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000230 // Any variables reaching here with ".auto." in its name is a local scope
231 // variable and should not be printed in global data section.
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000232 std::string Name = Mang->getValueName(I);
Sanjiv Guptad0765702009-03-12 02:10:45 +0000233 if (isLocalName (Name))
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000234 continue;
235
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000236 if (I->isDeclaration())
237 O << "\textern "<< Name << "\n";
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000238 else if (I->hasCommonLinkage() || I->hasExternalLinkage())
Sanjiv Guptaa2d8b062009-02-06 18:24:59 +0000239 O << "\tglobal "<< Name << "\n";
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000240 }
241}
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000242
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000243void PIC16AsmPrinter::EmitInitData (Module &M) {
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000244 SwitchToSection(TAI->getDataSection());
Sanjiv Guptad0765702009-03-12 02:10:45 +0000245 for (Module::global_iterator I = M.global_begin(), E = M.global_end();
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000246 I != E; ++I) {
247 if (!I->hasInitializer()) // External global require no code.
248 continue;
249
250 Constant *C = I->getInitializer();
251 const PointerType *PtrTy = I->getType();
252 int AddrSpace = PtrTy->getAddressSpace();
253
254 if ((!C->isNullValue()) && (AddrSpace == PIC16ISD::RAM_SPACE)) {
255
256 if (EmitSpecialLLVMGlobal(I))
257 continue;
258
259 // Any variables reaching here with "." in its name is a local scope
260 // variable and should not be printed in global data section.
Sanjiv Guptad0765702009-03-12 02:10:45 +0000261 std::string Name = Mang->getValueName(I);
262 if (isLocalName(Name))
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000263 continue;
264
Sanjiv Guptad0765702009-03-12 02:10:45 +0000265 I->setSection(TAI->getDataSection()->getName());
266 O << Name;
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +0000267 EmitGlobalConstant(C, AddrSpace);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000268 }
269 }
270}
271
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000272void PIC16AsmPrinter::EmitRomData (Module &M)
273{
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000274 SwitchToSection(TAI->getReadOnlySection());
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000275 IsRomData = true;
Sanjiv Guptad0765702009-03-12 02:10:45 +0000276 for (Module::global_iterator I = M.global_begin(), E = M.global_end();
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000277 I != E; ++I) {
278 if (!I->hasInitializer()) // External global require no code.
279 continue;
280
281 Constant *C = I->getInitializer();
282 const PointerType *PtrTy = I->getType();
283 int AddrSpace = PtrTy->getAddressSpace();
284 if ((!C->isNullValue()) && (AddrSpace == PIC16ISD::ROM_SPACE)) {
285
286 if (EmitSpecialLLVMGlobal(I))
287 continue;
288
289 // Any variables reaching here with "." in its name is a local scope
290 // variable and should not be printed in global data section.
291 std::string name = Mang->getValueName(I);
292 if (name.find(".") != std::string::npos)
293 continue;
294
Sanjiv Guptad0765702009-03-12 02:10:45 +0000295 I->setSection(TAI->getReadOnlySection()->getName());
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000296 O << name;
Sanjiv Guptac8d7bc82009-01-30 04:25:10 +0000297 EmitGlobalConstant(C, AddrSpace);
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000298 O << "\n";
299 }
300 }
301 IsRomData = false;
302}
303
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000304void PIC16AsmPrinter::EmitUnInitData (Module &M)
305{
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000306 SwitchToSection(TAI->getBSSSection_());
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000307 const TargetData *TD = TM.getTargetData();
308
Sanjiv Guptad0765702009-03-12 02:10:45 +0000309 for (Module::global_iterator I = M.global_begin(), E = M.global_end();
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000310 I != E; ++I) {
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000311 if (!I->hasInitializer()) // External global require no code.
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000312 continue;
313
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000314 Constant *C = I->getInitializer();
315 if (C->isNullValue()) {
316
317 if (EmitSpecialLLVMGlobal(I))
318 continue;
319
320 // Any variables reaching here with "." in its name is a local scope
321 // variable and should not be printed in global data section.
322 std::string name = Mang->getValueName(I);
323 if (name.find(".") != std::string::npos)
324 continue;
325
Sanjiv Guptad0765702009-03-12 02:10:45 +0000326 I->setSection(TAI->getBSSSection_()->getName());
327
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000328 const Type *Ty = C->getType();
Duncan Sandsceb4d1a2009-01-12 20:38:59 +0000329 unsigned Size = TD->getTypePaddedSize(Ty);
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000330
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000331 O << name << " " <<"RES"<< " " << Size ;
332 O << "\n";
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000333 }
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000334 }
335}
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000336
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000337bool PIC16AsmPrinter::doFinalization(Module &M) {
338 O << "\t" << "END\n";
339 bool Result = AsmPrinter::doFinalization(M);
340 return Result;
341}
342
343void PIC16AsmPrinter::emitFunctionData(MachineFunction &MF) {
344 const Function *F = MF.getFunction();
345 std::string FuncName = Mang->getValueName(F);
Sanjiv Guptad0765702009-03-12 02:10:45 +0000346 Module *M = const_cast<Module *>(F->getParent());
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000347 const TargetData *TD = TM.getTargetData();
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000348 unsigned FrameSize = 0;
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000349 // Emit the data section name.
350 O << "\n";
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000351 std::string SectionName = "fdata." + CurrentFnName + ".# " + "UDATA";
352
353 const Section *fDataSection = TAI->getNamedSection(SectionName.c_str(),
354 SectionFlags::Writeable);
355 SwitchToSection(fDataSection);
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000356
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000357
358 // Emit function frame label
359 O << CurrentFnName << ".frame:\n";
360
Sanjiv Gupta8f78fa82008-11-26 10:53:50 +0000361 const Type *RetType = F->getReturnType();
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000362 unsigned RetSize = 0;
363 if (RetType->getTypeID() != Type::VoidTyID)
364 RetSize = TD->getTypePaddedSize(RetType);
365
Sanjiv Guptab84d5a42009-04-02 17:42:00 +0000366 //Emit function return value space
367 if(RetSize > 0)
368 O << CurrentFnName << ".retval RES " << RetSize << "\n";
369 else
370 O << CurrentFnName << ".retval:\n";
371
372 // Emit variable to hold the space for function arguments
373 unsigned ArgSize = 0;
374 for (Function::const_arg_iterator argi = F->arg_begin(),
375 arge = F->arg_end(); argi != arge ; ++argi) {
376 const Type *Ty = argi->getType();
377 ArgSize += TD->getTypePaddedSize(Ty);
378 }
379 O << CurrentFnName << ".args RES " << ArgSize << "\n";
380
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000381 // Emit the function variables.
382
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000383 // In PIC16 all the function arguments and local variables are global.
384 // Therefore to get the variable belonging to this function entire
385 // global list will be traversed and variables belonging to this function
386 // will be emitted in the current data section.
Sanjiv Guptad0765702009-03-12 02:10:45 +0000387 for (Module::global_iterator I = M->global_begin(), E = M->global_end();
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000388 I != E; ++I) {
389 std::string VarName = Mang->getValueName(I);
390
391 // The variables of a function are of form FuncName.* . If this variable
392 // does not belong to this function then continue.
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000393 // Static local varilabes of a function does not have .auto. in their
394 // name. They are not printed as part of function data but module
395 // level global data.
Sanjiv Guptad0765702009-03-12 02:10:45 +0000396 if (! isLocalToFunc(FuncName, VarName))
397 continue;
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000398
Sanjiv Guptad0765702009-03-12 02:10:45 +0000399 I->setSection("fdata." + CurrentFnName + ".#");
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000400 Constant *C = I->getInitializer();
Sanjiv Gupta2010b3e2008-05-14 11:31:39 +0000401 const Type *Ty = C->getType();
Duncan Sandsceb4d1a2009-01-12 20:38:59 +0000402 unsigned Size = TD->getTypePaddedSize(Ty);
Sanjiv Gupta1b046942009-01-13 19:18:47 +0000403 FrameSize += Size;
Sanjiv Guptab1b5ffd2008-11-19 11:00:54 +0000404 // Emit memory reserve directive.
405 O << VarName << " RES " << Size << "\n";
406 }
Sanjiv Gupta2cc75312009-02-10 04:20:26 +0000407
Sanjiv Guptacae1b622009-04-06 10:54:50 +0000408 int TempSize = PTLI->GetTmpSize();
409 if (TempSize > 0 )
410 O << CurrentFnName << ".tmp RES " << TempSize <<"\n";
Sanjiv Gupta0e687712008-05-13 09:02:57 +0000411}