Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 1 | //===-- SparcV8AsmPrinter.cpp - SparcV8 LLVM assembly writer --------------===// |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 2 | // |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 7 | // |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains a printer that converts from our internal representation |
| 11 | // of machine-dependent LLVM code to GAS-format Sparc V8 assembly language. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "SparcV8.h" |
| 16 | #include "SparcV8InstrInfo.h" |
| 17 | #include "llvm/Constants.h" |
| 18 | #include "llvm/DerivedTypes.h" |
| 19 | #include "llvm/Module.h" |
| 20 | #include "llvm/Assembly/Writer.h" |
| 21 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 22 | #include "llvm/CodeGen/MachineConstantPool.h" |
| 23 | #include "llvm/CodeGen/MachineInstr.h" |
| 24 | #include "llvm/Target/TargetMachine.h" |
| 25 | #include "llvm/Support/Mangler.h" |
Brian Gaeke | 74dfcf1 | 2004-09-02 02:37:43 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/Statistic.h" |
| 27 | #include "llvm/ADT/StringExtras.h" |
| 28 | #include "llvm/Support/CommandLine.h" |
Jim Laskey | b8df7c2 | 2005-08-17 20:04:34 +0000 | [diff] [blame] | 29 | #include "llvm/Support/MathExtras.h" |
Brian Gaeke | a8b00ca | 2004-03-06 05:30:21 +0000 | [diff] [blame] | 30 | #include <cctype> |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 31 | using namespace llvm; |
| 32 | |
| 33 | namespace { |
| 34 | Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); |
| 35 | |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 36 | struct SparcV8AsmPrinter : public MachineFunctionPass { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 37 | /// Output stream on which we're printing assembly code. |
| 38 | /// |
| 39 | std::ostream &O; |
| 40 | |
| 41 | /// Target machine description which we query for reg. names, data |
| 42 | /// layout, etc. |
| 43 | /// |
| 44 | TargetMachine &TM; |
| 45 | |
| 46 | /// Name-mangler for global names. |
| 47 | /// |
| 48 | Mangler *Mang; |
| 49 | |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 50 | SparcV8AsmPrinter(std::ostream &o, TargetMachine &tm) : O(o), TM(tm) { } |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 51 | |
| 52 | /// We name each basic block in a Function with a unique number, so |
| 53 | /// that we can consistently refer to them later. This is cleared |
| 54 | /// at the beginning of each call to runOnMachineFunction(). |
| 55 | /// |
| 56 | typedef std::map<const Value *, unsigned> ValueMapTy; |
| 57 | ValueMapTy NumberForBB; |
| 58 | |
| 59 | /// Cache of mangled name for current function. This is |
| 60 | /// recalculated at the beginning of each call to |
| 61 | /// runOnMachineFunction(). |
| 62 | /// |
| 63 | std::string CurrentFnName; |
| 64 | |
| 65 | virtual const char *getPassName() const { |
| 66 | return "SparcV8 Assembly Printer"; |
| 67 | } |
| 68 | |
| 69 | void emitConstantValueOnly(const Constant *CV); |
| 70 | void emitGlobalConstant(const Constant *CV); |
| 71 | void printConstantPool(MachineConstantPool *MCP); |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 72 | void printOperand(const MachineInstr *MI, int opNum); |
Brian Gaeke | ceb2241 | 2004-06-18 06:27:59 +0000 | [diff] [blame] | 73 | void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 74 | void printMachineInstruction(const MachineInstr *MI); |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 75 | bool printInstruction(const MachineInstr *MI); // autogenerated. |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 76 | bool runOnMachineFunction(MachineFunction &F); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 77 | bool doInitialization(Module &M); |
| 78 | bool doFinalization(Module &M); |
| 79 | }; |
| 80 | } // end of anonymous namespace |
| 81 | |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 82 | #include "SparcV8GenAsmWriter.inc" |
| 83 | |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 84 | /// createSparcV8CodePrinterPass - Returns a pass that prints the SparcV8 |
| 85 | /// assembly code for a MachineFunction to the given output stream, |
| 86 | /// using the given target machine description. This should work |
| 87 | /// regardless of whether the function is in SSA form. |
| 88 | /// |
| 89 | FunctionPass *llvm::createSparcV8CodePrinterPass (std::ostream &o, |
| 90 | TargetMachine &tm) { |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 91 | return new SparcV8AsmPrinter(o, tm); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | /// toOctal - Convert the low order bits of X into an octal digit. |
| 95 | /// |
| 96 | static inline char toOctal(int X) { |
| 97 | return (X&7)+'0'; |
| 98 | } |
| 99 | |
| 100 | /// getAsCString - Return the specified array as a C compatible |
| 101 | /// string, only if the predicate isStringCompatible is true. |
| 102 | /// |
| 103 | static void printAsCString(std::ostream &O, const ConstantArray *CVA) { |
| 104 | assert(CVA->isString() && "Array is not string compatible!"); |
| 105 | |
| 106 | O << "\""; |
| 107 | for (unsigned i = 0; i != CVA->getNumOperands(); ++i) { |
| 108 | unsigned char C = cast<ConstantInt>(CVA->getOperand(i))->getRawValue(); |
| 109 | |
| 110 | if (C == '"') { |
| 111 | O << "\\\""; |
| 112 | } else if (C == '\\') { |
| 113 | O << "\\\\"; |
| 114 | } else if (isprint(C)) { |
| 115 | O << C; |
| 116 | } else { |
| 117 | switch(C) { |
| 118 | case '\b': O << "\\b"; break; |
| 119 | case '\f': O << "\\f"; break; |
| 120 | case '\n': O << "\\n"; break; |
| 121 | case '\r': O << "\\r"; break; |
| 122 | case '\t': O << "\\t"; break; |
| 123 | default: |
| 124 | O << '\\'; |
| 125 | O << toOctal(C >> 6); |
| 126 | O << toOctal(C >> 3); |
| 127 | O << toOctal(C >> 0); |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | } |
| 132 | O << "\""; |
| 133 | } |
| 134 | |
| 135 | // Print out the specified constant, without a storage class. Only the |
| 136 | // constants valid in constant expressions can occur here. |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 137 | void SparcV8AsmPrinter::emitConstantValueOnly(const Constant *CV) { |
Brian Gaeke | 54799c2 | 2004-11-14 03:22:05 +0000 | [diff] [blame] | 138 | if (CV->isNullValue() || isa<UndefValue> (CV)) |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 139 | O << "0"; |
| 140 | else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) { |
| 141 | assert(CB == ConstantBool::True); |
| 142 | O << "1"; |
| 143 | } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) |
| 144 | if (((CI->getValue() << 32) >> 32) == CI->getValue()) |
| 145 | O << CI->getValue(); |
| 146 | else |
| 147 | O << (unsigned long long)CI->getValue(); |
| 148 | else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) |
| 149 | O << CI->getValue(); |
Chris Lattner | 7330248 | 2004-07-18 07:26:17 +0000 | [diff] [blame] | 150 | else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 151 | // This is a constant address for a global variable or function. Use the |
| 152 | // name of the variable or function as the address value. |
Chris Lattner | 7330248 | 2004-07-18 07:26:17 +0000 | [diff] [blame] | 153 | O << Mang->getValueName(GV); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 154 | else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) { |
| 155 | const TargetData &TD = TM.getTargetData(); |
| 156 | switch(CE->getOpcode()) { |
| 157 | case Instruction::GetElementPtr: { |
| 158 | // generate a symbolic expression for the byte address |
| 159 | const Constant *ptrVal = CE->getOperand(0); |
| 160 | std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end()); |
| 161 | if (unsigned Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) { |
| 162 | O << "("; |
| 163 | emitConstantValueOnly(ptrVal); |
| 164 | O << ") + " << Offset; |
| 165 | } else { |
| 166 | emitConstantValueOnly(ptrVal); |
| 167 | } |
| 168 | break; |
| 169 | } |
| 170 | case Instruction::Cast: { |
| 171 | // Support only non-converting or widening casts for now, that is, ones |
| 172 | // that do not involve a change in value. This assertion is really gross, |
| 173 | // and may not even be a complete check. |
| 174 | Constant *Op = CE->getOperand(0); |
| 175 | const Type *OpTy = Op->getType(), *Ty = CE->getType(); |
| 176 | |
| 177 | // Pointers on ILP32 machines can be losslessly converted back and |
| 178 | // forth into 32-bit or wider integers, regardless of signedness. |
| 179 | assert(((isa<PointerType>(OpTy) |
| 180 | && (Ty == Type::LongTy || Ty == Type::ULongTy |
| 181 | || Ty == Type::IntTy || Ty == Type::UIntTy)) |
| 182 | || (isa<PointerType>(Ty) |
| 183 | && (OpTy == Type::LongTy || OpTy == Type::ULongTy |
| 184 | || OpTy == Type::IntTy || OpTy == Type::UIntTy)) |
| 185 | || (((TD.getTypeSize(Ty) >= TD.getTypeSize(OpTy)) |
| 186 | && OpTy->isLosslesslyConvertibleTo(Ty)))) |
| 187 | && "FIXME: Don't yet support this kind of constant cast expr"); |
| 188 | O << "("; |
| 189 | emitConstantValueOnly(Op); |
| 190 | O << ")"; |
| 191 | break; |
| 192 | } |
| 193 | case Instruction::Add: |
| 194 | O << "("; |
| 195 | emitConstantValueOnly(CE->getOperand(0)); |
| 196 | O << ") + ("; |
| 197 | emitConstantValueOnly(CE->getOperand(1)); |
| 198 | O << ")"; |
| 199 | break; |
| 200 | default: |
| 201 | assert(0 && "Unsupported operator!"); |
| 202 | } |
| 203 | } else { |
| 204 | assert(0 && "Unknown constant value!"); |
| 205 | } |
| 206 | } |
| 207 | |
| 208 | // Print a constant value or values, with the appropriate storage class as a |
| 209 | // prefix. |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 210 | void SparcV8AsmPrinter::emitGlobalConstant(const Constant *CV) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 211 | const TargetData &TD = TM.getTargetData(); |
| 212 | |
Brian Gaeke | 9d2427c | 2004-06-18 08:59:16 +0000 | [diff] [blame] | 213 | if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 214 | if (CVA->isString()) { |
| 215 | O << "\t.ascii\t"; |
| 216 | printAsCString(O, CVA); |
| 217 | O << "\n"; |
| 218 | } else { // Not a string. Print the values in successive locations |
Chris Lattner | cdf7012 | 2004-08-04 17:27:27 +0000 | [diff] [blame] | 219 | for (unsigned i = 0, e = CVA->getNumOperands(); i != e; i++) |
| 220 | emitGlobalConstant(CVA->getOperand(i)); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 221 | } |
| 222 | return; |
| 223 | } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) { |
| 224 | // Print the fields in successive locations. Pad to align if needed! |
| 225 | const StructLayout *cvsLayout = TD.getStructLayout(CVS->getType()); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 226 | unsigned sizeSoFar = 0; |
Chris Lattner | cdf7012 | 2004-08-04 17:27:27 +0000 | [diff] [blame] | 227 | for (unsigned i = 0, e = CVS->getNumOperands(); i != e; i++) { |
| 228 | const Constant* field = CVS->getOperand(i); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 229 | |
| 230 | // Check if padding is needed and insert one or more 0s. |
| 231 | unsigned fieldSize = TD.getTypeSize(field->getType()); |
Chris Lattner | cdf7012 | 2004-08-04 17:27:27 +0000 | [diff] [blame] | 232 | unsigned padSize = ((i == e-1? cvsLayout->StructSize |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 233 | : cvsLayout->MemberOffsets[i+1]) |
| 234 | - cvsLayout->MemberOffsets[i]) - fieldSize; |
| 235 | sizeSoFar += fieldSize + padSize; |
| 236 | |
| 237 | // Now print the actual field value |
| 238 | emitGlobalConstant(field); |
| 239 | |
| 240 | // Insert the field padding unless it's zero bytes... |
| 241 | if (padSize) |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 242 | O << "\t.skip\t " << padSize << "\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 243 | } |
| 244 | assert(sizeSoFar == cvsLayout->StructSize && |
| 245 | "Layout of constant struct may be incorrect!"); |
| 246 | return; |
| 247 | } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) { |
| 248 | // FP Constants are printed as integer constants to avoid losing |
| 249 | // precision... |
| 250 | double Val = CFP->getValue(); |
Chris Lattner | f70c22b | 2004-06-17 18:19:28 +0000 | [diff] [blame] | 251 | switch (CFP->getType()->getTypeID()) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 252 | default: assert(0 && "Unknown floating point type!"); |
| 253 | case Type::FloatTyID: { |
Jim Laskey | cb6682f | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 254 | O << ".long\t" << FloatToBits(Val) << "\t! float " << Val << "\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 255 | return; |
| 256 | } |
| 257 | case Type::DoubleTyID: { |
Jim Laskey | cb6682f | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 258 | O << ".word\t0x" << std::hex << (DoubleToBits(Val) >> 32) << std::dec << "\t! double " << Val << "\n"; |
| 259 | O << ".word\t0x" << std::hex << (DoubleToBits(Val) & 0xffffffffUL) << std::dec << "\t! double " << Val << "\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 260 | return; |
| 261 | } |
| 262 | } |
Brian Gaeke | 54799c2 | 2004-11-14 03:22:05 +0000 | [diff] [blame] | 263 | } else if (isa<UndefValue> (CV)) { |
| 264 | unsigned size = TD.getTypeSize (CV->getType ()); |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 265 | O << "\t.skip\t " << size << "\n"; |
Brian Gaeke | 54799c2 | 2004-11-14 03:22:05 +0000 | [diff] [blame] | 266 | return; |
Brian Gaeke | 4dd043f | 2004-11-23 21:10:49 +0000 | [diff] [blame] | 267 | } else if (isa<ConstantAggregateZero> (CV)) { |
| 268 | unsigned size = TD.getTypeSize (CV->getType ()); |
| 269 | for (unsigned i = 0; i < size; ++i) |
Misha Brukman | 27177f8 | 2005-04-22 18:06:01 +0000 | [diff] [blame] | 270 | O << "\t.byte 0\n"; |
Brian Gaeke | 4dd043f | 2004-11-23 21:10:49 +0000 | [diff] [blame] | 271 | return; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | const Type *type = CV->getType(); |
| 275 | O << "\t"; |
Chris Lattner | f70c22b | 2004-06-17 18:19:28 +0000 | [diff] [blame] | 276 | switch (type->getTypeID()) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 277 | case Type::BoolTyID: case Type::UByteTyID: case Type::SByteTyID: |
| 278 | O << ".byte"; |
| 279 | break; |
| 280 | case Type::UShortTyID: case Type::ShortTyID: |
Brian Gaeke | 3bf960c | 2004-12-09 18:51:01 +0000 | [diff] [blame] | 281 | O << ".half"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 282 | break; |
| 283 | case Type::FloatTyID: case Type::PointerTyID: |
| 284 | case Type::UIntTyID: case Type::IntTyID: |
Brian Gaeke | 3bf960c | 2004-12-09 18:51:01 +0000 | [diff] [blame] | 285 | O << ".word"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 286 | break; |
| 287 | case Type::DoubleTyID: |
| 288 | case Type::ULongTyID: case Type::LongTyID: |
Brian Gaeke | 3bf960c | 2004-12-09 18:51:01 +0000 | [diff] [blame] | 289 | O << ".xword"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 290 | break; |
| 291 | default: |
| 292 | assert (0 && "Can't handle printing this type of thing"); |
| 293 | break; |
| 294 | } |
| 295 | O << "\t"; |
| 296 | emitConstantValueOnly(CV); |
| 297 | O << "\n"; |
| 298 | } |
| 299 | |
| 300 | /// printConstantPool - Print to the current output stream assembly |
| 301 | /// representations of the constants in the constant pool MCP. This is |
| 302 | /// used to print out constants which have been "spilled to memory" by |
| 303 | /// the code generator. |
| 304 | /// |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 305 | void SparcV8AsmPrinter::printConstantPool(MachineConstantPool *MCP) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 306 | const std::vector<Constant*> &CP = MCP->getConstants(); |
| 307 | const TargetData &TD = TM.getTargetData(); |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 308 | |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 309 | if (CP.empty()) return; |
| 310 | |
| 311 | for (unsigned i = 0, e = CP.size(); i != e; ++i) { |
Brian Gaeke | b27df44 | 2004-09-29 03:25:40 +0000 | [diff] [blame] | 312 | O << "\t.section \".rodata\"\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 313 | O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType()) |
| 314 | << "\n"; |
Brian Gaeke | 79db740 | 2004-03-16 22:37:12 +0000 | [diff] [blame] | 315 | O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t!" |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 316 | << *CP[i] << "\n"; |
| 317 | emitGlobalConstant(CP[i]); |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | /// runOnMachineFunction - This uses the printMachineInstruction() |
| 322 | /// method to print assembly for each instruction. |
| 323 | /// |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 324 | bool SparcV8AsmPrinter::runOnMachineFunction(MachineFunction &MF) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 325 | // BBNumber is used here so that a given Printer will never give two |
| 326 | // BBs the same name. (If you have a better way, please let me know!) |
| 327 | static unsigned BBNumber = 0; |
| 328 | |
| 329 | O << "\n\n"; |
| 330 | // What's my mangled name? |
| 331 | CurrentFnName = Mang->getValueName(MF.getFunction()); |
| 332 | |
| 333 | // Print out constants referenced by the function |
| 334 | printConstantPool(MF.getConstantPool()); |
| 335 | |
| 336 | // Print out labels for the function. |
| 337 | O << "\t.text\n"; |
| 338 | O << "\t.align 16\n"; |
| 339 | O << "\t.globl\t" << CurrentFnName << "\n"; |
Brian Gaeke | 54cc3c2 | 2004-03-16 22:52:04 +0000 | [diff] [blame] | 340 | O << "\t.type\t" << CurrentFnName << ", #function\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 341 | O << CurrentFnName << ":\n"; |
| 342 | |
| 343 | // Number each basic block so that we can consistently refer to them |
| 344 | // in PC-relative references. |
| 345 | NumberForBB.clear(); |
| 346 | for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); |
| 347 | I != E; ++I) { |
| 348 | NumberForBB[I->getBasicBlock()] = BBNumber++; |
| 349 | } |
| 350 | |
| 351 | // Print out code for the function. |
| 352 | for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); |
| 353 | I != E; ++I) { |
| 354 | // Print a label for the basic block. |
Brian Gaeke | 09c1309 | 2004-06-17 19:39:23 +0000 | [diff] [blame] | 355 | O << ".LBB" << Mang->getValueName(MF.getFunction ()) |
| 356 | << "_" << I->getNumber () << ":\t! " |
| 357 | << I->getBasicBlock ()->getName () << "\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 358 | for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); |
Misha Brukman | 27177f8 | 2005-04-22 18:06:01 +0000 | [diff] [blame] | 359 | II != E; ++II) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 360 | // Print the assembly for the instruction. |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 361 | printMachineInstruction(II); |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | // We didn't modify anything. |
| 366 | return false; |
| 367 | } |
| 368 | |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 369 | void SparcV8AsmPrinter::printOperand(const MachineInstr *MI, int opNum) { |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 370 | const MachineOperand &MO = MI->getOperand (opNum); |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 371 | const MRegisterInfo &RI = *TM.getRegisterInfo(); |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 372 | bool CloseParen = false; |
| 373 | if (MI->getOpcode() == V8::SETHIi && !MO.isRegister() && !MO.isImmediate()) { |
| 374 | O << "%hi("; |
| 375 | CloseParen = true; |
Misha Brukman | f54ef97 | 2004-06-24 23:38:20 +0000 | [diff] [blame] | 376 | } else if (MI->getOpcode() ==V8::ORri &&!MO.isRegister() &&!MO.isImmediate()) |
| 377 | { |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 378 | O << "%lo("; |
| 379 | CloseParen = true; |
| 380 | } |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 381 | switch (MO.getType()) { |
| 382 | case MachineOperand::MO_VirtualRegister: |
| 383 | if (Value *V = MO.getVRegValueOrNull()) { |
| 384 | O << "<" << V->getName() << ">"; |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 385 | break; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 386 | } |
| 387 | // FALLTHROUGH |
| 388 | case MachineOperand::MO_MachineRegister: |
| 389 | if (MRegisterInfo::isPhysicalRegister(MO.getReg())) |
Brian Gaeke | a8b00ca | 2004-03-06 05:30:21 +0000 | [diff] [blame] | 390 | O << "%" << LowercaseString (RI.get(MO.getReg()).Name); |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 391 | else |
| 392 | O << "%reg" << MO.getReg(); |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 393 | break; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 394 | |
| 395 | case MachineOperand::MO_SignExtendedImmed: |
| 396 | case MachineOperand::MO_UnextendedImmed: |
| 397 | O << (int)MO.getImmedValue(); |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 398 | break; |
Brian Gaeke | 09c1309 | 2004-06-17 19:39:23 +0000 | [diff] [blame] | 399 | case MachineOperand::MO_MachineBasicBlock: { |
| 400 | MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); |
| 401 | O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) |
| 402 | << "_" << MBBOp->getNumber () << "\t! " |
| 403 | << MBBOp->getBasicBlock ()->getName (); |
| 404 | return; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 405 | } |
Brian Gaeke | 09c1309 | 2004-06-17 19:39:23 +0000 | [diff] [blame] | 406 | case MachineOperand::MO_PCRelativeDisp: |
| 407 | std::cerr << "Shouldn't use addPCDisp() when building SparcV8 MachineInstrs"; |
| 408 | abort (); |
| 409 | return; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 410 | case MachineOperand::MO_GlobalAddress: |
| 411 | O << Mang->getValueName(MO.getGlobal()); |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 412 | break; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 413 | case MachineOperand::MO_ExternalSymbol: |
| 414 | O << MO.getSymbolName(); |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 415 | break; |
Brian Gaeke | 8a0ae9e | 2004-06-27 22:50:44 +0000 | [diff] [blame] | 416 | case MachineOperand::MO_ConstantPoolIndex: |
| 417 | O << ".CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex(); |
| 418 | break; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 419 | default: |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 420 | O << "<unknown operand type>"; abort (); break; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 421 | } |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 422 | if (CloseParen) O << ")"; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 425 | static bool isLoadInstruction (const MachineInstr *MI) { |
| 426 | switch (MI->getOpcode ()) { |
Brian Gaeke | af0492e | 2004-06-24 07:37:12 +0000 | [diff] [blame] | 427 | case V8::LDSB: |
| 428 | case V8::LDSH: |
| 429 | case V8::LDUB: |
| 430 | case V8::LDUH: |
| 431 | case V8::LD: |
| 432 | case V8::LDD: |
| 433 | case V8::LDFrr: |
| 434 | case V8::LDFri: |
| 435 | case V8::LDDFrr: |
| 436 | case V8::LDDFri: |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 437 | return true; |
| 438 | default: |
| 439 | return false; |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | static bool isStoreInstruction (const MachineInstr *MI) { |
| 444 | switch (MI->getOpcode ()) { |
Brian Gaeke | af0492e | 2004-06-24 07:37:12 +0000 | [diff] [blame] | 445 | case V8::STB: |
| 446 | case V8::STH: |
| 447 | case V8::ST: |
| 448 | case V8::STD: |
| 449 | case V8::STFrr: |
| 450 | case V8::STFri: |
| 451 | case V8::STDFrr: |
| 452 | case V8::STDFri: |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 453 | return true; |
| 454 | default: |
| 455 | return false; |
| 456 | } |
| 457 | } |
| 458 | |
Brian Gaeke | d303a20 | 2004-07-16 10:31:47 +0000 | [diff] [blame] | 459 | static bool isPseudoInstruction (const MachineInstr *MI) { |
| 460 | switch (MI->getOpcode ()) { |
| 461 | case V8::PHI: |
| 462 | case V8::ADJCALLSTACKUP: |
| 463 | case V8::ADJCALLSTACKDOWN: |
| 464 | case V8::IMPLICIT_USE: |
| 465 | case V8::IMPLICIT_DEF: |
| 466 | return true; |
| 467 | default: |
| 468 | return false; |
| 469 | } |
| 470 | } |
| 471 | |
Brian Gaeke | ceb2241 | 2004-06-18 06:27:59 +0000 | [diff] [blame] | 472 | /// printBaseOffsetPair - Print two consecutive operands of MI, starting at #i, |
| 473 | /// which form a base + offset pair (which may have brackets around it, if |
| 474 | /// brackets is true, or may be in the form base - constant, if offset is a |
| 475 | /// negative constant). |
| 476 | /// |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 477 | void SparcV8AsmPrinter::printBaseOffsetPair (const MachineInstr *MI, int i, |
Brian Gaeke | ceb2241 | 2004-06-18 06:27:59 +0000 | [diff] [blame] | 478 | bool brackets) { |
| 479 | if (brackets) O << "["; |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 480 | printOperand (MI, i); |
Brian Gaeke | ceb2241 | 2004-06-18 06:27:59 +0000 | [diff] [blame] | 481 | if (MI->getOperand (i + 1).isImmediate()) { |
| 482 | int Val = (int) MI->getOperand (i + 1).getImmedValue (); |
| 483 | if (Val != 0) { |
| 484 | O << ((Val >= 0) ? " + " : " - "); |
| 485 | O << ((Val >= 0) ? Val : -Val); |
| 486 | } |
| 487 | } else { |
| 488 | O << " + "; |
| 489 | printOperand (MI, i + 1); |
Brian Gaeke | 8005ed3 | 2004-04-07 17:33:56 +0000 | [diff] [blame] | 490 | } |
Brian Gaeke | ceb2241 | 2004-06-18 06:27:59 +0000 | [diff] [blame] | 491 | if (brackets) O << "]"; |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 492 | } |
| 493 | |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 494 | /// printMachineInstruction -- Print out a single SparcV8 LLVM instruction |
| 495 | /// MI in GAS syntax to the current output stream. |
| 496 | /// |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 497 | void SparcV8AsmPrinter::printMachineInstruction(const MachineInstr *MI) { |
| 498 | if (printInstruction(MI)) return; |
| 499 | O << "\t"; |
| 500 | |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 501 | unsigned Opcode = MI->getOpcode(); |
Chris Lattner | 143e0ea | 2004-06-02 05:47:26 +0000 | [diff] [blame] | 502 | const TargetInstrInfo &TII = *TM.getInstrInfo(); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 503 | const TargetInstrDescriptor &Desc = TII.get(Opcode); |
Brian Gaeke | d303a20 | 2004-07-16 10:31:47 +0000 | [diff] [blame] | 504 | |
| 505 | // If it's a pseudo-instruction, comment it out. |
| 506 | if (isPseudoInstruction (MI)) |
| 507 | O << "! "; |
| 508 | |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 509 | O << Desc.Name << " "; |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 510 | |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 511 | // Printing memory instructions is a special case. |
Brian Gaeke | fa4bb09 | 2004-04-07 04:29:03 +0000 | [diff] [blame] | 512 | // for loads: %dest = op %base, offset --> op [%base + offset], %dest |
Brian Gaeke | 8308d04 | 2004-06-17 22:34:19 +0000 | [diff] [blame] | 513 | // for stores: op %base, offset, %src --> op %src, [%base + offset] |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 514 | if (isLoadInstruction (MI)) { |
Brian Gaeke | fa4bb09 | 2004-04-07 04:29:03 +0000 | [diff] [blame] | 515 | printBaseOffsetPair (MI, 1); |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 516 | O << ", "; |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 517 | printOperand (MI, 0); |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 518 | O << "\n"; |
| 519 | return; |
| 520 | } else if (isStoreInstruction (MI)) { |
Brian Gaeke | 8308d04 | 2004-06-17 22:34:19 +0000 | [diff] [blame] | 521 | printOperand (MI, 2); |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 522 | O << ", "; |
Brian Gaeke | 8308d04 | 2004-06-17 22:34:19 +0000 | [diff] [blame] | 523 | printBaseOffsetPair (MI, 0); |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 524 | O << "\n"; |
| 525 | return; |
Brian Gaeke | ceb2241 | 2004-06-18 06:27:59 +0000 | [diff] [blame] | 526 | } else if (Opcode == V8::JMPLrr) { |
| 527 | printBaseOffsetPair (MI, 1, false); |
| 528 | O << ", "; |
| 529 | printOperand (MI, 0); |
| 530 | O << "\n"; |
| 531 | return; |
Brian Gaeke | 1c38175 | 2004-04-06 22:10:11 +0000 | [diff] [blame] | 532 | } |
| 533 | |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 534 | // print non-immediate, non-register-def operands |
| 535 | // then print immediate operands |
| 536 | // then print register-def operands. |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 537 | std::vector<int> print_order; |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 538 | for (unsigned i = 0; i < MI->getNumOperands (); ++i) |
| 539 | if (!(MI->getOperand (i).isImmediate () |
| 540 | || (MI->getOperand (i).isRegister () |
| 541 | && MI->getOperand (i).isDef ()))) |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 542 | print_order.push_back (i); |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 543 | for (unsigned i = 0; i < MI->getNumOperands (); ++i) |
| 544 | if (MI->getOperand (i).isImmediate ()) |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 545 | print_order.push_back (i); |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 546 | for (unsigned i = 0; i < MI->getNumOperands (); ++i) |
| 547 | if (MI->getOperand (i).isRegister () && MI->getOperand (i).isDef ()) |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 548 | print_order.push_back (i); |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 549 | for (unsigned i = 0, e = print_order.size (); i != e; ++i) { |
Brian Gaeke | 446ae11 | 2004-06-15 19:52:59 +0000 | [diff] [blame] | 550 | printOperand (MI, print_order[i]); |
Brian Gaeke | 62aa28a | 2004-03-05 08:39:09 +0000 | [diff] [blame] | 551 | if (i != (print_order.size () - 1)) |
| 552 | O << ", "; |
| 553 | } |
| 554 | O << "\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 555 | } |
| 556 | |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 557 | bool SparcV8AsmPrinter::doInitialization(Module &M) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 558 | Mang = new Mangler(M); |
| 559 | return false; // success |
| 560 | } |
| 561 | |
| 562 | // SwitchSection - Switch to the specified section of the executable if we are |
| 563 | // not already in it! |
| 564 | // |
| 565 | static void SwitchSection(std::ostream &OS, std::string &CurSection, |
| 566 | const char *NewSection) { |
| 567 | if (CurSection != NewSection) { |
| 568 | CurSection = NewSection; |
| 569 | if (!CurSection.empty()) |
Brian Gaeke | b27df44 | 2004-09-29 03:25:40 +0000 | [diff] [blame] | 570 | OS << "\t.section \"" << NewSection << "\"\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 571 | } |
| 572 | } |
| 573 | |
Chris Lattner | 994b735 | 2005-12-16 06:34:17 +0000 | [diff] [blame^] | 574 | bool SparcV8AsmPrinter::doFinalization(Module &M) { |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 575 | const TargetData &TD = TM.getTargetData(); |
| 576 | std::string CurSection; |
| 577 | |
| 578 | // Print out module-level global variables here. |
Chris Lattner | e4d5c44 | 2005-03-15 04:54:21 +0000 | [diff] [blame] | 579 | for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 580 | if (I->hasInitializer()) { // External global require no code |
| 581 | O << "\n\n"; |
| 582 | std::string name = Mang->getValueName(I); |
| 583 | Constant *C = I->getInitializer(); |
| 584 | unsigned Size = TD.getTypeSize(C->getType()); |
| 585 | unsigned Align = TD.getTypeAlignment(C->getType()); |
| 586 | |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 587 | if (C->isNullValue() && |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 588 | (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || |
| 589 | I->hasWeakLinkage() /* FIXME: Verify correct */)) { |
| 590 | SwitchSection(O, CurSection, ".data"); |
| 591 | if (I->hasInternalLinkage()) |
| 592 | O << "\t.local " << name << "\n"; |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 593 | |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 594 | O << "\t.comm " << name << "," << TD.getTypeSize(C->getType()) |
| 595 | << "," << (unsigned)TD.getTypeAlignment(C->getType()); |
Brian Gaeke | 79db740 | 2004-03-16 22:37:12 +0000 | [diff] [blame] | 596 | O << "\t\t! "; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 597 | WriteAsOperand(O, I, true, true, &M); |
| 598 | O << "\n"; |
| 599 | } else { |
| 600 | switch (I->getLinkage()) { |
| 601 | case GlobalValue::LinkOnceLinkage: |
| 602 | case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. |
| 603 | // Nonnull linkonce -> weak |
| 604 | O << "\t.weak " << name << "\n"; |
| 605 | SwitchSection(O, CurSection, ""); |
Brian Gaeke | b27df44 | 2004-09-29 03:25:40 +0000 | [diff] [blame] | 606 | O << "\t.section\t\".llvm.linkonce.d." << name << "\",\"aw\",@progbits\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 607 | break; |
Misha Brukman | b5f662f | 2005-04-21 23:30:14 +0000 | [diff] [blame] | 608 | |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 609 | case GlobalValue::AppendingLinkage: |
| 610 | // FIXME: appending linkage variables should go into a section of |
| 611 | // their name or something. For now, just emit them as external. |
| 612 | case GlobalValue::ExternalLinkage: |
| 613 | // If external or appending, declare as a global symbol |
| 614 | O << "\t.globl " << name << "\n"; |
| 615 | // FALL THROUGH |
| 616 | case GlobalValue::InternalLinkage: |
| 617 | if (C->isNullValue()) |
| 618 | SwitchSection(O, CurSection, ".bss"); |
| 619 | else |
| 620 | SwitchSection(O, CurSection, ".data"); |
| 621 | break; |
Misha Brukman | c11c44f | 2004-11-19 21:49:19 +0000 | [diff] [blame] | 622 | case GlobalValue::GhostLinkage: |
| 623 | std::cerr << "Should not have any unmaterialized functions!\n"; |
| 624 | abort(); |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 625 | } |
| 626 | |
| 627 | O << "\t.align " << Align << "\n"; |
Brian Gaeke | 54cc3c2 | 2004-03-16 22:52:04 +0000 | [diff] [blame] | 628 | O << "\t.type " << name << ",#object\n"; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 629 | O << "\t.size " << name << "," << Size << "\n"; |
Brian Gaeke | 79db740 | 2004-03-16 22:37:12 +0000 | [diff] [blame] | 630 | O << name << ":\t\t\t\t! "; |
Brian Gaeke | 4acfd03 | 2004-03-04 06:00:41 +0000 | [diff] [blame] | 631 | WriteAsOperand(O, I, true, true, &M); |
| 632 | O << " = "; |
| 633 | WriteAsOperand(O, C, false, false, &M); |
| 634 | O << "\n"; |
| 635 | emitGlobalConstant(C); |
| 636 | } |
| 637 | } |
| 638 | |
| 639 | delete Mang; |
| 640 | return false; // success |
| 641 | } |