blob: 46036d0b58d8618621208d3b097b26587a3d291b [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
123 getFrameInfo()->print(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 Lattnereb24db92002-12-28 21:08:26 +0000191void MachineFrameInfo::print(std::ostream &OS) const {
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) {
203 OS << " at location [SP";
204 if (SO.SPOffset > 0)
205 OS << "+" << SO.SPOffset;
206 else if (SO.SPOffset < 0)
207 OS << SO.SPOffset;
208 OS << "]";
209 }
210 OS << "\n";
211 }
212
213 if (HasVarSizedObjects)
214 OS << " Stack frame contains variable sized objects\n";
215}
216
Chris Lattnereb24db92002-12-28 21:08:26 +0000217void MachineFrameInfo::dump() const { print(std::cerr); }
Chris Lattner955fad12002-12-28 20:37:16 +0000218
219
220//===----------------------------------------------------------------------===//
Chris Lattner4d149cd2003-01-13 00:23:03 +0000221// MachineConstantPool implementation
222//===----------------------------------------------------------------------===//
223
224void MachineConstantPool::print(std::ostream &OS) const {
225 for (unsigned i = 0, e = Constants.size(); i != e; ++i)
226 OS << " <cp #" << i << "> is" << *(Value*)Constants[i] << "\n";
227}
228
229void MachineConstantPool::dump() const { print(std::cerr); }
230
231//===----------------------------------------------------------------------===//
Chris Lattner955fad12002-12-28 20:37:16 +0000232// MachineFunctionInfo implementation
233//===----------------------------------------------------------------------===//
Chris Lattner831fdcf2002-12-25 05:03:22 +0000234
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000235static unsigned
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000236ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F,
237 unsigned &maxOptionalNumArgs)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000238{
Chris Lattner955fad12002-12-28 20:37:16 +0000239 const TargetFrameInfo &frameInfo = target.getFrameInfo();
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000240
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000241 unsigned maxSize = 0;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000242
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000243 for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB)
244 for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
245 if (const CallInst *callInst = dyn_cast<CallInst>(&*I))
246 {
247 unsigned numOperands = callInst->getNumOperands() - 1;
248 int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs();
249 if (numExtra <= 0)
250 continue;
251
Chris Lattner955fad12002-12-28 20:37:16 +0000252 unsigned sizeForThisCall;
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000253 if (frameInfo.argsOnStackHaveFixedSize())
254 {
255 int argSize = frameInfo.getSizeOfEachArgOnStack();
256 sizeForThisCall = numExtra * (unsigned) argSize;
257 }
258 else
259 {
260 assert(0 && "UNTESTED CODE: Size per stack argument is not "
261 "fixed on this architecture: use actual arg sizes to "
262 "compute MaxOptionalArgsSize");
263 sizeForThisCall = 0;
264 for (unsigned i = 0; i < numOperands; ++i)
Chris Lattner955fad12002-12-28 20:37:16 +0000265 sizeForThisCall += target.getTargetData().getTypeSize(callInst->
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000266 getOperand(i)->getType());
267 }
268
269 if (maxSize < sizeForThisCall)
270 maxSize = sizeForThisCall;
271
272 if ((int)maxOptionalNumArgs < numExtra)
273 maxOptionalNumArgs = (unsigned) numExtra;
274 }
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000275
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000276 return maxSize;
277}
278
279// Align data larger than one L1 cache line on L1 cache line boundaries.
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000280// Align all smaller data on the next higher 2^x boundary (4, 8, ...),
281// but not higher than the alignment of the largest type we support
282// (currently a double word). -- see class TargetData).
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000283//
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000284// This function is similar to the corresponding function in EmitAssembly.cpp
285// but they are unrelated. This one does not align at more than a
286// double-word boundary whereas that one might.
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000287//
Chris Lattner955fad12002-12-28 20:37:16 +0000288inline unsigned
289SizeToAlignment(unsigned size, const TargetMachine& target)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000290{
291 unsigned short cacheLineSize = target.getCacheInfo().getCacheLineSize(1);
292 if (size > (unsigned) cacheLineSize / 2)
293 return cacheLineSize;
294 else
295 for (unsigned sz=1; /*no condition*/; sz *= 2)
Chris Lattner955fad12002-12-28 20:37:16 +0000296 if (sz >= size || sz >= target.getTargetData().getDoubleAlignment())
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000297 return sz;
298}
299
300
Chris Lattner955fad12002-12-28 20:37:16 +0000301void MachineFunctionInfo::CalculateArgSize() {
302 maxOptionalArgsSize = ComputeMaxOptionalArgsSize(MF.getTarget(),
303 MF.getFunction(),
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000304 maxOptionalNumArgs);
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000305 staticStackSize = maxOptionalArgsSize
Chris Lattner955fad12002-12-28 20:37:16 +0000306 + MF.getTarget().getFrameInfo().getMinStackFrameSize();
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000307}
308
309int
Chris Lattner955fad12002-12-28 20:37:16 +0000310MachineFunctionInfo::computeOffsetforLocalVar(const Value* val,
311 unsigned &getPaddedSize,
312 unsigned sizeToUse)
Vikram S. Adve89e2da02002-03-18 03:36:30 +0000313{
Vikram S. Advee4e4d4e2002-03-24 03:39:26 +0000314 if (sizeToUse == 0)
Chris Lattner955fad12002-12-28 20:37:16 +0000315 sizeToUse = MF.getTarget().findOptimalStorageSize(val->getType());
316 unsigned align = SizeToAlignment(sizeToUse, MF.getTarget());
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000317
318 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000319 int firstOffset = MF.getTarget().getFrameInfo().getFirstAutomaticVarOffset(MF,
320 growUp);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000321 int offset = growUp? firstOffset + getAutomaticVarsSize()
322 : firstOffset - (getAutomaticVarsSize() + sizeToUse);
323
Chris Lattner955fad12002-12-28 20:37:16 +0000324 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000325 getPaddedSize = sizeToUse + abs(aligned - offset);
326
327 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000328}
329
330int
Chris Lattner955fad12002-12-28 20:37:16 +0000331MachineFunctionInfo::allocateLocalVar(const Value* val,
332 unsigned sizeToUse)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000333{
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000334 assert(! automaticVarsAreaFrozen &&
335 "Size of auto vars area has been used to compute an offset so "
336 "no more automatic vars should be allocated!");
337
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000338 // Check if we've allocated a stack slot for this value already
339 //
340 int offset = getOffset(val);
341 if (offset == INVALID_FRAME_OFFSET)
342 {
Chris Lattner955fad12002-12-28 20:37:16 +0000343 unsigned getPaddedSize;
344 offset = computeOffsetforLocalVar(val, getPaddedSize, sizeToUse);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000345 offsets[val] = offset;
Vikram S. Advee4e4d4e2002-03-24 03:39:26 +0000346 incrementAutomaticVarsSize(getPaddedSize);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000347 }
348 return offset;
349}
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000350
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000351int
Chris Lattner955fad12002-12-28 20:37:16 +0000352MachineFunctionInfo::allocateSpilledValue(const Type* type)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000353{
Vikram S. Adve03d33bd2002-04-25 04:30:43 +0000354 assert(! spillsAreaFrozen &&
355 "Size of reg spills area has been used to compute an offset so "
356 "no more register spill slots should be allocated!");
357
Chris Lattner955fad12002-12-28 20:37:16 +0000358 unsigned size = MF.getTarget().getTargetData().getTypeSize(type);
359 unsigned char align = MF.getTarget().getTargetData().getTypeAlignment(type);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000360
361 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000362 int firstOffset = MF.getTarget().getFrameInfo().getRegSpillAreaOffset(MF, growUp);
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000363
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000364 int offset = growUp? firstOffset + getRegSpillsSize()
365 : firstOffset - (getRegSpillsSize() + size);
366
Chris Lattner955fad12002-12-28 20:37:16 +0000367 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp, align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000368 size += abs(aligned - offset); // include alignment padding in size
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000369
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000370 incrementRegSpillsSize(size); // update size of reg. spills area
371
372 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000373}
374
375int
Chris Lattner955fad12002-12-28 20:37:16 +0000376MachineFunctionInfo::pushTempValue(unsigned size)
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000377{
Chris Lattner955fad12002-12-28 20:37:16 +0000378 unsigned align = SizeToAlignment(size, MF.getTarget());
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000379
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000380 bool growUp;
Chris Lattner955fad12002-12-28 20:37:16 +0000381 int firstOffset = MF.getTarget().getFrameInfo().getTmpAreaOffset(MF, growUp);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000382
383 int offset = growUp? firstOffset + currentTmpValuesSize
384 : firstOffset - (currentTmpValuesSize + size);
385
Chris Lattner955fad12002-12-28 20:37:16 +0000386 int aligned = MF.getTarget().getFrameInfo().adjustAlignment(offset, growUp,
387 align);
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000388 size += abs(aligned - offset); // include alignment padding in size
389
390 incrementTmpAreaSize(size); // update "current" size of tmp area
391
392 return aligned;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000393}
394
Chris Lattner955fad12002-12-28 20:37:16 +0000395void MachineFunctionInfo::popAllTempValues() {
Vikram S. Adve1318bed2002-09-16 15:18:16 +0000396 resetTmpAreaSize(); // clear tmp area to reuse
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000397}
398
399int
Chris Lattner955fad12002-12-28 20:37:16 +0000400MachineFunctionInfo::getOffset(const Value* val) const
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000401{
Chris Lattner09ff1122002-07-24 21:21:32 +0000402 hash_map<const Value*, int>::const_iterator pair = offsets.find(val);
Chris Lattner6b944532002-10-28 01:16:38 +0000403 return (pair == offsets.end()) ? INVALID_FRAME_OFFSET : pair->second;
Chris Lattnerf2868ce2002-02-03 07:54:50 +0000404}