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