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