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