Chris Lattner | 6b94453 | 2002-10-28 01:16:38 +0000 | [diff] [blame] | 1 | //===-- MachineFunction.cpp -----------------------------------------------===// |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 2 | // |
Chris Lattner | 6b94453 | 2002-10-28 01:16:38 +0000 | [diff] [blame] | 3 | // 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 Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 8 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 9 | #include "llvm/CodeGen/MachineInstr.h" // For debug output |
Chris Lattner | 6b94453 | 2002-10-28 01:16:38 +0000 | [diff] [blame] | 10 | #include "llvm/CodeGen/MachineFunction.h" |
Chris Lattner | 227c3d3 | 2002-10-28 01:12:41 +0000 | [diff] [blame] | 11 | #include "llvm/CodeGen/MachineCodeForInstruction.h" |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 12 | #include "llvm/Target/TargetMachine.h" |
| 13 | #include "llvm/Target/MachineFrameInfo.h" |
| 14 | #include "llvm/Target/MachineCacheInfo.h" |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 15 | #include "llvm/Function.h" |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 16 | #include "llvm/iOther.h" |
Chris Lattner | 227c3d3 | 2002-10-28 01:12:41 +0000 | [diff] [blame] | 17 | #include "llvm/Pass.h" |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 18 | #include <limits.h> |
| 19 | |
| 20 | const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits<int>::max(); |
| 21 | |
Chris Lattner | e316efc | 2002-10-29 23:18:43 +0000 | [diff] [blame] | 22 | static AnnotationID MF_AID( |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 23 | AnnotationManager::getID("CodeGen::MachineCodeForFunction")); |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 24 | |
Chris Lattner | 227c3d3 | 2002-10-28 01:12:41 +0000 | [diff] [blame] | 25 | |
| 26 | //===---------------------------------------------------------------------===// |
| 27 | // Code generation/destruction passes |
| 28 | //===---------------------------------------------------------------------===// |
| 29 | |
| 30 | namespace { |
| 31 | class ConstructMachineFunction : public FunctionPass { |
| 32 | TargetMachine &Target; |
| 33 | public: |
| 34 | ConstructMachineFunction(TargetMachine &T) : Target(T) {} |
| 35 | |
| 36 | const char *getPassName() const { |
| 37 | return "ConstructMachineFunction"; |
| 38 | } |
| 39 | |
| 40 | bool runOnFunction(Function &F) { |
Chris Lattner | 8872618 | 2002-10-29 23:40:03 +0000 | [diff] [blame] | 41 | MachineFunction::construct(&F, Target).CalculateArgSize(); |
Chris Lattner | 227c3d3 | 2002-10-28 01:12:41 +0000 | [diff] [blame] | 42 | return false; |
| 43 | } |
| 44 | }; |
| 45 | |
| 46 | struct DestroyMachineFunction : public FunctionPass { |
| 47 | const char *getPassName() const { return "FreeMachineFunction"; } |
| 48 | |
| 49 | static void freeMachineCode(Instruction &I) { |
| 50 | MachineCodeForInstruction::destroy(&I); |
| 51 | } |
| 52 | |
| 53 | bool runOnFunction(Function &F) { |
| 54 | for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) |
| 55 | for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E; ++I) |
| 56 | MachineCodeForInstruction::get(I).dropAllReferences(); |
| 57 | |
| 58 | for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE; ++FI) |
| 59 | for_each(FI->begin(), FI->end(), freeMachineCode); |
| 60 | |
| 61 | return false; |
| 62 | } |
| 63 | }; |
Chris Lattner | 1049164 | 2002-10-30 00:48:05 +0000 | [diff] [blame^] | 64 | |
| 65 | struct Printer : public FunctionPass { |
| 66 | const char *getPassName() const { return "MachineFunction Printer"; } |
| 67 | |
| 68 | virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
| 69 | AU.setPreservesAll(); |
| 70 | } |
| 71 | |
| 72 | bool runOnFunction(Function &F) { |
| 73 | MachineFunction::get(&F).dump(); |
| 74 | return false; |
| 75 | } |
| 76 | }; |
Chris Lattner | 227c3d3 | 2002-10-28 01:12:41 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | Pass *createMachineCodeConstructionPass(TargetMachine &Target) { |
| 80 | return new ConstructMachineFunction(Target); |
| 81 | } |
| 82 | |
| 83 | Pass *createMachineCodeDestructionPass() { |
| 84 | return new DestroyMachineFunction(); |
| 85 | } |
| 86 | |
Chris Lattner | 1049164 | 2002-10-30 00:48:05 +0000 | [diff] [blame^] | 87 | Pass *createMachineFunctionPrinterPass() { |
| 88 | return new Printer(); |
| 89 | } |
| 90 | |
Chris Lattner | 227c3d3 | 2002-10-28 01:12:41 +0000 | [diff] [blame] | 91 | |
| 92 | //===---------------------------------------------------------------------===// |
| 93 | // MachineFunction implementation |
| 94 | //===---------------------------------------------------------------------===// |
| 95 | |
Chris Lattner | 1049164 | 2002-10-30 00:48:05 +0000 | [diff] [blame^] | 96 | MachineFunction::MachineFunction(const Function *F, |
| 97 | const TargetMachine& target) |
| 98 | : Annotation(MF_AID), |
| 99 | Fn(F), Target(target), staticStackSize(0), |
| 100 | automaticVarsSize(0), regSpillsSize(0), |
| 101 | maxOptionalArgsSize(0), maxOptionalNumArgs(0), |
| 102 | currentTmpValuesSize(0), maxTmpValuesSize(0), compiledAsLeaf(false), |
| 103 | spillsAreaFrozen(false), automaticVarsAreaFrozen(false) |
| 104 | { |
| 105 | } |
| 106 | |
| 107 | void MachineFunction::dump() const { print(std::cerr); } |
| 108 | |
| 109 | void MachineFunction::print(std::ostream &OS) const { |
| 110 | OS << "\n" << *(Value*)Fn->getReturnType() << " \"" << Fn->getName()<< "\"\n"; |
| 111 | |
| 112 | for (const_iterator BB = begin(); BB != end(); ++BB) { |
| 113 | BasicBlock *LBB = BB->getBasicBlock(); |
| 114 | OS << "\n" << LBB->getName() << " (" |
| 115 | << (const void*)BB->getBasicBlock() << "):\n"; |
| 116 | for (MachineBasicBlock::const_iterator I = BB->begin(); I != BB->end();++I){ |
| 117 | OS << "\t"; |
| 118 | (*I)->print(OS, Target); |
| 119 | } |
| 120 | } |
| 121 | OS << "\nEnd function \"" << Fn->getName() << "\"\n\n"; |
| 122 | } |
| 123 | |
| 124 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 125 | // The next two methods are used to construct and to retrieve |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 126 | // the MachineCodeForFunction object for the given function. |
| 127 | // construct() -- Allocates and initializes for a given function and target |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 128 | // get() -- Returns a handle to the object. |
| 129 | // This should not be called before "construct()" |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 130 | // for a given Function. |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 131 | // |
Misha Brukman | fce1143 | 2002-10-28 00:28:31 +0000 | [diff] [blame] | 132 | MachineFunction& |
Chris Lattner | 335d5c3 | 2002-10-28 05:58:46 +0000 | [diff] [blame] | 133 | MachineFunction::construct(const Function *Fn, const TargetMachine &Tar) |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 134 | { |
Chris Lattner | e316efc | 2002-10-29 23:18:43 +0000 | [diff] [blame] | 135 | assert(Fn->getAnnotation(MF_AID) == 0 && |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 136 | "Object already exists for this function!"); |
Chris Lattner | 335d5c3 | 2002-10-28 05:58:46 +0000 | [diff] [blame] | 137 | MachineFunction* mcInfo = new MachineFunction(Fn, Tar); |
| 138 | Fn->addAnnotation(mcInfo); |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 139 | return *mcInfo; |
| 140 | } |
| 141 | |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 142 | void |
Chris Lattner | 335d5c3 | 2002-10-28 05:58:46 +0000 | [diff] [blame] | 143 | MachineFunction::destruct(const Function *Fn) |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 144 | { |
Chris Lattner | e316efc | 2002-10-29 23:18:43 +0000 | [diff] [blame] | 145 | bool Deleted = Fn->deleteAnnotation(MF_AID); |
Chris Lattner | 2fbfdcf | 2002-04-07 20:49:59 +0000 | [diff] [blame] | 146 | assert(Deleted && "Machine code did not exist for function!"); |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 147 | } |
| 148 | |
Chris Lattner | 335d5c3 | 2002-10-28 05:58:46 +0000 | [diff] [blame] | 149 | MachineFunction& MachineFunction::get(const Function *F) |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 150 | { |
Chris Lattner | e316efc | 2002-10-29 23:18:43 +0000 | [diff] [blame] | 151 | MachineFunction *mc = (MachineFunction*)F->getAnnotation(MF_AID); |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 152 | assert(mc && "Call construct() method first to allocate the object"); |
| 153 | return *mc; |
| 154 | } |
| 155 | |
| 156 | static unsigned |
Vikram S. Adve | 03d33bd | 2002-04-25 04:30:43 +0000 | [diff] [blame] | 157 | ComputeMaxOptionalArgsSize(const TargetMachine& target, const Function *F, |
| 158 | unsigned &maxOptionalNumArgs) |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 159 | { |
| 160 | const MachineFrameInfo& frameInfo = target.getFrameInfo(); |
| 161 | |
Chris Lattner | 0b12b5f | 2002-06-25 16:13:21 +0000 | [diff] [blame] | 162 | unsigned maxSize = 0; |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 163 | |
Chris Lattner | 0b12b5f | 2002-06-25 16:13:21 +0000 | [diff] [blame] | 164 | for (Function::const_iterator BB = F->begin(), BBE = F->end(); BB !=BBE; ++BB) |
| 165 | for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) |
| 166 | if (const CallInst *callInst = dyn_cast<CallInst>(&*I)) |
| 167 | { |
| 168 | unsigned numOperands = callInst->getNumOperands() - 1; |
| 169 | int numExtra = (int)numOperands-frameInfo.getNumFixedOutgoingArgs(); |
| 170 | if (numExtra <= 0) |
| 171 | continue; |
| 172 | |
| 173 | unsigned int sizeForThisCall; |
| 174 | if (frameInfo.argsOnStackHaveFixedSize()) |
| 175 | { |
| 176 | int argSize = frameInfo.getSizeOfEachArgOnStack(); |
| 177 | sizeForThisCall = numExtra * (unsigned) argSize; |
| 178 | } |
| 179 | else |
| 180 | { |
| 181 | assert(0 && "UNTESTED CODE: Size per stack argument is not " |
| 182 | "fixed on this architecture: use actual arg sizes to " |
| 183 | "compute MaxOptionalArgsSize"); |
| 184 | sizeForThisCall = 0; |
| 185 | for (unsigned i = 0; i < numOperands; ++i) |
Vikram S. Adve | cde3982 | 2002-10-11 16:10:53 +0000 | [diff] [blame] | 186 | sizeForThisCall += target.DataLayout.getTypeSize(callInst-> |
Chris Lattner | 0b12b5f | 2002-06-25 16:13:21 +0000 | [diff] [blame] | 187 | getOperand(i)->getType()); |
| 188 | } |
| 189 | |
| 190 | if (maxSize < sizeForThisCall) |
| 191 | maxSize = sizeForThisCall; |
| 192 | |
| 193 | if ((int)maxOptionalNumArgs < numExtra) |
| 194 | maxOptionalNumArgs = (unsigned) numExtra; |
| 195 | } |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 196 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 197 | return maxSize; |
| 198 | } |
| 199 | |
| 200 | // Align data larger than one L1 cache line on L1 cache line boundaries. |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 201 | // Align all smaller data on the next higher 2^x boundary (4, 8, ...), |
| 202 | // but not higher than the alignment of the largest type we support |
| 203 | // (currently a double word). -- see class TargetData). |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 204 | // |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 205 | // This function is similar to the corresponding function in EmitAssembly.cpp |
| 206 | // but they are unrelated. This one does not align at more than a |
| 207 | // double-word boundary whereas that one might. |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 208 | // |
| 209 | inline unsigned int |
| 210 | SizeToAlignment(unsigned int size, const TargetMachine& target) |
| 211 | { |
| 212 | unsigned short cacheLineSize = target.getCacheInfo().getCacheLineSize(1); |
| 213 | if (size > (unsigned) cacheLineSize / 2) |
| 214 | return cacheLineSize; |
| 215 | else |
| 216 | for (unsigned sz=1; /*no condition*/; sz *= 2) |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 217 | if (sz >= size || sz >= target.DataLayout.getDoubleAlignment()) |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 218 | return sz; |
| 219 | } |
| 220 | |
| 221 | |
Chris Lattner | 8872618 | 2002-10-29 23:40:03 +0000 | [diff] [blame] | 222 | void MachineFunction::CalculateArgSize() { |
| 223 | maxOptionalArgsSize = ComputeMaxOptionalArgsSize(Target, Fn, |
Vikram S. Adve | 03d33bd | 2002-04-25 04:30:43 +0000 | [diff] [blame] | 224 | maxOptionalNumArgs); |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 225 | staticStackSize = maxOptionalArgsSize |
Chris Lattner | 8872618 | 2002-10-29 23:40:03 +0000 | [diff] [blame] | 226 | + Target.getFrameInfo().getMinStackFrameSize(); |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | int |
Misha Brukman | fce1143 | 2002-10-28 00:28:31 +0000 | [diff] [blame] | 230 | MachineFunction::computeOffsetforLocalVar(const TargetMachine& target, |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 231 | const Value* val, |
Vikram S. Adve | e4e4d4e | 2002-03-24 03:39:26 +0000 | [diff] [blame] | 232 | unsigned int& getPaddedSize, |
Chris Lattner | 0c0edf8 | 2002-07-25 06:17:51 +0000 | [diff] [blame] | 233 | unsigned int sizeToUse) |
Vikram S. Adve | 89e2da0 | 2002-03-18 03:36:30 +0000 | [diff] [blame] | 234 | { |
Vikram S. Adve | e4e4d4e | 2002-03-24 03:39:26 +0000 | [diff] [blame] | 235 | if (sizeToUse == 0) |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 236 | sizeToUse = target.findOptimalStorageSize(val->getType()); |
| 237 | unsigned int align = SizeToAlignment(sizeToUse, target); |
| 238 | |
| 239 | bool growUp; |
| 240 | int firstOffset = target.getFrameInfo().getFirstAutomaticVarOffset(*this, |
| 241 | growUp); |
| 242 | int offset = growUp? firstOffset + getAutomaticVarsSize() |
| 243 | : firstOffset - (getAutomaticVarsSize() + sizeToUse); |
| 244 | |
| 245 | int aligned = target.getFrameInfo().adjustAlignment(offset, growUp, align); |
| 246 | getPaddedSize = sizeToUse + abs(aligned - offset); |
| 247 | |
| 248 | return aligned; |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | int |
Misha Brukman | fce1143 | 2002-10-28 00:28:31 +0000 | [diff] [blame] | 252 | MachineFunction::allocateLocalVar(const TargetMachine& target, |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 253 | const Value* val, |
Chris Lattner | 0c0edf8 | 2002-07-25 06:17:51 +0000 | [diff] [blame] | 254 | unsigned int sizeToUse) |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 255 | { |
Vikram S. Adve | 03d33bd | 2002-04-25 04:30:43 +0000 | [diff] [blame] | 256 | assert(! automaticVarsAreaFrozen && |
| 257 | "Size of auto vars area has been used to compute an offset so " |
| 258 | "no more automatic vars should be allocated!"); |
| 259 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 260 | // Check if we've allocated a stack slot for this value already |
| 261 | // |
| 262 | int offset = getOffset(val); |
| 263 | if (offset == INVALID_FRAME_OFFSET) |
| 264 | { |
Vikram S. Adve | e4e4d4e | 2002-03-24 03:39:26 +0000 | [diff] [blame] | 265 | unsigned int getPaddedSize; |
Chris Lattner | 6b94453 | 2002-10-28 01:16:38 +0000 | [diff] [blame] | 266 | offset = computeOffsetforLocalVar(target, val, getPaddedSize, sizeToUse); |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 267 | offsets[val] = offset; |
Vikram S. Adve | e4e4d4e | 2002-03-24 03:39:26 +0000 | [diff] [blame] | 268 | incrementAutomaticVarsSize(getPaddedSize); |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 269 | } |
| 270 | return offset; |
| 271 | } |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 272 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 273 | int |
Misha Brukman | fce1143 | 2002-10-28 00:28:31 +0000 | [diff] [blame] | 274 | MachineFunction::allocateSpilledValue(const TargetMachine& target, |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 275 | const Type* type) |
| 276 | { |
Vikram S. Adve | 03d33bd | 2002-04-25 04:30:43 +0000 | [diff] [blame] | 277 | assert(! spillsAreaFrozen && |
| 278 | "Size of reg spills area has been used to compute an offset so " |
| 279 | "no more register spill slots should be allocated!"); |
| 280 | |
Vikram S. Adve | cde3982 | 2002-10-11 16:10:53 +0000 | [diff] [blame] | 281 | unsigned int size = target.DataLayout.getTypeSize(type); |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 282 | unsigned char align = target.DataLayout.getTypeAlignment(type); |
| 283 | |
| 284 | bool growUp; |
| 285 | int firstOffset = target.getFrameInfo().getRegSpillAreaOffset(*this, growUp); |
| 286 | |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 287 | int offset = growUp? firstOffset + getRegSpillsSize() |
| 288 | : firstOffset - (getRegSpillsSize() + size); |
| 289 | |
| 290 | int aligned = target.getFrameInfo().adjustAlignment(offset, growUp, align); |
| 291 | size += abs(aligned - offset); // include alignment padding in size |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 292 | |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 293 | incrementRegSpillsSize(size); // update size of reg. spills area |
| 294 | |
| 295 | return aligned; |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 296 | } |
| 297 | |
| 298 | int |
Misha Brukman | fce1143 | 2002-10-28 00:28:31 +0000 | [diff] [blame] | 299 | MachineFunction::pushTempValue(const TargetMachine& target, |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 300 | unsigned int size) |
| 301 | { |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 302 | unsigned int align = SizeToAlignment(size, target); |
| 303 | |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 304 | bool growUp; |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 305 | int firstOffset = target.getFrameInfo().getTmpAreaOffset(*this, growUp); |
| 306 | |
| 307 | int offset = growUp? firstOffset + currentTmpValuesSize |
| 308 | : firstOffset - (currentTmpValuesSize + size); |
| 309 | |
| 310 | int aligned = target.getFrameInfo().adjustAlignment(offset, growUp, align); |
| 311 | size += abs(aligned - offset); // include alignment padding in size |
| 312 | |
| 313 | incrementTmpAreaSize(size); // update "current" size of tmp area |
| 314 | |
| 315 | return aligned; |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | void |
Misha Brukman | fce1143 | 2002-10-28 00:28:31 +0000 | [diff] [blame] | 319 | MachineFunction::popAllTempValues(const TargetMachine& target) |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 320 | { |
Vikram S. Adve | 1318bed | 2002-09-16 15:18:16 +0000 | [diff] [blame] | 321 | resetTmpAreaSize(); // clear tmp area to reuse |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 322 | } |
| 323 | |
| 324 | int |
Misha Brukman | fce1143 | 2002-10-28 00:28:31 +0000 | [diff] [blame] | 325 | MachineFunction::getOffset(const Value* val) const |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 326 | { |
Chris Lattner | 09ff112 | 2002-07-24 21:21:32 +0000 | [diff] [blame] | 327 | hash_map<const Value*, int>::const_iterator pair = offsets.find(val); |
Chris Lattner | 6b94453 | 2002-10-28 01:16:38 +0000 | [diff] [blame] | 328 | return (pair == offsets.end()) ? INVALID_FRAME_OFFSET : pair->second; |
Chris Lattner | f2868ce | 2002-02-03 07:54:50 +0000 | [diff] [blame] | 329 | } |