blob: 57b34fae1f528b74dbf5db800611c3fa6171095c [file] [log] [blame]
Chris Lattner6b944532002-10-28 01:16:38 +00001//===-- MachineFunction.cpp -----------------------------------------------===//
Chris Lattnerf2868ce2002-02-03 07:54:50 +00002//
Chris Lattner6b944532002-10-28 01:16:38 +00003// Collect native machine code information for a function. This allows
4// target-specific information about the generated code to be stored with each
5// function.
6//
7//===----------------------------------------------------------------------===//
Chris Lattnerf2868ce2002-02-03 07:54:50 +00008
Chris Lattner6b944532002-10-28 01:16:38 +00009#include "llvm/CodeGen/MachineFunction.h"
Chris Lattner831fdcf2002-12-25 05:03:22 +000010#include "llvm/CodeGen/MachineInstr.h"
Chris Lattner227c3d32002-10-28 01:12:41 +000011#include "llvm/CodeGen/MachineCodeForInstruction.h"
Chris Lattner831fdcf2002-12-25 05:03:22 +000012#include "llvm/CodeGen/SSARegMap.h"
Chris Lattner955fad12002-12-28 20:37:16 +000013#include "llvm/CodeGen/MachineFunctionInfo.h"
Chris Lattnereb24db92002-12-28 21:08:26 +000014#include "llvm/CodeGen/MachineFrameInfo.h"
Chris Lattner4d149cd2003-01-13 00:23:03 +000015#include "llvm/CodeGen/MachineConstantPool.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000016#include "llvm/Target/TargetMachine.h"
Chris Lattner8bd66e62002-12-28 21:00:25 +000017#include "llvm/Target/TargetFrameInfo.h"
Chris Lattnerf27eeea2002-12-29 02:50:35 +000018#include "llvm/Target/TargetCacheInfo.h"
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000019#include "llvm/Function.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000020#include "llvm/iOther.h"
Chris Lattner227c3d32002-10-28 01:12:41 +000021#include "llvm/Pass.h"
Chris Lattnerf2868ce2002-02-03 07:54:50 +000022#include <limits.h>
23
24const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits<int>::max();
25
Chris Lattnere316efc2002-10-29 23:18:43 +000026static AnnotationID MF_AID(
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000027 AnnotationManager::getID("CodeGen::MachineCodeForFunction"));
Chris Lattnerf2868ce2002-02-03 07:54:50 +000028
Chris Lattner227c3d32002-10-28 01:12:41 +000029
30//===---------------------------------------------------------------------===//
31// Code generation/destruction passes
32//===---------------------------------------------------------------------===//
33
34namespace {
35 class ConstructMachineFunction : public FunctionPass {
36 TargetMachine &Target;
37 public:
38 ConstructMachineFunction(TargetMachine &T) : Target(T) {}
39
40 const char *getPassName() const {
41 return "ConstructMachineFunction";
42 }
43
44 bool runOnFunction(Function &F) {
Chris Lattner955fad12002-12-28 20:37:16 +000045 MachineFunction::construct(&F, Target).getInfo()->CalculateArgSize();
Chris Lattner227c3d32002-10-28 01:12:41 +000046 return false;
47 }
48 };
49
50 struct DestroyMachineFunction : public FunctionPass {
51 const char *getPassName() const { return "FreeMachineFunction"; }
52
53 static void freeMachineCode(Instruction &I) {
54 MachineCodeForInstruction::destroy(&I);
55 }
56
57 bool runOnFunction(Function &F) {
58 for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
59 for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E; ++I)
60 MachineCodeForInstruction::get(I).dropAllReferences();
61
62 for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI)
63 for_each(FI->begin(), FI->end(), freeMachineCode);
64
65 return false;
66 }
67 };
Chris Lattner10491642002-10-30 00:48:05 +000068
69 struct Printer : public FunctionPass {
70 const char *getPassName() const { return "MachineFunction Printer"; }
71
72 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
73 AU.setPreservesAll();
74 }
75
76 bool runOnFunction(Function &F) {
77 MachineFunction::get(&F).dump();
78 return false;
79 }
80 };
Chris Lattner227c3d32002-10-28 01:12:41 +000081}
82
83Pass *createMachineCodeConstructionPass(TargetMachine &Target) {
84 return new ConstructMachineFunction(Target);
85}
86
87Pass *createMachineCodeDestructionPass() {
88 return new DestroyMachineFunction();
89}
90
Chris Lattner10491642002-10-30 00:48:05 +000091Pass *createMachineFunctionPrinterPass() {
92 return new Printer();
93}
94
Chris Lattner227c3d32002-10-28 01:12:41 +000095
96//===---------------------------------------------------------------------===//
97// MachineFunction implementation
98//===---------------------------------------------------------------------===//
99
Chris Lattner10491642002-10-30 00:48:05 +0000100MachineFunction::MachineFunction(const Function *F,
Chris Lattner955fad12002-12-28 20:37:16 +0000101 const TargetMachine &TM)
102 : Annotation(MF_AID), Fn(F), Target(TM) {
Misha Brukmanb7825bc2002-11-20 18:55:27 +0000103 SSARegMapping = new SSARegMap();
Chris Lattner955fad12002-12-28 20:37:16 +0000104 MFInfo = new MachineFunctionInfo(*this);
Chris Lattnereb24db92002-12-28 21:08:26 +0000105 FrameInfo = new MachineFrameInfo();
Chris Lattner4d149cd2003-01-13 00:23:03 +0000106 ConstantPool = new MachineConstantPool();
Chris Lattner831fdcf2002-12-25 05:03:22 +0000107}
108
109MachineFunction::~MachineFunction() {
110 delete SSARegMapping;
Chris Lattner955fad12002-12-28 20:37:16 +0000111 delete MFInfo;
112 delete FrameInfo;
Chris Lattner4d149cd2003-01-13 00:23:03 +0000113 delete ConstantPool;
Chris Lattner10491642002-10-30 00:48:05 +0000114}
115
116void MachineFunction::dump() const { print(std::cerr); }
117
118void MachineFunction::print(std::ostream &OS) const {
Chris Lattner955fad12002-12-28 20:37:16 +0000119 OS << "\n" << *(Value*)Fn->getFunctionType() << " \"" << Fn->getName()
120 << "\"\n";
121
122 // Print Frame Information
Chris Lattner9085d8a2003-01-16 18:35:57 +0000123 getFrameInfo()->print(*this, OS);
Chris Lattner4d149cd2003-01-13 00:23:03 +0000124
125 // Print Constant Pool
126 getConstantPool()->print(OS);
Chris Lattner10491642002-10-30 00:48:05 +0000127
128 for (const_iterator BB = begin(); BB != end(); ++BB) {
129 BasicBlock *LBB = BB->getBasicBlock();
Chris Lattner2109f502002-12-15 20:35:25 +0000130 OS << "\n" << LBB->getName() << " (" << (const void*)LBB << "):\n";
Chris Lattner10491642002-10-30 00:48:05 +0000131 for (MachineBasicBlock::const_iterator I = BB->begin(); I != BB->end();++I){
132 OS << "\t";
133 (*I)->print(OS, Target);
134 }
135 }
136 OS << "\nEnd function \"" << Fn->getName() << "\"\n\n";
137}
138
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
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000157void
Chris Lattner335d5c32002-10-28 05:58:46 +0000158MachineFunction::destruct(const Function *Fn)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000159{
Chris Lattnere316efc2002-10-29 23:18:43 +0000160 bool Deleted = Fn->deleteAnnotation(MF_AID);
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000161 assert(Deleted && "Machine code did not exist for function!");
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000162}
163
Chris Lattner335d5c32002-10-28 05:58:46 +0000164MachineFunction& MachineFunction::get(const Function *F)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000165{
Chris Lattnere316efc2002-10-29 23:18:43 +0000166 MachineFunction *mc = (MachineFunction*)F->getAnnotation(MF_AID);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000167 assert(mc && "Call construct() method first to allocate the object");
168 return *mc;
169}
170
Chris Lattner831fdcf2002-12-25 05:03:22 +0000171void MachineFunction::clearSSARegMap() {
172 delete SSARegMapping;
173 SSARegMapping = 0;
174}
175
Chris Lattner955fad12002-12-28 20:37:16 +0000176//===----------------------------------------------------------------------===//
Chris Lattnereb24db92002-12-28 21:08:26 +0000177// MachineFrameInfo implementation
Chris Lattner955fad12002-12-28 20:37:16 +0000178//===----------------------------------------------------------------------===//
179
Chris Lattner4d149cd2003-01-13 00:23:03 +0000180/// CreateStackObject - Create a stack object for a value of the specified type.
181///
182int MachineFrameInfo::CreateStackObject(const Type *Ty, const TargetData &TD) {
183 return CreateStackObject(TD.getTypeSize(Ty), TD.getTypeAlignment(Ty));
184}
185
186int MachineFrameInfo::CreateStackObject(const TargetRegisterClass *RC) {
187 return CreateStackObject(RC->getSize(), RC->getAlignment());
188}
189
190
Chris Lattner9085d8a2003-01-16 18:35:57 +0000191void MachineFrameInfo::print(const MachineFunction &MF, std::ostream &OS) const{
192 int ValOffset = MF.getTarget().getFrameInfo().getOffsetOfLocalArea();
193
Chris Lattner955fad12002-12-28 20:37:16 +0000194 for (unsigned i = 0, e = Objects.size(); i != e; ++i) {
195 const StackObject &SO = Objects[i];
Chris Lattner4d149cd2003-01-13 00:23:03 +0000196 OS << " <fi #" << (int)(i-NumFixedObjects) << "> is ";
Chris Lattner955fad12002-12-28 20:37:16 +0000197 if (SO.Size == 0)
198 OS << "variable sized";
199 else
200 OS << SO.Size << " byte" << (SO.Size != 1 ? "s" : " ");
201
202 if (i < NumFixedObjects)
203 OS << " fixed";
204 if (i < NumFixedObjects || SO.SPOffset != -1) {
Chris Lattner9085d8a2003-01-16 18:35:57 +0000205 int Off = SO.SPOffset + ValOffset;
Chris Lattner955fad12002-12-28 20:37:16 +0000206 OS << " at location [SP";
Chris Lattner9085d8a2003-01-16 18:35:57 +0000207 if (Off > 0)
208 OS << "+" << Off;
209 else if (Off < 0)
210 OS << Off;
Chris Lattner955fad12002-12-28 20:37:16 +0000211 OS << "]";
212 }
213 OS << "\n";
214 }
215
216 if (HasVarSizedObjects)
217 OS << " Stack frame contains variable sized objects\n";
218}
219
Chris Lattner9085d8a2003-01-16 18:35:57 +0000220void MachineFrameInfo::dump(const MachineFunction &MF) const {
221 print(MF, std::cerr);
222}
Chris Lattner955fad12002-12-28 20:37:16 +0000223
224
225//===----------------------------------------------------------------------===//
Chris Lattner4d149cd2003-01-13 00:23:03 +0000226// MachineConstantPool implementation
227//===----------------------------------------------------------------------===//
228
229void MachineConstantPool::print(std::ostream &OS) const {
230 for (unsigned i = 0, e = Constants.size(); i != e; ++i)
231 OS << " <cp #" << i << "> is" << *(Value*)Constants[i] << "\n";
232}
233
234void MachineConstantPool::dump() const { print(std::cerr); }
235
236//===----------------------------------------------------------------------===//
Chris Lattner955fad12002-12-28 20:37:16 +0000237// MachineFunctionInfo implementation
238//===----------------------------------------------------------------------===//
Chris Lattner831fdcf2002-12-25 05:03:22 +0000239
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000240static unsigned
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000241ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
242 unsigned &maxOptionalNumArgs)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000243{
Chris Lattner955fad12002-12-28 20:37:16 +0000244 const TargetFrameInfo &frameInfo = target.getFrameInfo();
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000245
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000246 unsigned maxSize = 0;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000247
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000248 for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB)
249 for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
Chris Lattner2ee82e02003-04-23 16:36:11 +0000250 if (const CallInst *callInst = dyn_cast<CallInst>(I))
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000251 {
252 unsigned numOperands = callInst->getNumOperands() - 1;
253 int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();
254 if (numExtra <= 0)
255 continue;
256
Chris Lattner955fad12002-12-28 20:37:16 +0000257 unsigned sizeForThisCall;
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000258 if (frameInfo.argsOnStackHaveFixedSize())
259 {
260 int argSize = frameInfo.getSizeOfEachArgOnStack();
261 sizeForThisCall = numExtra * (unsigned) argSize;
262 }
263 else
264 {
265 assert(0 && "UNTESTED CODE: Size per stack argument is not "
266 "fixed on this architecture: use actual arg sizes to "
267 "compute MaxOptionalArgsSize");
268 sizeForThisCall = 0;
269 for (unsigned i = 0; i < numOperands; ++i)
Chris Lattner955fad12002-12-28 20:37:16 +0000270 sizeForThisCall += target.getTargetData().getTypeSize(callInst->
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000271 getOperand(i)->getType());
272 }
273
274 if (maxSize < sizeForThisCall)
275 maxSize = sizeForThisCall;
276
277 if ((int)maxOptionalNumArgs < numExtra)
278 maxOptionalNumArgs = (unsigned) numExtra;
279 }
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000280
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000281 return maxSize;
282}
283
284// Align data larger than one L1 cache line on L1 cache line boundaries.
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000285// Align all smaller data on the next higher 2^x boundary (4, 8, ...),
286// but not higher than the alignment of the largest type we support
287// (currently a double word). -- see class TargetData).
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000288//
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000289// This function is similar to the corresponding function in EmitAssembly.cpp
290// but they are unrelated. This one does not align at more than a
291// double-word boundary whereas that one might.
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000292//
Chris Lattner955fad12002-12-28 20:37:16 +0000293inline unsigned
294SizeToAlignment(unsigned size, const TargetMachine& target)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000295{
296 unsigned short cacheLineSize = target.getCacheInfo().getCacheLineSize(1);
297 if (size > (unsigned) cacheLineSize / 2)
298 return cacheLineSize;
299 else
300 for (unsigned sz=1; /*no condition*/; sz *= 2)
Chris Lattner955fad12002-12-28 20:37:16 +0000301 if (sz >= size || sz >= target.getTargetData().getDoubleAlignment())
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000302 return sz;
303}
304
305
Chris Lattner955fad12002-12-28 20:37:16 +0000306void MachineFunctionInfo::CalculateArgSize() {
307 maxOptionalArgsSize = ComputeMaxOptionalArgsSize(MF.getTarget(),
308 MF.getFunction(),
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000309 maxOptionalNumArgs);
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000310 staticStackSize = maxOptionalArgsSize
Chris Lattner955fad12002-12-28 20:37:16 +0000311 + MF.getTarget().getFrameInfo().getMinStackFrameSize();
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000312}
313
314int
Chris Lattner955fad12002-12-28 20:37:16 +0000315MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
316 unsigned &getPaddedSize,
317 unsigned sizeToUse)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000318{
Vikram S. Advee4e4d4e2002-03-24 03:39:26 +0000319 if (sizeToUse == 0)
Chris Lattner955fad12002-12-28 20:37:16 +0000320 sizeToUse = MF.getTarget().findOptimalStorageSize(val->getType());
321 unsigned align = SizeToAlignment(sizeToUse, MF.getTarget());
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000322
323 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000324 int firstOffset = MF.getTarget().getFrameInfo().getFirstAutomaticVarOffset(MF,
325 growUp);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000326 int offset = growUp? firstOffset + getAutomaticVarsSize()
327 : firstOffset - (getAutomaticVarsSize() + sizeToUse);
328
Chris Lattner955fad12002-12-28 20:37:16 +0000329 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000330 getPaddedSize = sizeToUse + abs(aligned - offset);
331
332 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000333}
334
335int
Chris Lattner955fad12002-12-28 20:37:16 +0000336MachineFunctionInfo::allocateLocalVar(const Value* val,
337 unsigned sizeToUse)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000338{
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000339 assert(! automaticVarsAreaFrozen &&
340 "Size of auto vars area has been used to compute an offset so "
341 "no more automatic vars should be allocated!");
342
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000343 // Check if we've allocated a stack slot for this value already
344 //
345 int offset = getOffset(val);
346 if (offset == INVALID_FRAME_OFFSET)
347 {
Chris Lattner955fad12002-12-28 20:37:16 +0000348 unsigned getPaddedSize;
349 offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000350 offsets[val] = offset;
Vikram S. Advee4e4d4e2002-03-24 03:39:26 +0000351 incrementAutomaticVarsSize(getPaddedSize);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000352 }
353 return offset;
354}
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000355
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000356int
Chris Lattner955fad12002-12-28 20:37:16 +0000357MachineFunctionInfo::allocateSpilledValue(const Type* type)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000358{
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000359 assert(! spillsAreaFrozen &&
360 "Size of reg spills area has been used to compute an offset so "
361 "no more register spill slots should be allocated!");
362
Chris Lattner955fad12002-12-28 20:37:16 +0000363 unsigned size = MF.getTarget().getTargetData().getTypeSize(type);
364 unsigned char align = MF.getTarget().getTargetData().getTypeAlignment(type);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000365
366 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000367 int firstOffset = MF.getTarget().getFrameInfo().getRegSpillAreaOffset(MF, growUp);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000368
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000369 int offset = growUp? firstOffset + getRegSpillsSize()
370 : firstOffset - (getRegSpillsSize() + size);
371
Chris Lattner955fad12002-12-28 20:37:16 +0000372 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000373 size += abs(aligned - offset); // include alignment padding in size
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000374
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000375 incrementRegSpillsSize(size); // update size of reg. spills area
376
377 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000378}
379
380int
Chris Lattner955fad12002-12-28 20:37:16 +0000381MachineFunctionInfo::pushTempValue(unsigned size)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000382{
Chris Lattner955fad12002-12-28 20:37:16 +0000383 unsigned align = SizeToAlignment(size, MF.getTarget());
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000384
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000385 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000386 int firstOffset = MF.getTarget().getFrameInfo().getTmpAreaOffset(MF, growUp);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000387
388 int offset = growUp? firstOffset + currentTmpValuesSize
389 : firstOffset - (currentTmpValuesSize + size);
390
Chris Lattner955fad12002-12-28 20:37:16 +0000391 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp,
392 align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000393 size += abs(aligned - offset); // include alignment padding in size
394
395 incrementTmpAreaSize(size); // update "current" size of tmp area
396
397 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000398}
399
Chris Lattner955fad12002-12-28 20:37:16 +0000400void MachineFunctionInfo::popAllTempValues() {
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000401 resetTmpAreaSize(); // clear tmp area to reuse
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000402}
403
404int
Chris Lattner955fad12002-12-28 20:37:16 +0000405MachineFunctionInfo::getOffset(const Value* val) const
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000406{
Chris Lattner09ff1122002-07-24 21:21:32 +0000407 hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
Chris Lattner6b944532002-10-28 01:16:38 +0000408 return (pair == offsets.end()) ? INVALID_FRAME_OFFSET : pair->second;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000409}