Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 1 | //===-- Writer.cpp - Library for Printing VM assembly files ------*- C++ -*--=// |
| 2 | // |
| 3 | // This library implements the functionality defined in llvm/Assembly/Writer.h |
| 4 | // |
| 5 | // This library uses the Analysis library to figure out offsets for |
| 6 | // variables in the method tables... |
| 7 | // |
| 8 | // TODO: print out the type name instead of the full type if a particular type |
| 9 | // is in the symbol table... |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "llvm/Assembly/Writer.h" |
| 14 | #include "llvm/Analysis/SlotCalculator.h" |
| 15 | #include "llvm/Module.h" |
| 16 | #include "llvm/Method.h" |
| 17 | #include "llvm/BasicBlock.h" |
| 18 | #include "llvm/ConstPoolVals.h" |
| 19 | #include "llvm/iOther.h" |
| 20 | #include "llvm/iMemory.h" |
| 21 | |
Chris Lattner | 2e9fee4 | 2001-07-12 23:35:26 +0000 | [diff] [blame] | 22 | void DebugValue(const Value *V) { |
| 23 | cerr << V << endl; |
| 24 | } |
| 25 | |
Chris Lattner | 5e5abe3 | 2001-07-20 19:15:21 +0000 | [diff] [blame] | 26 | // WriteAsOperand - Write the name of the specified value out to the specified |
| 27 | // ostream. This can be useful when you just want to print int %reg126, not the |
| 28 | // whole instruction that generated it. |
| 29 | // |
| 30 | ostream &WriteAsOperand(ostream &Out, const Value *V, bool PrintType, |
| 31 | bool PrintName, SlotCalculator *Table) { |
| 32 | if (PrintType) |
| 33 | Out << " " << V->getType(); |
| 34 | |
| 35 | if (V->hasName() && PrintName) { |
| 36 | Out << " %" << V->getName(); |
| 37 | } else { |
| 38 | if (const ConstPoolVal *CPV = V->castConstant()) { |
| 39 | Out << " " << CPV->getStrValue(); |
| 40 | } else { |
| 41 | int Slot; |
| 42 | if (Table) { |
| 43 | Slot = Table->getValSlot(V); |
| 44 | } else { |
| 45 | if (const Type *Ty = V->castType()) { |
| 46 | return Out << " " << Ty; |
| 47 | } else if (const MethodArgument *MA = V->castMethodArgument()) { |
| 48 | Table = new SlotCalculator(MA->getParent(), true); |
| 49 | } else if (const Instruction *I = V->castInstruction()) { |
| 50 | Table = new SlotCalculator(I->getParent()->getParent(), true); |
| 51 | } else if (const BasicBlock *BB = V->castBasicBlock()) { |
| 52 | Table = new SlotCalculator(BB->getParent(), true); |
| 53 | } else if (const Method *Meth = V->castMethod()) { |
| 54 | Table = new SlotCalculator(Meth, true); |
| 55 | } else if (const Module *Mod = V->castModule()) { |
| 56 | Table = new SlotCalculator(Mod, true); |
| 57 | } else { |
| 58 | return Out << "BAD VALUE TYPE!"; |
| 59 | } |
| 60 | Slot = Table->getValSlot(V); |
| 61 | delete Table; |
| 62 | } |
| 63 | if (Slot >= 0) Out << " %" << Slot; |
| 64 | else if (PrintName) |
| 65 | Out << "<badref>"; // Not embeded into a location? |
| 66 | } |
| 67 | } |
| 68 | return Out; |
| 69 | } |
| 70 | |
| 71 | |
Chris Lattner | 2e9fee4 | 2001-07-12 23:35:26 +0000 | [diff] [blame] | 72 | |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 73 | class AssemblyWriter : public ModuleAnalyzer { |
| 74 | ostream &Out; |
| 75 | SlotCalculator &Table; |
| 76 | public: |
| 77 | inline AssemblyWriter(ostream &o, SlotCalculator &Tab) : Out(o), Table(Tab) { |
| 78 | } |
| 79 | |
| 80 | inline void write(const Module *M) { processModule(M); } |
| 81 | inline void write(const Method *M) { processMethod(M); } |
| 82 | inline void write(const BasicBlock *BB) { processBasicBlock(BB); } |
| 83 | inline void write(const Instruction *I) { processInstruction(I); } |
| 84 | inline void write(const ConstPoolVal *CPV) { processConstant(CPV); } |
| 85 | |
| 86 | protected: |
| 87 | virtual bool visitMethod(const Method *M); |
| 88 | virtual bool processConstPool(const ConstantPool &CP, bool isMethod); |
| 89 | virtual bool processConstant(const ConstPoolVal *CPV); |
| 90 | virtual bool processMethod(const Method *M); |
| 91 | virtual bool processMethodArgument(const MethodArgument *MA); |
| 92 | virtual bool processBasicBlock(const BasicBlock *BB); |
| 93 | virtual bool processInstruction(const Instruction *I); |
| 94 | |
| 95 | private : |
| 96 | void writeOperand(const Value *Op, bool PrintType, bool PrintName = true); |
| 97 | }; |
| 98 | |
| 99 | |
| 100 | |
| 101 | // visitMethod - This member is called after the above two steps, visting each |
| 102 | // method, because they are effectively values that go into the constant pool. |
| 103 | // |
| 104 | bool AssemblyWriter::visitMethod(const Method *M) { |
| 105 | return false; |
| 106 | } |
| 107 | |
| 108 | bool AssemblyWriter::processConstPool(const ConstantPool &CP, bool isMethod) { |
| 109 | // Done printing arguments... |
Chris Lattner | 90e0d46 | 2001-07-25 22:47:55 +0000 | [diff] [blame] | 110 | if (isMethod) { |
Chris Lattner | 2091efb | 2001-07-28 17:49:02 +0000 | [diff] [blame^] | 111 | const MethodType *MT = CP.getParentV()->castMethodAsserting()->getType()-> |
| 112 | isMethodType(); |
| 113 | if (MT->isVarArg()) { |
| 114 | if (MT->getParamTypes().size()) |
| 115 | Out << ", "; |
| 116 | Out << "..."; // Output varargs portion of signature! |
| 117 | } |
Chris Lattner | 90e0d46 | 2001-07-25 22:47:55 +0000 | [diff] [blame] | 118 | Out << ")\n"; |
| 119 | } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 120 | |
| 121 | ModuleAnalyzer::processConstPool(CP, isMethod); |
| 122 | |
Chris Lattner | a7620d9 | 2001-07-15 06:35:59 +0000 | [diff] [blame] | 123 | if (isMethod) { |
| 124 | if (!CP.getParentV()->castMethodAsserting()->isExternal()) |
| 125 | Out << "begin"; |
| 126 | } else { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 127 | Out << "implementation\n"; |
Chris Lattner | a7620d9 | 2001-07-15 06:35:59 +0000 | [diff] [blame] | 128 | } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 129 | return false; |
| 130 | } |
| 131 | |
| 132 | |
| 133 | // processConstant - Print out a constant pool entry... |
| 134 | // |
| 135 | bool AssemblyWriter::processConstant(const ConstPoolVal *CPV) { |
Chris Lattner | ee998be | 2001-07-26 16:29:38 +0000 | [diff] [blame] | 136 | if (!CPV->hasName()) |
| 137 | return false; // Don't print out unnamed constants, they will be inlined |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 138 | |
Chris Lattner | ee998be | 2001-07-26 16:29:38 +0000 | [diff] [blame] | 139 | // Print out name... |
| 140 | Out << "\t%" << CPV->getName() << " = "; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 141 | |
Chris Lattner | ee998be | 2001-07-26 16:29:38 +0000 | [diff] [blame] | 142 | // Print out the constant type... |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 143 | Out << CPV->getType(); |
| 144 | |
| 145 | // Write the value out now... |
| 146 | writeOperand(CPV, false, false); |
| 147 | |
| 148 | if (!CPV->hasName() && CPV->getType() != Type::VoidTy) { |
| 149 | int Slot = Table.getValSlot(CPV); // Print out the def slot taken... |
| 150 | Out << "\t\t; <" << CPV->getType() << ">:"; |
| 151 | if (Slot >= 0) Out << Slot; |
| 152 | else Out << "<badref>"; |
| 153 | } |
| 154 | |
| 155 | Out << endl; |
| 156 | return false; |
| 157 | } |
| 158 | |
| 159 | // processMethod - Process all aspects of a method. |
| 160 | // |
| 161 | bool AssemblyWriter::processMethod(const Method *M) { |
| 162 | // Print out the return type and name... |
Chris Lattner | a7620d9 | 2001-07-15 06:35:59 +0000 | [diff] [blame] | 163 | Out << "\n" << (M->isExternal() ? "declare " : "") |
| 164 | << M->getReturnType() << " \"" << M->getName() << "\"("; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 165 | Table.incorporateMethod(M); |
| 166 | ModuleAnalyzer::processMethod(M); |
| 167 | Table.purgeMethod(); |
Chris Lattner | a7620d9 | 2001-07-15 06:35:59 +0000 | [diff] [blame] | 168 | if (!M->isExternal()) |
| 169 | Out << "end\n"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 170 | return false; |
| 171 | } |
| 172 | |
| 173 | // processMethodArgument - This member is called for every argument that |
| 174 | // is passed into the method. Simply print it out |
| 175 | // |
| 176 | bool AssemblyWriter::processMethodArgument(const MethodArgument *Arg) { |
| 177 | // Insert commas as we go... the first arg doesn't get a comma |
| 178 | if (Arg != Arg->getParent()->getArgumentList().front()) Out << ", "; |
| 179 | |
| 180 | // Output type... |
| 181 | Out << Arg->getType(); |
| 182 | |
| 183 | // Output name, if available... |
| 184 | if (Arg->hasName()) |
| 185 | Out << " %" << Arg->getName(); |
| 186 | else if (Table.getValSlot(Arg) < 0) |
| 187 | Out << "<badref>"; |
| 188 | |
| 189 | return false; |
| 190 | } |
| 191 | |
| 192 | // processBasicBlock - This member is called for each basic block in a methd. |
| 193 | // |
| 194 | bool AssemblyWriter::processBasicBlock(const BasicBlock *BB) { |
| 195 | if (BB->hasName()) { // Print out the label if it exists... |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 196 | Out << "\n" << BB->getName() << ":"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 197 | } else { |
| 198 | int Slot = Table.getValSlot(BB); |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 199 | Out << "\n; <label>:"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 200 | if (Slot >= 0) |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 201 | Out << Slot; // Extra newline seperates out label's |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 202 | else |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 203 | Out << "<badref>"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 204 | } |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 205 | Out << "\t\t\t\t\t;[#uses=" << BB->use_size() << "]\n"; // Output # uses |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 206 | |
| 207 | ModuleAnalyzer::processBasicBlock(BB); |
| 208 | return false; |
| 209 | } |
| 210 | |
| 211 | // processInstruction - This member is called for each Instruction in a methd. |
| 212 | // |
| 213 | bool AssemblyWriter::processInstruction(const Instruction *I) { |
| 214 | Out << "\t"; |
| 215 | |
| 216 | // Print out name if it exists... |
| 217 | if (I && I->hasName()) |
| 218 | Out << "%" << I->getName() << " = "; |
| 219 | |
| 220 | // Print out the opcode... |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 221 | Out << I->getOpcodeName(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 222 | |
| 223 | // Print out the type of the operands... |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 224 | const Value *Operand = I->getNumOperands() ? I->getOperand(0) : 0; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 225 | |
| 226 | // Special case conditional branches to swizzle the condition out to the front |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 227 | if (I->getOpcode() == Instruction::Br && I->getNumOperands() > 1) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 228 | writeOperand(I->getOperand(2), true); |
| 229 | Out << ","; |
| 230 | writeOperand(Operand, true); |
| 231 | Out << ","; |
| 232 | writeOperand(I->getOperand(1), true); |
| 233 | |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 234 | } else if (I->getOpcode() == Instruction::Switch) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 235 | // Special case switch statement to get formatting nice and correct... |
| 236 | writeOperand(Operand , true); Out << ","; |
| 237 | writeOperand(I->getOperand(1), true); Out << " ["; |
| 238 | |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 239 | for (unsigned op = 2, Eop = I->getNumOperands(); op < Eop; op += 2) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 240 | Out << "\n\t\t"; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 241 | writeOperand(I->getOperand(op ), true); Out << ","; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 242 | writeOperand(I->getOperand(op+1), true); |
| 243 | } |
| 244 | Out << "\n\t]"; |
Chris Lattner | 4cee8d8 | 2001-06-27 23:41:11 +0000 | [diff] [blame] | 245 | } else if (I->isPHINode()) { |
Chris Lattner | 931ef3b | 2001-06-11 15:04:20 +0000 | [diff] [blame] | 246 | Out << " " << Operand->getType(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 247 | |
Chris Lattner | 931ef3b | 2001-06-11 15:04:20 +0000 | [diff] [blame] | 248 | Out << " ["; writeOperand(Operand, false); Out << ","; |
Chris Lattner | 4b94e23 | 2001-06-21 05:29:56 +0000 | [diff] [blame] | 249 | writeOperand(I->getOperand(1), false); Out << " ]"; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 250 | for (unsigned op = 2, Eop = I->getNumOperands(); op < Eop; op += 2) { |
| 251 | Out << ", ["; |
| 252 | writeOperand(I->getOperand(op ), false); Out << ","; |
Chris Lattner | 4b94e23 | 2001-06-21 05:29:56 +0000 | [diff] [blame] | 253 | writeOperand(I->getOperand(op+1), false); Out << " ]"; |
Chris Lattner | 931ef3b | 2001-06-11 15:04:20 +0000 | [diff] [blame] | 254 | } |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 255 | } else if (I->getOpcode() == Instruction::Ret && !Operand) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 256 | Out << " void"; |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 257 | } else if (I->getOpcode() == Instruction::Call) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 258 | writeOperand(Operand, true); |
| 259 | Out << "("; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 260 | if (I->getNumOperands() > 1) writeOperand(I->getOperand(1), true); |
| 261 | for (unsigned op = 2, Eop = I->getNumOperands(); op < Eop; ++op) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 262 | Out << ","; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 263 | writeOperand(I->getOperand(op), true); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | Out << " )"; |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 267 | } else if (I->getOpcode() == Instruction::Malloc || |
| 268 | I->getOpcode() == Instruction::Alloca) { |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 269 | Out << " " << ((const PointerType*)I->getType())->getValueType(); |
| 270 | if (I->getNumOperands()) { |
| 271 | Out << ","; |
| 272 | writeOperand(I->getOperand(0), true); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 273 | } |
Chris Lattner | a682182 | 2001-07-08 04:57:15 +0000 | [diff] [blame] | 274 | } else if (I->getOpcode() == Instruction::Cast) { |
| 275 | writeOperand(Operand, true); |
| 276 | Out << " to " << I->getType(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 277 | } else if (Operand) { // Print the normal way... |
| 278 | |
| 279 | // PrintAllTypes - Instructions who have operands of all the same type |
| 280 | // omit the type from all but the first operand. If the instruction has |
| 281 | // different type operands (for example br), then they are all printed. |
| 282 | bool PrintAllTypes = false; |
| 283 | const Type *TheType = Operand->getType(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 284 | |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 285 | for (unsigned i = 1, E = I->getNumOperands(); i != E; ++i) { |
| 286 | Operand = I->getOperand(i); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 287 | if (Operand->getType() != TheType) { |
| 288 | PrintAllTypes = true; // We have differing types! Print them all! |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | if (!PrintAllTypes) |
| 294 | Out << " " << I->getOperand(0)->getType(); |
| 295 | |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 296 | for (unsigned i = 0, E = I->getNumOperands(); i != E; ++i) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 297 | if (i) Out << ","; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 298 | writeOperand(I->getOperand(i), PrintAllTypes); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 299 | } |
| 300 | } |
| 301 | |
| 302 | // Print a little comment after the instruction indicating which slot it |
| 303 | // occupies. |
| 304 | // |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 305 | if (I->getType() != Type::VoidTy) { |
| 306 | Out << "\t\t; <" << I->getType() << ">"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 307 | |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 308 | if (!I->hasName()) { |
| 309 | int Slot = Table.getValSlot(I); // Print out the def slot taken... |
| 310 | if (Slot >= 0) Out << ":" << Slot; |
| 311 | else Out << ":<badref>"; |
| 312 | } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 313 | Out << "\t[#uses=" << I->use_size() << "]"; // Output # uses |
| 314 | } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 315 | Out << endl; |
| 316 | |
| 317 | return false; |
| 318 | } |
| 319 | |
| 320 | |
| 321 | void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType, |
| 322 | bool PrintName) { |
Chris Lattner | 5e5abe3 | 2001-07-20 19:15:21 +0000 | [diff] [blame] | 323 | WriteAsOperand(Out, Operand, PrintType, PrintName, &Table); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | |
| 327 | //===----------------------------------------------------------------------===// |
| 328 | // External Interface declarations |
| 329 | //===----------------------------------------------------------------------===// |
| 330 | |
| 331 | |
| 332 | |
| 333 | void WriteToAssembly(const Module *M, ostream &o) { |
| 334 | if (M == 0) { o << "<null> module\n"; return; } |
| 335 | SlotCalculator SlotTable(M, true); |
| 336 | AssemblyWriter W(o, SlotTable); |
| 337 | |
| 338 | W.write(M); |
| 339 | } |
| 340 | |
| 341 | void WriteToAssembly(const Method *M, ostream &o) { |
| 342 | if (M == 0) { o << "<null> method\n"; return; } |
| 343 | SlotCalculator SlotTable(M->getParent(), true); |
| 344 | AssemblyWriter W(o, SlotTable); |
| 345 | |
| 346 | W.write(M); |
| 347 | } |
| 348 | |
| 349 | |
| 350 | void WriteToAssembly(const BasicBlock *BB, ostream &o) { |
| 351 | if (BB == 0) { o << "<null> basic block\n"; return; } |
| 352 | |
| 353 | SlotCalculator SlotTable(BB->getParent(), true); |
| 354 | AssemblyWriter W(o, SlotTable); |
| 355 | |
| 356 | W.write(BB); |
| 357 | } |
| 358 | |
| 359 | void WriteToAssembly(const ConstPoolVal *CPV, ostream &o) { |
| 360 | if (CPV == 0) { o << "<null> constant pool value\n"; return; } |
Chris Lattner | 2091efb | 2001-07-28 17:49:02 +0000 | [diff] [blame^] | 361 | WriteAsOperand(o, CPV, true, true, 0); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 362 | } |
| 363 | |
| 364 | void WriteToAssembly(const Instruction *I, ostream &o) { |
| 365 | if (I == 0) { o << "<null> instruction\n"; return; } |
| 366 | |
| 367 | SlotCalculator SlotTable(I->getParent() ? I->getParent()->getParent() : 0, |
| 368 | true); |
| 369 | AssemblyWriter W(o, SlotTable); |
| 370 | |
| 371 | W.write(I); |
| 372 | } |