blob: a3e9211f5c34b0316b5849773f5625844973ea0f [file] [log] [blame]
Chris Lattner6b944532002-10-28 01:16:38 +00001//===-- MachineFunction.cpp -----------------------------------------------===//
Chris Lattnerf2868ce2002-02-03 07:54:50 +00002//
John Criswellb576c942003-10-20 19:43:21 +00003// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
Chris Lattner6b944532002-10-28 01:16:38 +000010// Collect native machine code information for a function. This allows
11// target-specific information about the generated code to be stored with each
12// function.
13//
14//===----------------------------------------------------------------------===//
Chris Lattnerf2868ce2002-02-03 07:54:50 +000015
Chris Lattner16c45e92003-12-20 10:20:58 +000016#include "llvm/CodeGen/MachineFunctionPass.h"
Chris Lattner831fdcf2002-12-25 05:03:22 +000017#include "llvm/CodeGen/MachineInstr.h"
Chris Lattner831fdcf2002-12-25 05:03:22 +000018#include "llvm/CodeGen/SSARegMap.h"
Chris Lattner955fad12002-12-28 20:37:16 +000019#include "llvm/CodeGen/MachineFunctionInfo.h"
Chris Lattnereb24db92002-12-28 21:08:26 +000020#include "llvm/CodeGen/MachineFrameInfo.h"
Chris Lattner4d149cd2003-01-13 00:23:03 +000021#include "llvm/CodeGen/MachineConstantPool.h"
Chris Lattner16c45e92003-12-20 10:20:58 +000022#include "llvm/CodeGen/Passes.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000023#include "llvm/Target/TargetMachine.h"
Chris Lattner8bd66e62002-12-28 21:00:25 +000024#include "llvm/Target/TargetFrameInfo.h"
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000025#include "llvm/Function.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000026#include "llvm/iOther.h"
Tanya Lattner792699c2004-05-24 06:11:51 +000027#include "Support/LeakDetector.h"
28
Chris Lattner07f32d42003-12-20 09:17:07 +000029using namespace llvm;
Chris Lattnerf2868ce2002-02-03 07:54:50 +000030
Chris Lattnere316efc2002-10-29 23:18:43 +000031static AnnotationID MF_AID(
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000032 AnnotationManager::getID("CodeGen::MachineCodeForFunction"));
Chris Lattnerf2868ce2002-02-03 07:54:50 +000033
Chris Lattner227c3d32002-10-28 01:12:41 +000034
Chris Lattner227c3d32002-10-28 01:12:41 +000035namespace {
Chris Lattner16c45e92003-12-20 10:20:58 +000036 struct Printer : public MachineFunctionPass {
Brian Gaeke09caa372004-01-30 21:53:46 +000037 std::ostream *OS;
Chris Lattnerd4baf0f2004-02-01 05:25:07 +000038 const std::string Banner;
Brian Gaeke09caa372004-01-30 21:53:46 +000039
40 Printer (std::ostream *_OS, const std::string &_Banner) :
41 OS (_OS), Banner (_Banner) { }
42
Chris Lattner10491642002-10-30 00:48:05 +000043 const char *getPassName() const { return "MachineFunction Printer"; }
44
45 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
46 AU.setPreservesAll();
47 }
48
Chris Lattner16c45e92003-12-20 10:20:58 +000049 bool runOnMachineFunction(MachineFunction &MF) {
Brian Gaeke09caa372004-01-30 21:53:46 +000050 (*OS) << Banner;
51 MF.print (*OS);
Chris Lattner10491642002-10-30 00:48:05 +000052 return false;
53 }
54 };
Chris Lattner227c3d32002-10-28 01:12:41 +000055}
56
Brian Gaeke09caa372004-01-30 21:53:46 +000057/// Returns a newly-created MachineFunction Printer pass. The default output
58/// stream is std::cerr; the default banner is empty.
59///
60FunctionPass *llvm::createMachineFunctionPrinterPass(std::ostream *OS,
61 const std::string &Banner) {
62 return new Printer(OS, Banner);
Chris Lattner10491642002-10-30 00:48:05 +000063}
64
Alkis Evlogimenosc81efdc2004-02-15 00:03:15 +000065namespace {
66 struct Deleter : public MachineFunctionPass {
67 const char *getPassName() const { return "Machine Code Deleter"; }
68
69 bool runOnMachineFunction(MachineFunction &MF) {
70 // Delete the annotation from the function now.
71 MachineFunction::destruct(MF.getFunction());
72 return true;
73 }
74 };
75}
76
77/// MachineCodeDeletion Pass - This pass deletes all of the machine code for
78/// the current function, which should happen after the function has been
79/// emitted to a .s file or to memory.
80FunctionPass *llvm::createMachineCodeDeleter() {
81 return new Deleter();
82}
83
84
85
Chris Lattner227c3d32002-10-28 01:12:41 +000086//===---------------------------------------------------------------------===//
87// MachineFunction implementation
88//===---------------------------------------------------------------------===//
Tanya Lattner792699c2004-05-24 06:11:51 +000089MachineBasicBlock* ilist_traits<MachineBasicBlock>::createNode()
90{
91 MachineBasicBlock* dummy = new MachineBasicBlock();
92 LeakDetector::removeGarbageObject(dummy);
93 return dummy;
94}
95
96void ilist_traits<MachineBasicBlock>::transferNodesFromList(
97 iplist<MachineBasicBlock, ilist_traits<MachineBasicBlock> >& toList,
98 ilist_iterator<MachineBasicBlock> first,
99 ilist_iterator<MachineBasicBlock> last)
100{
101 if (parent != toList.parent)
102 for (; first != last; ++first)
103 first->Parent = toList.parent;
104}
Chris Lattner227c3d32002-10-28 01:12:41 +0000105
Chris Lattner10491642002-10-30 00:48:05 +0000106MachineFunction::MachineFunction(const Function *F,
Chris Lattner955fad12002-12-28 20:37:16 +0000107 const TargetMachine &TM)
Brian Gaeked657c422004-05-12 21:35:23 +0000108 : Annotation(MF_AID), Fn(F), Target(TM), NextMBBNumber(0) {
Misha Brukmanb7825bc2002-11-20 18:55:27 +0000109 SSARegMapping = new SSARegMap();
Chris Lattner955fad12002-12-28 20:37:16 +0000110 MFInfo = new MachineFunctionInfo(*this);
Chris Lattnereb24db92002-12-28 21:08:26 +0000111 FrameInfo = new MachineFrameInfo();
Chris Lattner4d149cd2003-01-13 00:23:03 +0000112 ConstantPool = new MachineConstantPool();
Tanya Lattner792699c2004-05-24 06:11:51 +0000113 BasicBlocks.parent = this;
Chris Lattner831fdcf2002-12-25 05:03:22 +0000114}
115
116MachineFunction::~MachineFunction() {
117 delete SSARegMapping;
Chris Lattner955fad12002-12-28 20:37:16 +0000118 delete MFInfo;
119 delete FrameInfo;
Chris Lattner4d149cd2003-01-13 00:23:03 +0000120 delete ConstantPool;
Chris Lattner10491642002-10-30 00:48:05 +0000121}
122
123void MachineFunction::dump() const { print(std::cerr); }
124
125void MachineFunction::print(std::ostream &OS) const {
Brian Gaeke47b71642004-03-29 21:58:31 +0000126 OS << "# Machine code for " << Fn->getName () << "():\n";
Chris Lattner955fad12002-12-28 20:37:16 +0000127
128 // Print Frame Information
Chris Lattner9085d8a2003-01-16 18:35:57 +0000129 getFrameInfo()->print(*this, OS);
Chris Lattner4d149cd2003-01-13 00:23:03 +0000130
131 // Print Constant Pool
132 getConstantPool()->print(OS);
Chris Lattner10491642002-10-30 00:48:05 +0000133
Brian Gaeke90421cd2004-02-13 04:39:55 +0000134 for (const_iterator BB = begin(); BB != end(); ++BB)
135 BB->print(OS);
Brian Gaeke47b71642004-03-29 21:58:31 +0000136
137 OS << "\n# End machine code for " << Fn->getName () << "().\n\n";
Chris Lattner10491642002-10-30 00:48:05 +0000138}
139
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000140// The next two methods are used to construct and to retrieve
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000141// the MachineCodeForFunction object for the given function.
142// construct() -- Allocates and initializes for a given function and target
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000143// get() -- Returns a handle to the object.
144// This should not be called before "construct()"
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000145// for a given Function.
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000146//
Misha Brukmanfce11432002-10-28 00:28:31 +0000147MachineFunction&
Chris Lattner335d5c32002-10-28 05:58:46 +0000148MachineFunction::construct(const Function *Fn, const TargetMachine &Tar)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000149{
Chris Lattnere316efc2002-10-29 23:18:43 +0000150 assert(Fn->getAnnotation(MF_AID) == 0 &&
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000151 "Object already exists for this function!");
Chris Lattner335d5c32002-10-28 05:58:46 +0000152 MachineFunction* mcInfo = new MachineFunction(Fn, Tar);
153 Fn->addAnnotation(mcInfo);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000154 return *mcInfo;
155}
156
Chris Lattner16c45e92003-12-20 10:20:58 +0000157void MachineFunction::destruct(const Function *Fn) {
Chris Lattnere316efc2002-10-29 23:18:43 +0000158 bool Deleted = Fn->deleteAnnotation(MF_AID);
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000159 assert(Deleted && "Machine code did not exist for function!");
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000160}
161
Chris Lattner335d5c32002-10-28 05:58:46 +0000162MachineFunction& MachineFunction::get(const Function *F)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000163{
Chris Lattnere316efc2002-10-29 23:18:43 +0000164 MachineFunction *mc = (MachineFunction*)F->getAnnotation(MF_AID);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000165 assert(mc && "Call construct() method first to allocate the object");
166 return *mc;
167}
168
Chris Lattner831fdcf2002-12-25 05:03:22 +0000169void MachineFunction::clearSSARegMap() {
170 delete SSARegMapping;
171 SSARegMapping = 0;
172}
173
Chris Lattner955fad12002-12-28 20:37:16 +0000174//===----------------------------------------------------------------------===//
Chris Lattnereb24db92002-12-28 21:08:26 +0000175// MachineFrameInfo implementation
Chris Lattner955fad12002-12-28 20:37:16 +0000176//===----------------------------------------------------------------------===//
177
Chris Lattner4d149cd2003-01-13 00:23:03 +0000178/// CreateStackObject - Create a stack object for a value of the specified type.
179///
180int MachineFrameInfo::CreateStackObject(const Type *Ty, const TargetData &TD) {
181 return CreateStackObject(TD.getTypeSize(Ty), TD.getTypeAlignment(Ty));
182}
183
184int MachineFrameInfo::CreateStackObject(const TargetRegisterClass *RC) {
185 return CreateStackObject(RC->getSize(), RC->getAlignment());
186}
187
188
Chris Lattner9085d8a2003-01-16 18:35:57 +0000189void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{
190 int ValOffset = MF.getTarget().getFrameInfo().getOffsetOfLocalArea();
191
Chris Lattner955fad12002-12-28 20:37:16 +0000192 for (unsigned i = 0, e = Objects.size(); i != e; ++i) {
193 const StackObject &SO = Objects[i];
Chris Lattner4d149cd2003-01-13 00:23:03 +0000194 OS << " <fi #" << (int)(i-NumFixedObjects) << "> is ";
Chris Lattner955fad12002-12-28 20:37:16 +0000195 if (SO.Size == 0)
196 OS << "variable sized";
197 else
198 OS << SO.Size << " byte" << (SO.Size != 1 ? "s" : " ");
199
200 if (i < NumFixedObjects)
201 OS << " fixed";
202 if (i < NumFixedObjects || SO.SPOffset != -1) {
Chris Lattner9085d8a2003-01-16 18:35:57 +0000203 int Off = SO.SPOffset + ValOffset;
Chris Lattner955fad12002-12-28 20:37:16 +0000204 OS << " at location [SP";
Chris Lattner9085d8a2003-01-16 18:35:57 +0000205 if (Off > 0)
206 OS << "+" << Off;
207 else if (Off < 0)
208 OS << Off;
Chris Lattner955fad12002-12-28 20:37:16 +0000209 OS << "]";
210 }
211 OS << "\n";
212 }
213
214 if (HasVarSizedObjects)
215 OS << " Stack frame contains variable sized objects\n";
216}
217
Chris Lattner9085d8a2003-01-16 18:35:57 +0000218void MachineFrameInfo::dump(const MachineFunction &MF) const {
219 print(MF, std::cerr);
220}
Chris Lattner955fad12002-12-28 20:37:16 +0000221
222
223//===----------------------------------------------------------------------===//
Chris Lattner4d149cd2003-01-13 00:23:03 +0000224// MachineConstantPool implementation
225//===----------------------------------------------------------------------===//
226
227void MachineConstantPool::print(std::ostream &OS) const {
228 for (unsigned i = 0, e = Constants.size(); i != e; ++i)
229 OS << " <cp #" << i << "> is" << *(Value*)Constants[i] << "\n";
230}
231
232void MachineConstantPool::dump() const { print(std::cerr); }
233
234//===----------------------------------------------------------------------===//
Chris Lattner955fad12002-12-28 20:37:16 +0000235// MachineFunctionInfo implementation
236//===----------------------------------------------------------------------===//
Chris Lattner831fdcf2002-12-25 05:03:22 +0000237
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000238static unsigned
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000239ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
240 unsigned &maxOptionalNumArgs)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000241{
Chris Lattner955fad12002-12-28 20:37:16 +0000242 const TargetFrameInfo &frameInfo = target.getFrameInfo();
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000243
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000244 unsigned maxSize = 0;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000245
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000246 for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB)
247 for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
Chris Lattner2ee82e02003-04-23 16:36:11 +0000248 if (const CallInst *callInst = dyn_cast<CallInst>(I))
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000249 {
250 unsigned numOperands = callInst->getNumOperands() - 1;
251 int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();
252 if (numExtra <= 0)
253 continue;
254
Chris Lattner955fad12002-12-28 20:37:16 +0000255 unsigned sizeForThisCall;
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000256 if (frameInfo.argsOnStackHaveFixedSize())
257 {
258 int argSize = frameInfo.getSizeOfEachArgOnStack();
259 sizeForThisCall = numExtra * (unsigned) argSize;
260 }
261 else
262 {
263 assert(0 && "UNTESTED CODE: Size per stack argument is not "
264 "fixed on this architecture: use actual arg sizes to "
265 "compute MaxOptionalArgsSize");
266 sizeForThisCall = 0;
267 for (unsigned i = 0; i < numOperands; ++i)
Chris Lattner955fad12002-12-28 20:37:16 +0000268 sizeForThisCall += target.getTargetData().getTypeSize(callInst->
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000269 getOperand(i)->getType());
270 }
271
272 if (maxSize < sizeForThisCall)
273 maxSize = sizeForThisCall;
274
275 if ((int)maxOptionalNumArgs < numExtra)
276 maxOptionalNumArgs = (unsigned) numExtra;
277 }
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000278
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000279 return maxSize;
280}
281
282// Align data larger than one L1 cache line on L1 cache line boundaries.
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000283// Align all smaller data on the next higher 2^x boundary (4, 8, ...),
284// but not higher than the alignment of the largest type we support
285// (currently a double word). -- see class TargetData).
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000286//
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000287// This function is similar to the corresponding function in EmitAssembly.cpp
288// but they are unrelated. This one does not align at more than a
289// double-word boundary whereas that one might.
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000290//
Chris Lattner955fad12002-12-28 20:37:16 +0000291inline unsigned
292SizeToAlignment(unsigned size, const TargetMachine& target)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000293{
Brian Gaeke05b15fb2004-03-01 06:43:29 +0000294 const unsigned short cacheLineSize = 16;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000295 if (size > (unsigned) cacheLineSize / 2)
296 return cacheLineSize;
297 else
298 for (unsigned sz=1; /*no condition*/; sz *= 2)
Chris Lattner955fad12002-12-28 20:37:16 +0000299 if (sz >= size || sz >= target.getTargetData().getDoubleAlignment())
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000300 return sz;
301}
302
303
Chris Lattner955fad12002-12-28 20:37:16 +0000304void MachineFunctionInfo::CalculateArgSize() {
305 maxOptionalArgsSize = ComputeMaxOptionalArgsSize(MF.getTarget(),
306 MF.getFunction(),
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000307 maxOptionalNumArgs);
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000308 staticStackSize = maxOptionalArgsSize
Chris Lattner955fad12002-12-28 20:37:16 +0000309 + MF.getTarget().getFrameInfo().getMinStackFrameSize();
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000310}
311
312int
Chris Lattner955fad12002-12-28 20:37:16 +0000313MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
314 unsigned &getPaddedSize,
315 unsigned sizeToUse)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000316{
Vikram S. Advee4e4d4e2002-03-24 03:39:26 +0000317 if (sizeToUse == 0)
Chris Lattner955fad12002-12-28 20:37:16 +0000318 sizeToUse = MF.getTarget().findOptimalStorageSize(val->getType());
319 unsigned align = SizeToAlignment(sizeToUse, MF.getTarget());
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000320
321 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000322 int firstOffset = MF.getTarget().getFrameInfo().getFirstAutomaticVarOffset(MF,
323 growUp);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000324 int offset = growUp? firstOffset + getAutomaticVarsSize()
325 : firstOffset - (getAutomaticVarsSize() + sizeToUse);
326
Chris Lattner955fad12002-12-28 20:37:16 +0000327 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000328 getPaddedSize = sizeToUse + abs(aligned - offset);
329
330 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000331}
332
Chris Lattner07f32d42003-12-20 09:17:07 +0000333
334int MachineFunctionInfo::allocateLocalVar(const Value* val,
335 unsigned sizeToUse) {
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000336 assert(! automaticVarsAreaFrozen &&
337 "Size of auto vars area has been used to compute an offset so "
338 "no more automatic vars should be allocated!");
339
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000340 // Check if we've allocated a stack slot for this value already
341 //
Chris Lattner07f32d42003-12-20 09:17:07 +0000342 hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
343 if (pair != offsets.end())
344 return pair->second;
345
346 unsigned getPaddedSize;
347 unsigned offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse);
348 offsets[val] = offset;
349 incrementAutomaticVarsSize(getPaddedSize);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000350 return offset;
351}
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000352
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000353int
Chris Lattner955fad12002-12-28 20:37:16 +0000354MachineFunctionInfo::allocateSpilledValue(const Type* type)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000355{
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000356 assert(! spillsAreaFrozen &&
357 "Size of reg spills area has been used to compute an offset so "
358 "no more register spill slots should be allocated!");
359
Chris Lattner955fad12002-12-28 20:37:16 +0000360 unsigned size = MF.getTarget().getTargetData().getTypeSize(type);
361 unsigned char align = MF.getTarget().getTargetData().getTypeAlignment(type);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000362
363 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000364 int firstOffset = MF.getTarget().getFrameInfo().getRegSpillAreaOffset(MF, growUp);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000365
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000366 int offset = growUp? firstOffset + getRegSpillsSize()
367 : firstOffset - (getRegSpillsSize() + size);
368
Chris Lattner955fad12002-12-28 20:37:16 +0000369 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000370 size += abs(aligned - offset); // include alignment padding in size
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000371
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000372 incrementRegSpillsSize(size); // update size of reg. spills area
373
374 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000375}
376
377int
Chris Lattner955fad12002-12-28 20:37:16 +0000378MachineFunctionInfo::pushTempValue(unsigned size)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000379{
Chris Lattner955fad12002-12-28 20:37:16 +0000380 unsigned align = SizeToAlignment(size, MF.getTarget());
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000381
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000382 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000383 int firstOffset = MF.getTarget().getFrameInfo().getTmpAreaOffset(MF, growUp);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000384
385 int offset = growUp? firstOffset + currentTmpValuesSize
386 : firstOffset - (currentTmpValuesSize + size);
387
Chris Lattner955fad12002-12-28 20:37:16 +0000388 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp,
389 align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000390 size += abs(aligned - offset); // include alignment padding in size
391
392 incrementTmpAreaSize(size); // update "current" size of tmp area
393
394 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000395}
396
Chris Lattner955fad12002-12-28 20:37:16 +0000397void MachineFunctionInfo::popAllTempValues() {
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000398 resetTmpAreaSize(); // clear tmp area to reuse
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000399}
400