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" |
Chris Lattner | da97550 | 2001-09-10 07:58:01 +0000 | [diff] [blame] | 17 | #include "llvm/GlobalVariable.h" |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 18 | #include "llvm/BasicBlock.h" |
| 19 | #include "llvm/ConstPoolVals.h" |
| 20 | #include "llvm/iOther.h" |
| 21 | #include "llvm/iMemory.h" |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 22 | #include "llvm/iTerminators.h" |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 23 | #include "llvm/SymbolTable.h" |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 24 | #include "llvm/Support/STLExtras.h" |
| 25 | #include "llvm/Support/StringExtras.h" |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 26 | #include <algorithm> |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 27 | #include <map> |
| 28 | |
| 29 | static SlotCalculator *createSlotCalculator(const Value *V) { |
| 30 | assert(!isa<Type>(V) && "Can't create an SC for a type!"); |
| 31 | if (const MethodArgument *MA =dyn_cast<const MethodArgument>(V)){ |
| 32 | return new SlotCalculator(MA->getParent(), true); |
| 33 | } else if (const Instruction *I = dyn_cast<const Instruction>(V)) { |
| 34 | return new SlotCalculator(I->getParent()->getParent(), true); |
| 35 | } else if (const BasicBlock *BB = dyn_cast<const BasicBlock>(V)) { |
| 36 | return new SlotCalculator(BB->getParent(), true); |
| 37 | } else if (const GlobalVariable *GV =dyn_cast<const GlobalVariable>(V)){ |
| 38 | return new SlotCalculator(GV->getParent(), true); |
| 39 | } else if (const Method *Meth = dyn_cast<const Method>(V)) { |
| 40 | return new SlotCalculator(Meth, true); |
| 41 | } else if (const Module *Mod = dyn_cast<const Module>(V)) { |
| 42 | return new SlotCalculator(Mod, true); |
| 43 | } |
| 44 | return 0; |
| 45 | } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 46 | |
Chris Lattner | 5e5abe3 | 2001-07-20 19:15:21 +0000 | [diff] [blame] | 47 | // WriteAsOperand - Write the name of the specified value out to the specified |
| 48 | // ostream. This can be useful when you just want to print int %reg126, not the |
| 49 | // whole instruction that generated it. |
| 50 | // |
| 51 | ostream &WriteAsOperand(ostream &Out, const Value *V, bool PrintType, |
| 52 | bool PrintName, SlotCalculator *Table) { |
| 53 | if (PrintType) |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 54 | Out << " " << V->getType()->getDescription(); |
Chris Lattner | 5e5abe3 | 2001-07-20 19:15:21 +0000 | [diff] [blame] | 55 | |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 56 | if (PrintName && V->hasName()) { |
Chris Lattner | 5e5abe3 | 2001-07-20 19:15:21 +0000 | [diff] [blame] | 57 | Out << " %" << V->getName(); |
| 58 | } else { |
Chris Lattner | 4b717c0 | 2001-10-01 16:18:37 +0000 | [diff] [blame] | 59 | if (const ConstPoolVal *CPV = dyn_cast<const ConstPoolVal>(V)) { |
Chris Lattner | 5e5abe3 | 2001-07-20 19:15:21 +0000 | [diff] [blame] | 60 | Out << " " << CPV->getStrValue(); |
| 61 | } else { |
| 62 | int Slot; |
| 63 | if (Table) { |
| 64 | Slot = Table->getValSlot(V); |
| 65 | } else { |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 66 | if (const Type *Ty = dyn_cast<const Type>(V)) |
| 67 | return Out << " " << Ty; |
| 68 | |
| 69 | Table = createSlotCalculator(V); |
| 70 | if (Table == 0) return Out << "BAD VALUE TYPE!"; |
| 71 | |
Chris Lattner | 5e5abe3 | 2001-07-20 19:15:21 +0000 | [diff] [blame] | 72 | Slot = Table->getValSlot(V); |
| 73 | delete Table; |
| 74 | } |
| 75 | if (Slot >= 0) Out << " %" << Slot; |
| 76 | else if (PrintName) |
| 77 | Out << "<badref>"; // Not embeded into a location? |
| 78 | } |
| 79 | } |
| 80 | return Out; |
| 81 | } |
| 82 | |
| 83 | |
Chris Lattner | 2e9fee4 | 2001-07-12 23:35:26 +0000 | [diff] [blame] | 84 | |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 85 | class AssemblyWriter { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 86 | ostream &Out; |
| 87 | SlotCalculator &Table; |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 88 | const Module *TheModule; |
| 89 | map<const Type *, string> TypeNames; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 90 | public: |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 91 | inline AssemblyWriter(ostream &o, SlotCalculator &Tab, const Module *M) |
| 92 | : Out(o), Table(Tab), TheModule(M) { |
| 93 | |
| 94 | // If the module has a symbol table, take all global types and stuff their |
| 95 | // names into the TypeNames map. |
| 96 | // |
| 97 | if (M && M->hasSymbolTable()) { |
| 98 | const SymbolTable *ST = M->getSymbolTable(); |
| 99 | SymbolTable::const_iterator PI = ST->find(Type::TypeTy); |
| 100 | if (PI != ST->end()) { |
| 101 | SymbolTable::type_const_iterator I = PI->second.begin(); |
| 102 | for (; I != PI->second.end(); ++I) { |
| 103 | // As a heuristic, don't insert pointer to primitive types, because |
| 104 | // they are used too often to have a single useful name. |
| 105 | // |
| 106 | const Type *Ty = cast<const Type>(I->second); |
| 107 | if (!isa<PointerType>(Ty) || |
| 108 | !cast<PointerType>(Ty)->getValueType()->isPrimitiveType()) |
| 109 | TypeNames.insert(make_pair(Ty, "%"+I->first)); |
| 110 | } |
| 111 | } |
| 112 | } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 113 | } |
| 114 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 115 | inline void write(const Module *M) { printModule(M); } |
| 116 | inline void write(const GlobalVariable *G) { printGlobal(G); } |
| 117 | inline void write(const Method *M) { printMethod(M); } |
| 118 | inline void write(const BasicBlock *BB) { printBasicBlock(BB); } |
| 119 | inline void write(const Instruction *I) { printInstruction(I); } |
| 120 | inline void write(const ConstPoolVal *CPV) { printConstant(CPV); } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 121 | |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 122 | private : |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 123 | void printModule(const Module *M); |
| 124 | void printSymbolTable(const SymbolTable &ST); |
| 125 | void printConstant(const ConstPoolVal *CPV); |
| 126 | void printGlobal(const GlobalVariable *GV); |
| 127 | void printMethod(const Method *M); |
| 128 | void printMethodArgument(const MethodArgument *MA); |
| 129 | void printBasicBlock(const BasicBlock *BB); |
| 130 | void printInstruction(const Instruction *I); |
| 131 | ostream &printType(const Type *Ty); |
| 132 | |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 133 | void writeOperand(const Value *Op, bool PrintType, bool PrintName = true); |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 134 | |
| 135 | // printInfoComment - Print a little comment after the instruction indicating |
| 136 | // which slot it occupies. |
| 137 | void printInfoComment(const Value *V); |
| 138 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 139 | |
| 140 | string calcTypeName(const Type *Ty, vector<const Type *> &TypeStack); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 141 | }; |
| 142 | |
| 143 | |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 144 | void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType, |
| 145 | bool PrintName) { |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 146 | if (PrintType) { Out << " "; printType(Operand->getType()); } |
| 147 | WriteAsOperand(Out, Operand, false, PrintName, &Table); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 148 | } |
| 149 | |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 150 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 151 | void AssemblyWriter::printModule(const Module *M) { |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 152 | // Loop over the symbol table, emitting all named constants... |
| 153 | if (M->hasSymbolTable()) |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 154 | printSymbolTable(*M->getSymbolTable()); |
Chris Lattner | da97550 | 2001-09-10 07:58:01 +0000 | [diff] [blame] | 155 | |
| 156 | for_each(M->gbegin(), M->gend(), |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 157 | bind_obj(this, &AssemblyWriter::printGlobal)); |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 158 | |
Vikram S. Adve | 13ba19a | 2001-09-18 12:48:16 +0000 | [diff] [blame] | 159 | Out << "implementation\n"; |
| 160 | |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 161 | // Output all of the methods... |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 162 | for_each(M->begin(), M->end(), bind_obj(this,&AssemblyWriter::printMethod)); |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 163 | } |
| 164 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 165 | void AssemblyWriter::printGlobal(const GlobalVariable *GV) { |
Chris Lattner | da97550 | 2001-09-10 07:58:01 +0000 | [diff] [blame] | 166 | if (GV->hasName()) Out << "%" << GV->getName() << " = "; |
Chris Lattner | 3779864 | 2001-09-18 04:01:05 +0000 | [diff] [blame] | 167 | |
| 168 | if (!GV->hasInitializer()) Out << "uninitialized "; |
| 169 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 170 | Out << (GV->isConstant() ? "constant " : "global "); |
| 171 | printType(GV->getType()->getValueType()); |
Chris Lattner | 3779864 | 2001-09-18 04:01:05 +0000 | [diff] [blame] | 172 | |
| 173 | if (GV->hasInitializer()) |
| 174 | writeOperand(GV->getInitializer(), false, false); |
| 175 | |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 176 | printInfoComment(GV); |
Chris Lattner | 3779864 | 2001-09-18 04:01:05 +0000 | [diff] [blame] | 177 | Out << endl; |
Chris Lattner | da97550 | 2001-09-10 07:58:01 +0000 | [diff] [blame] | 178 | } |
| 179 | |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 180 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 181 | // printSymbolTable - Run through symbol table looking for named constants |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 182 | // if a named constant is found, emit it's declaration... |
| 183 | // |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 184 | void AssemblyWriter::printSymbolTable(const SymbolTable &ST) { |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 185 | for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) { |
| 186 | SymbolTable::type_const_iterator I = ST.type_begin(TI->first); |
| 187 | SymbolTable::type_const_iterator End = ST.type_end(TI->first); |
| 188 | |
| 189 | for (; I != End; ++I) { |
| 190 | const Value *V = I->second; |
Chris Lattner | 3856934 | 2001-10-01 20:11:19 +0000 | [diff] [blame] | 191 | if (const ConstPoolVal *CPV = dyn_cast<const ConstPoolVal>(V)) { |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 192 | printConstant(CPV); |
Chris Lattner | 3856934 | 2001-10-01 20:11:19 +0000 | [diff] [blame] | 193 | } else if (const Type *Ty = dyn_cast<const Type>(V)) { |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 194 | Out << "\t%" << I->first << " = type " << Ty->getDescription() << endl; |
| 195 | } |
| 196 | } |
Chris Lattner | a7620d9 | 2001-07-15 06:35:59 +0000 | [diff] [blame] | 197 | } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 201 | // printConstant - Print out a constant pool entry... |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 202 | // |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 203 | void AssemblyWriter::printConstant(const ConstPoolVal *CPV) { |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 204 | // Don't print out unnamed constants, they will be inlined |
| 205 | if (!CPV->hasName()) return; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 206 | |
Chris Lattner | ee998be | 2001-07-26 16:29:38 +0000 | [diff] [blame] | 207 | // Print out name... |
| 208 | Out << "\t%" << CPV->getName() << " = "; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 209 | |
Chris Lattner | ee998be | 2001-07-26 16:29:38 +0000 | [diff] [blame] | 210 | // Print out the constant type... |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 211 | printType(CPV->getType()); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 212 | |
| 213 | // Write the value out now... |
| 214 | writeOperand(CPV, false, false); |
| 215 | |
| 216 | if (!CPV->hasName() && CPV->getType() != Type::VoidTy) { |
| 217 | int Slot = Table.getValSlot(CPV); // Print out the def slot taken... |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 218 | Out << "\t\t; <"; |
| 219 | printType(CPV->getType()) << ">:"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 220 | if (Slot >= 0) Out << Slot; |
| 221 | else Out << "<badref>"; |
| 222 | } |
| 223 | |
| 224 | Out << endl; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 227 | // printMethod - Print all aspects of a method. |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 228 | // |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 229 | void AssemblyWriter::printMethod(const Method *M) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 230 | // Print out the return type and name... |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 231 | Out << "\n" << (M->isExternal() ? "declare " : ""); |
| 232 | printType(M->getReturnType()) << " \"" << M->getName() << "\"("; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 233 | Table.incorporateMethod(M); |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 234 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 235 | // Loop over the arguments, printing them... |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 236 | const MethodType *MT = cast<const MethodType>(M->getMethodType()); |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 237 | |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 238 | if (!M->isExternal()) { |
| 239 | for_each(M->getArgumentList().begin(), M->getArgumentList().end(), |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 240 | bind_obj(this, &AssemblyWriter::printMethodArgument)); |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 241 | } else { |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 242 | // Loop over the arguments, printing them... |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 243 | const MethodType *MT = cast<const MethodType>(M->getMethodType()); |
| 244 | for (MethodType::ParamTypes::const_iterator I = MT->getParamTypes().begin(), |
| 245 | E = MT->getParamTypes().end(); I != E; ++I) { |
| 246 | if (I != MT->getParamTypes().begin()) Out << ", "; |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 247 | printType(*I); |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 248 | } |
| 249 | } |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 250 | |
| 251 | // Finish printing arguments... |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 252 | if (MT->isVarArg()) { |
| 253 | if (MT->getParamTypes().size()) Out << ", "; |
| 254 | Out << "..."; // Output varargs portion of signature! |
| 255 | } |
| 256 | Out << ")\n"; |
| 257 | |
| 258 | if (!M->isExternal()) { |
| 259 | // Loop over the symbol table, emitting all named constants... |
| 260 | if (M->hasSymbolTable()) |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 261 | printSymbolTable(*M->getSymbolTable()); |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 262 | |
| 263 | Out << "begin"; |
| 264 | |
| 265 | // Output all of its basic blocks... for the method |
| 266 | for_each(M->begin(), M->end(), |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 267 | bind_obj(this, &AssemblyWriter::printBasicBlock)); |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 268 | |
Chris Lattner | a7620d9 | 2001-07-15 06:35:59 +0000 | [diff] [blame] | 269 | Out << "end\n"; |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 270 | } |
| 271 | |
| 272 | Table.purgeMethod(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 273 | } |
| 274 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 275 | // printMethodArgument - This member is called for every argument that |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 276 | // is passed into the method. Simply print it out |
| 277 | // |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 278 | void AssemblyWriter::printMethodArgument(const MethodArgument *Arg) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 279 | // Insert commas as we go... the first arg doesn't get a comma |
| 280 | if (Arg != Arg->getParent()->getArgumentList().front()) Out << ", "; |
| 281 | |
| 282 | // Output type... |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 283 | printType(Arg->getType()); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 284 | |
| 285 | // Output name, if available... |
| 286 | if (Arg->hasName()) |
| 287 | Out << " %" << Arg->getName(); |
| 288 | else if (Table.getValSlot(Arg) < 0) |
| 289 | Out << "<badref>"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 290 | } |
| 291 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 292 | // printBasicBlock - This member is called for each basic block in a methd. |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 293 | // |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 294 | void AssemblyWriter::printBasicBlock(const BasicBlock *BB) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 295 | if (BB->hasName()) { // Print out the label if it exists... |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 296 | Out << "\n" << BB->getName() << ":"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 297 | } else { |
| 298 | int Slot = Table.getValSlot(BB); |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 299 | Out << "\n; <label>:"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 300 | if (Slot >= 0) |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 301 | Out << Slot; // Extra newline seperates out label's |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 302 | else |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 303 | Out << "<badref>"; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 304 | } |
Chris Lattner | a2f0187 | 2001-06-07 16:58:55 +0000 | [diff] [blame] | 305 | 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] | 306 | |
Chris Lattner | fee714f | 2001-09-07 16:36:04 +0000 | [diff] [blame] | 307 | // Output all of the instructions in the basic block... |
| 308 | for_each(BB->begin(), BB->end(), |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 309 | bind_obj(this, &AssemblyWriter::printInstruction)); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 310 | } |
| 311 | |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 312 | |
| 313 | // printInfoComment - Print a little comment after the instruction indicating |
| 314 | // which slot it occupies. |
| 315 | // |
| 316 | void AssemblyWriter::printInfoComment(const Value *V) { |
| 317 | if (V->getType() != Type::VoidTy) { |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 318 | Out << "\t\t; <"; |
| 319 | printType(V->getType()) << ">"; |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 320 | |
| 321 | if (!V->hasName()) { |
| 322 | int Slot = Table.getValSlot(V); // Print out the def slot taken... |
| 323 | if (Slot >= 0) Out << ":" << Slot; |
| 324 | else Out << ":<badref>"; |
| 325 | } |
| 326 | Out << "\t[#uses=" << V->use_size() << "]"; // Output # uses |
| 327 | } |
| 328 | } |
| 329 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 330 | // printInstruction - This member is called for each Instruction in a methd. |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 331 | // |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 332 | void AssemblyWriter::printInstruction(const Instruction *I) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 333 | Out << "\t"; |
| 334 | |
| 335 | // Print out name if it exists... |
| 336 | if (I && I->hasName()) |
| 337 | Out << "%" << I->getName() << " = "; |
| 338 | |
| 339 | // Print out the opcode... |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 340 | Out << I->getOpcodeName(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 341 | |
| 342 | // Print out the type of the operands... |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 343 | const Value *Operand = I->getNumOperands() ? I->getOperand(0) : 0; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 344 | |
| 345 | // Special case conditional branches to swizzle the condition out to the front |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 346 | if (I->getOpcode() == Instruction::Br && I->getNumOperands() > 1) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 347 | writeOperand(I->getOperand(2), true); |
| 348 | Out << ","; |
| 349 | writeOperand(Operand, true); |
| 350 | Out << ","; |
| 351 | writeOperand(I->getOperand(1), true); |
| 352 | |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 353 | } else if (I->getOpcode() == Instruction::Switch) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 354 | // Special case switch statement to get formatting nice and correct... |
| 355 | writeOperand(Operand , true); Out << ","; |
| 356 | writeOperand(I->getOperand(1), true); Out << " ["; |
| 357 | |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 358 | for (unsigned op = 2, Eop = I->getNumOperands(); op < Eop; op += 2) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 359 | Out << "\n\t\t"; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 360 | writeOperand(I->getOperand(op ), true); Out << ","; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 361 | writeOperand(I->getOperand(op+1), true); |
| 362 | } |
| 363 | Out << "\n\t]"; |
Chris Lattner | da55810 | 2001-10-02 03:41:24 +0000 | [diff] [blame] | 364 | } else if (isa<PHINode>(I)) { |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 365 | Out << " "; |
| 366 | printType(Operand->getType()); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 367 | |
Chris Lattner | 931ef3b | 2001-06-11 15:04:20 +0000 | [diff] [blame] | 368 | Out << " ["; writeOperand(Operand, false); Out << ","; |
Chris Lattner | 4b94e23 | 2001-06-21 05:29:56 +0000 | [diff] [blame] | 369 | writeOperand(I->getOperand(1), false); Out << " ]"; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 370 | for (unsigned op = 2, Eop = I->getNumOperands(); op < Eop; op += 2) { |
| 371 | Out << ", ["; |
| 372 | writeOperand(I->getOperand(op ), false); Out << ","; |
Chris Lattner | 4b94e23 | 2001-06-21 05:29:56 +0000 | [diff] [blame] | 373 | writeOperand(I->getOperand(op+1), false); Out << " ]"; |
Chris Lattner | 931ef3b | 2001-06-11 15:04:20 +0000 | [diff] [blame] | 374 | } |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 375 | } else if (isa<ReturnInst>(I) && !Operand) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 376 | Out << " void"; |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 377 | } else if (isa<CallInst>(I)) { |
Chris Lattner | 7fac070 | 2001-10-03 14:53:21 +0000 | [diff] [blame] | 378 | // TODO: Should try to print out short form of the Call instruction |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 379 | writeOperand(Operand, true); |
| 380 | Out << "("; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 381 | if (I->getNumOperands() > 1) writeOperand(I->getOperand(1), true); |
| 382 | for (unsigned op = 2, Eop = I->getNumOperands(); op < Eop; ++op) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 383 | Out << ","; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 384 | writeOperand(I->getOperand(op), true); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | Out << " )"; |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 388 | } else if (const InvokeInst *II = dyn_cast<InvokeInst>(I)) { |
| 389 | // TODO: Should try to print out short form of the Invoke instruction |
| 390 | writeOperand(Operand, true); |
| 391 | Out << "("; |
| 392 | if (I->getNumOperands() > 3) writeOperand(I->getOperand(3), true); |
| 393 | for (unsigned op = 4, Eop = I->getNumOperands(); op < Eop; ++op) { |
| 394 | Out << ","; |
| 395 | writeOperand(I->getOperand(op), true); |
| 396 | } |
| 397 | |
| 398 | Out << " )\n\t\t\tto"; |
| 399 | writeOperand(II->getNormalDest(), true); |
| 400 | Out << " except"; |
| 401 | writeOperand(II->getExceptionalDest(), true); |
| 402 | |
Chris Lattner | b1ca9cb | 2001-07-07 19:24:15 +0000 | [diff] [blame] | 403 | } else if (I->getOpcode() == Instruction::Malloc || |
| 404 | I->getOpcode() == Instruction::Alloca) { |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 405 | Out << " "; |
| 406 | printType(cast<const PointerType>(I->getType())->getValueType()); |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 407 | if (I->getNumOperands()) { |
| 408 | Out << ","; |
| 409 | writeOperand(I->getOperand(0), true); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 410 | } |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 411 | } else if (isa<CastInst>(I)) { |
Chris Lattner | a682182 | 2001-07-08 04:57:15 +0000 | [diff] [blame] | 412 | writeOperand(Operand, true); |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 413 | Out << " to "; |
| 414 | printType(I->getType()); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 415 | } else if (Operand) { // Print the normal way... |
| 416 | |
| 417 | // PrintAllTypes - Instructions who have operands of all the same type |
| 418 | // omit the type from all but the first operand. If the instruction has |
| 419 | // different type operands (for example br), then they are all printed. |
| 420 | bool PrintAllTypes = false; |
| 421 | const Type *TheType = Operand->getType(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 422 | |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 423 | for (unsigned i = 1, E = I->getNumOperands(); i != E; ++i) { |
| 424 | Operand = I->getOperand(i); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 425 | if (Operand->getType() != TheType) { |
| 426 | PrintAllTypes = true; // We have differing types! Print them all! |
| 427 | break; |
| 428 | } |
| 429 | } |
| 430 | |
Chris Lattner | b6fe234 | 2001-10-20 09:33:10 +0000 | [diff] [blame] | 431 | // Shift Left & Right print both types even for Ubyte LHS |
| 432 | if (isa<ShiftInst>(I)) PrintAllTypes = true; |
| 433 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 434 | if (!PrintAllTypes) { |
| 435 | Out << " "; |
| 436 | printType(I->getOperand(0)->getType()); |
| 437 | } |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 438 | |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 439 | for (unsigned i = 0, E = I->getNumOperands(); i != E; ++i) { |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 440 | if (i) Out << ","; |
Chris Lattner | a073acb | 2001-07-07 08:36:50 +0000 | [diff] [blame] | 441 | writeOperand(I->getOperand(i), PrintAllTypes); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 442 | } |
| 443 | } |
| 444 | |
Chris Lattner | 862e338 | 2001-10-13 06:42:36 +0000 | [diff] [blame] | 445 | printInfoComment(I); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 446 | Out << endl; |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 450 | string AssemblyWriter::calcTypeName(const Type *Ty, |
| 451 | vector<const Type *> &TypeStack) { |
| 452 | if (Ty->isPrimitiveType()) return Ty->getDescription(); // Base case |
| 453 | |
| 454 | // Check to see if the type is named. |
| 455 | map<const Type *, string>::iterator I = TypeNames.find(Ty); |
| 456 | if (I != TypeNames.end()) return I->second; |
| 457 | |
| 458 | // Check to see if the Type is already on the stack... |
| 459 | unsigned Slot = 0, CurSize = TypeStack.size(); |
| 460 | while (Slot < CurSize && TypeStack[Slot] != Ty) ++Slot; // Scan for type |
| 461 | |
| 462 | // This is another base case for the recursion. In this case, we know |
| 463 | // that we have looped back to a type that we have previously visited. |
| 464 | // Generate the appropriate upreference to handle this. |
| 465 | // |
| 466 | if (Slot < CurSize) |
| 467 | return "\\" + utostr(CurSize-Slot); // Here's the upreference |
| 468 | |
| 469 | TypeStack.push_back(Ty); // Recursive case: Add us to the stack.. |
| 470 | |
| 471 | string Result; |
| 472 | switch (Ty->getPrimitiveID()) { |
| 473 | case Type::MethodTyID: { |
| 474 | const MethodType *MTy = cast<const MethodType>(Ty); |
| 475 | Result = calcTypeName(MTy->getReturnType(), TypeStack)+" ("; |
| 476 | for (MethodType::ParamTypes::const_iterator |
| 477 | I = MTy->getParamTypes().begin(), |
| 478 | E = MTy->getParamTypes().end(); I != E; ++I) { |
| 479 | if (I != MTy->getParamTypes().begin()) |
| 480 | Result += ", "; |
| 481 | Result += calcTypeName(*I, TypeStack); |
| 482 | } |
| 483 | if (MTy->isVarArg()) { |
| 484 | if (!MTy->getParamTypes().empty()) Result += ", "; |
| 485 | Result += "..."; |
| 486 | } |
| 487 | Result += ")"; |
| 488 | break; |
| 489 | } |
| 490 | case Type::StructTyID: { |
| 491 | const StructType *STy = cast<const StructType>(Ty); |
| 492 | Result = "{ "; |
| 493 | for (StructType::ElementTypes::const_iterator |
| 494 | I = STy->getElementTypes().begin(), |
| 495 | E = STy->getElementTypes().end(); I != E; ++I) { |
| 496 | if (I != STy->getElementTypes().begin()) |
| 497 | Result += ", "; |
| 498 | Result += calcTypeName(*I, TypeStack); |
| 499 | } |
| 500 | Result += " }"; |
| 501 | break; |
| 502 | } |
| 503 | case Type::PointerTyID: |
| 504 | Result = calcTypeName(cast<const PointerType>(Ty)->getValueType(), |
| 505 | TypeStack) + " *"; |
| 506 | break; |
| 507 | case Type::ArrayTyID: { |
| 508 | const ArrayType *ATy = cast<const ArrayType>(Ty); |
| 509 | int NumElements = ATy->getNumElements(); |
| 510 | Result = "["; |
| 511 | if (NumElements != -1) Result += itostr(NumElements) + " x "; |
| 512 | Result += calcTypeName(ATy->getElementType(), TypeStack) + "]"; |
| 513 | break; |
| 514 | } |
| 515 | default: |
| 516 | assert(0 && "Unhandled case in getTypeProps!"); |
| 517 | Result = "<error>"; |
| 518 | } |
| 519 | |
| 520 | TypeStack.pop_back(); // Remove self from stack... |
| 521 | return Result; |
| 522 | } |
| 523 | |
| 524 | // printType - Go to extreme measures to attempt to print out a short, symbolic |
| 525 | // version of a type name. |
| 526 | // |
| 527 | ostream &AssemblyWriter::printType(const Type *Ty) { |
| 528 | // Primitive types always print out their description, regardless of whether |
| 529 | // they have been named or not. |
| 530 | // |
| 531 | if (Ty->isPrimitiveType()) return Out << Ty->getDescription(); |
| 532 | |
| 533 | // Check to see if the type is named. |
| 534 | map<const Type *, string>::iterator I = TypeNames.find(Ty); |
| 535 | if (I != TypeNames.end()) return Out << I->second; |
| 536 | |
| 537 | // Otherwise we have a type that has not been named but is a derived type. |
| 538 | // Carefully recurse the type hierarchy to print out any contained symbolic |
| 539 | // names. |
| 540 | // |
| 541 | vector<const Type *> TypeStack; |
| 542 | string TypeName = calcTypeName(Ty, TypeStack); |
| 543 | TypeNames.insert(make_pair(Ty, TypeName)); // Cache type name for later use |
| 544 | return Out << TypeName; |
| 545 | } |
| 546 | |
| 547 | |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 548 | //===----------------------------------------------------------------------===// |
| 549 | // External Interface declarations |
| 550 | //===----------------------------------------------------------------------===// |
| 551 | |
| 552 | |
| 553 | |
| 554 | void WriteToAssembly(const Module *M, ostream &o) { |
| 555 | if (M == 0) { o << "<null> module\n"; return; } |
| 556 | SlotCalculator SlotTable(M, true); |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 557 | AssemblyWriter W(o, SlotTable, M); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 558 | |
| 559 | W.write(M); |
| 560 | } |
| 561 | |
Chris Lattner | adfe0d1 | 2001-09-10 20:08:19 +0000 | [diff] [blame] | 562 | void WriteToAssembly(const GlobalVariable *G, ostream &o) { |
| 563 | if (G == 0) { o << "<null> global variable\n"; return; } |
| 564 | SlotCalculator SlotTable(G->getParent(), true); |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 565 | AssemblyWriter W(o, SlotTable, G->getParent()); |
Chris Lattner | adfe0d1 | 2001-09-10 20:08:19 +0000 | [diff] [blame] | 566 | W.write(G); |
| 567 | } |
| 568 | |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 569 | void WriteToAssembly(const Method *M, ostream &o) { |
| 570 | if (M == 0) { o << "<null> method\n"; return; } |
| 571 | SlotCalculator SlotTable(M->getParent(), true); |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 572 | AssemblyWriter W(o, SlotTable, M->getParent()); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 573 | |
| 574 | W.write(M); |
| 575 | } |
| 576 | |
| 577 | |
| 578 | void WriteToAssembly(const BasicBlock *BB, ostream &o) { |
| 579 | if (BB == 0) { o << "<null> basic block\n"; return; } |
| 580 | |
| 581 | SlotCalculator SlotTable(BB->getParent(), true); |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 582 | AssemblyWriter W(o, SlotTable, |
| 583 | BB->getParent() ? BB->getParent()->getParent() : 0); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 584 | |
| 585 | W.write(BB); |
| 586 | } |
| 587 | |
| 588 | void WriteToAssembly(const ConstPoolVal *CPV, ostream &o) { |
| 589 | if (CPV == 0) { o << "<null> constant pool value\n"; return; } |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 590 | o << " " << CPV->getType()->getDescription() << " " << CPV->getStrValue(); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | void WriteToAssembly(const Instruction *I, ostream &o) { |
| 594 | if (I == 0) { o << "<null> instruction\n"; return; } |
| 595 | |
Chris Lattner | 7bfee41 | 2001-10-29 16:05:51 +0000 | [diff] [blame^] | 596 | const Method *M = I->getParent() ? I->getParent()->getParent() : 0; |
| 597 | SlotCalculator SlotTable(M, true); |
| 598 | AssemblyWriter W(o, SlotTable, M ? M->getParent() : 0); |
Chris Lattner | 2f7c963 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 599 | |
| 600 | W.write(I); |
| 601 | } |