Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 1 | //===-- AsmPrinter.cpp - Common AsmPrinter code ---------------------------===// |
| 2 | // |
| 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. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the AsmPrinter class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/CodeGen/AsmPrinter.h" |
| 15 | #include "llvm/Constants.h" |
Chris Lattner | c0a1eba | 2005-11-10 18:36:17 +0000 | [diff] [blame] | 16 | #include "llvm/Module.h" |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Mangler.h" |
Jim Laskey | b74c666 | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 18 | #include "llvm/Support/MathExtras.h" |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetMachine.h" |
| 20 | using namespace llvm; |
| 21 | |
| 22 | bool AsmPrinter::doInitialization(Module &M) { |
Chris Lattner | 6d42cbd | 2004-08-17 06:06:19 +0000 | [diff] [blame] | 23 | Mang = new Mangler(M, GlobalPrefix); |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 24 | return false; |
| 25 | } |
| 26 | |
| 27 | bool AsmPrinter::doFinalization(Module &M) { |
| 28 | delete Mang; Mang = 0; |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | void AsmPrinter::setupMachineFunction(MachineFunction &MF) { |
| 33 | // What's my mangled name? |
Chris Lattner | c0a1eba | 2005-11-10 18:36:17 +0000 | [diff] [blame] | 34 | CurrentFnName = Mang->getValueName(MF.getFunction()); |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Chris Lattner | 1d35c16 | 2004-08-17 19:14:29 +0000 | [diff] [blame] | 37 | // emitAlignment - Emit an alignment directive to the specified power of two. |
Chris Lattner | dd8eeed | 2005-11-14 19:00:06 +0000 | [diff] [blame^] | 38 | void AsmPrinter::emitAlignment(unsigned NumBits, const GlobalValue *GV) const { |
| 39 | if (GV && GV->getAlignment()) |
| 40 | NumBits = Log2_32(GV->getAlignment()); |
Chris Lattner | 747960d | 2005-11-10 18:09:27 +0000 | [diff] [blame] | 41 | if (NumBits == 0) return; // No need to emit alignment. |
Chris Lattner | 1d35c16 | 2004-08-17 19:14:29 +0000 | [diff] [blame] | 42 | if (AlignmentIsInBytes) NumBits = 1 << NumBits; |
| 43 | O << AlignDirective << NumBits << "\n"; |
| 44 | } |
| 45 | |
Chris Lattner | ea75199 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 46 | /// emitZeros - Emit a block of zeros. |
| 47 | /// |
Chris Lattner | 0b955fd | 2005-01-08 19:59:10 +0000 | [diff] [blame] | 48 | void AsmPrinter::emitZeros(uint64_t NumZeros) const { |
Chris Lattner | ea75199 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 49 | if (NumZeros) { |
| 50 | if (ZeroDirective) |
| 51 | O << ZeroDirective << NumZeros << "\n"; |
| 52 | else { |
Chris Lattner | ea75199 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 53 | for (; NumZeros; --NumZeros) |
| 54 | O << Data8bitsDirective << "0\n"; |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 59 | // Print out the specified constant, without a storage class. Only the |
| 60 | // constants valid in constant expressions can occur here. |
| 61 | void AsmPrinter::emitConstantValueOnly(const Constant *CV) { |
Chris Lattner | 61753bf | 2004-10-16 18:19:26 +0000 | [diff] [blame] | 62 | if (CV->isNullValue() || isa<UndefValue>(CV)) |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 63 | O << "0"; |
| 64 | else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) { |
| 65 | assert(CB == ConstantBool::True); |
| 66 | O << "1"; |
| 67 | } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) |
| 68 | if (((CI->getValue() << 32) >> 32) == CI->getValue()) |
| 69 | O << CI->getValue(); |
| 70 | else |
Duraid Madina | 73c4dba | 2005-05-15 13:05:48 +0000 | [diff] [blame] | 71 | O << (uint64_t)CI->getValue(); |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 72 | else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) |
| 73 | O << CI->getValue(); |
Chris Lattner | c0a1eba | 2005-11-10 18:36:17 +0000 | [diff] [blame] | 74 | else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) { |
Duraid Madina | 73a316d | 2005-04-02 12:21:51 +0000 | [diff] [blame] | 75 | // This is a constant address for a global variable or function. Use the |
| 76 | // name of the variable or function as the address value, possibly |
| 77 | // decorating it with GlobalVarAddrPrefix/Suffix or |
| 78 | // FunctionAddrPrefix/Suffix (these all default to "" ) |
Chris Lattner | c0a1eba | 2005-11-10 18:36:17 +0000 | [diff] [blame] | 79 | if (isa<Function>(GV)) |
| 80 | O << FunctionAddrPrefix << Mang->getValueName(GV) << FunctionAddrSuffix; |
Duraid Madina | 73a316d | 2005-04-02 12:21:51 +0000 | [diff] [blame] | 81 | else |
Chris Lattner | c0a1eba | 2005-11-10 18:36:17 +0000 | [diff] [blame] | 82 | O << GlobalVarAddrPrefix << Mang->getValueName(GV) << GlobalVarAddrSuffix; |
Duraid Madina | 73a316d | 2005-04-02 12:21:51 +0000 | [diff] [blame] | 83 | } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) { |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 84 | const TargetData &TD = TM.getTargetData(); |
| 85 | switch(CE->getOpcode()) { |
| 86 | case Instruction::GetElementPtr: { |
| 87 | // generate a symbolic expression for the byte address |
| 88 | const Constant *ptrVal = CE->getOperand(0); |
| 89 | std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end()); |
Chris Lattner | 145569b | 2005-02-14 21:40:26 +0000 | [diff] [blame] | 90 | if (int64_t Offset = TD.getIndexedOffset(ptrVal->getType(), idxVec)) { |
| 91 | if (Offset) |
| 92 | O << "("; |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 93 | emitConstantValueOnly(ptrVal); |
Chris Lattner | 145569b | 2005-02-14 21:40:26 +0000 | [diff] [blame] | 94 | if (Offset > 0) |
| 95 | O << ") + " << Offset; |
| 96 | else if (Offset < 0) |
| 97 | O << ") - " << -Offset; |
Chris Lattner | 6a8e0f5 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 98 | } else { |
| 99 | emitConstantValueOnly(ptrVal); |
| 100 | } |
| 101 | break; |
| 102 | } |
| 103 | case Instruction::Cast: { |
| 104 | // Support only non-converting or widening casts for now, that is, ones |
| 105 | // that do not involve a change in value. This assertion is really gross, |
| 106 | // and may not even be a complete check. |
| 107 | Constant *Op = CE->getOperand(0); |
| 108 | const Type *OpTy = Op->getType(), *Ty = CE->getType(); |
| 109 | |
| 110 | // Remember, kids, pointers can be losslessly converted back and forth |
| 111 | // into 32-bit or wider integers, regardless of signedness. :-P |
| 112 | assert(((isa<PointerType>(OpTy) |
| 113 | && (Ty == Type::LongTy || Ty == Type::ULongTy |
| 114 | || Ty == Type::IntTy || Ty == Type::UIntTy)) |
| 115 | || (isa<PointerType>(Ty) |
| 116 | && (OpTy == Type::LongTy || OpTy == Type::ULongTy |
| 117 | || OpTy == Type::IntTy || OpTy == Type::UIntTy)) |
| 118 | || (((TD.getTypeSize(Ty) >= TD.getTypeSize(OpTy)) |
| 119 | && OpTy->isLosslesslyConvertibleTo(Ty)))) |
| 120 | && "FIXME: Don't yet support this kind of constant cast expr"); |
| 121 | O << "("; |
| 122 | emitConstantValueOnly(Op); |
| 123 | O << ")"; |
| 124 | break; |
| 125 | } |
| 126 | case Instruction::Add: |
| 127 | O << "("; |
| 128 | emitConstantValueOnly(CE->getOperand(0)); |
| 129 | O << ") + ("; |
| 130 | emitConstantValueOnly(CE->getOperand(1)); |
| 131 | O << ")"; |
| 132 | break; |
| 133 | default: |
| 134 | assert(0 && "Unsupported operator!"); |
| 135 | } |
| 136 | } else { |
| 137 | assert(0 && "Unknown constant value!"); |
| 138 | } |
| 139 | } |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 140 | |
| 141 | /// toOctal - Convert the low order bits of X into an octal digit. |
| 142 | /// |
| 143 | static inline char toOctal(int X) { |
| 144 | return (X&7)+'0'; |
| 145 | } |
| 146 | |
Chris Lattner | 55a6d90 | 2005-11-10 18:06:33 +0000 | [diff] [blame] | 147 | /// printAsCString - Print the specified array as a C compatible string, only if |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 148 | /// the predicate isString is true. |
| 149 | /// |
Chris Lattner | 55a6d90 | 2005-11-10 18:06:33 +0000 | [diff] [blame] | 150 | static void printAsCString(std::ostream &O, const ConstantArray *CVA, |
| 151 | unsigned LastElt) { |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 152 | assert(CVA->isString() && "Array is not string compatible!"); |
| 153 | |
| 154 | O << "\""; |
Chris Lattner | 55a6d90 | 2005-11-10 18:06:33 +0000 | [diff] [blame] | 155 | for (unsigned i = 0; i != LastElt; ++i) { |
Misha Brukman | 835702a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 156 | unsigned char C = |
Chris Lattner | 0b955fd | 2005-01-08 19:59:10 +0000 | [diff] [blame] | 157 | (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getRawValue(); |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 158 | |
| 159 | if (C == '"') { |
| 160 | O << "\\\""; |
| 161 | } else if (C == '\\') { |
| 162 | O << "\\\\"; |
| 163 | } else if (isprint(C)) { |
| 164 | O << C; |
| 165 | } else { |
| 166 | switch(C) { |
| 167 | case '\b': O << "\\b"; break; |
| 168 | case '\f': O << "\\f"; break; |
| 169 | case '\n': O << "\\n"; break; |
| 170 | case '\r': O << "\\r"; break; |
| 171 | case '\t': O << "\\t"; break; |
| 172 | default: |
| 173 | O << '\\'; |
| 174 | O << toOctal(C >> 6); |
| 175 | O << toOctal(C >> 3); |
| 176 | O << toOctal(C >> 0); |
| 177 | break; |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | O << "\""; |
| 182 | } |
| 183 | |
| 184 | /// emitGlobalConstant - Print a general LLVM constant to the .s file. |
| 185 | /// |
Misha Brukman | 835702a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 186 | void AsmPrinter::emitGlobalConstant(const Constant *CV) { |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 187 | const TargetData &TD = TM.getTargetData(); |
| 188 | |
Chris Lattner | 61753bf | 2004-10-16 18:19:26 +0000 | [diff] [blame] | 189 | if (CV->isNullValue() || isa<UndefValue>(CV)) { |
Chris Lattner | ea75199 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 190 | emitZeros(TD.getTypeSize(CV->getType())); |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 191 | return; |
| 192 | } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) { |
| 193 | if (CVA->isString()) { |
Chris Lattner | 55a6d90 | 2005-11-10 18:06:33 +0000 | [diff] [blame] | 194 | unsigned NumElts = CVA->getNumOperands(); |
| 195 | if (AscizDirective && NumElts && |
| 196 | cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) { |
| 197 | O << AscizDirective; |
| 198 | printAsCString(O, CVA, NumElts-1); |
| 199 | } else { |
| 200 | O << AsciiDirective; |
| 201 | printAsCString(O, CVA, NumElts); |
| 202 | } |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 203 | O << "\n"; |
| 204 | } else { // Not a string. Print the values in successive locations |
| 205 | for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i) |
| 206 | emitGlobalConstant(CVA->getOperand(i)); |
| 207 | } |
| 208 | return; |
| 209 | } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) { |
| 210 | // Print the fields in successive locations. Pad to align if needed! |
| 211 | const StructLayout *cvsLayout = TD.getStructLayout(CVS->getType()); |
Chris Lattner | 0b955fd | 2005-01-08 19:59:10 +0000 | [diff] [blame] | 212 | uint64_t sizeSoFar = 0; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 213 | for (unsigned i = 0, e = CVS->getNumOperands(); i != e; ++i) { |
| 214 | const Constant* field = CVS->getOperand(i); |
| 215 | |
| 216 | // Check if padding is needed and insert one or more 0s. |
Chris Lattner | 0b955fd | 2005-01-08 19:59:10 +0000 | [diff] [blame] | 217 | uint64_t fieldSize = TD.getTypeSize(field->getType()); |
| 218 | uint64_t padSize = ((i == e-1? cvsLayout->StructSize |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 219 | : cvsLayout->MemberOffsets[i+1]) |
| 220 | - cvsLayout->MemberOffsets[i]) - fieldSize; |
| 221 | sizeSoFar += fieldSize + padSize; |
| 222 | |
| 223 | // Now print the actual field value |
| 224 | emitGlobalConstant(field); |
| 225 | |
| 226 | // Insert the field padding unless it's zero bytes... |
Chris Lattner | ea75199 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 227 | emitZeros(padSize); |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 228 | } |
| 229 | assert(sizeSoFar == cvsLayout->StructSize && |
| 230 | "Layout of constant struct may be incorrect!"); |
| 231 | return; |
| 232 | } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) { |
| 233 | // FP Constants are printed as integer constants to avoid losing |
| 234 | // precision... |
| 235 | double Val = CFP->getValue(); |
| 236 | if (CFP->getType() == Type::DoubleTy) { |
Chris Lattner | 9fa0fc4 | 2004-08-17 06:48:16 +0000 | [diff] [blame] | 237 | if (Data64bitsDirective) |
Jim Laskey | b74c666 | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 238 | O << Data64bitsDirective << DoubleToBits(Val) << "\t" << CommentString |
Chris Lattner | ea75199 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 239 | << " double value: " << Val << "\n"; |
Chris Lattner | 9fa0fc4 | 2004-08-17 06:48:16 +0000 | [diff] [blame] | 240 | else if (TD.isBigEndian()) { |
Jim Laskey | b74c666 | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 241 | O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32) |
Chris Lattner | 10262ab | 2004-08-18 02:22:55 +0000 | [diff] [blame] | 242 | << "\t" << CommentString << " double most significant word " |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 243 | << Val << "\n"; |
Jim Laskey | b74c666 | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 244 | O << Data32bitsDirective << unsigned(DoubleToBits(Val)) |
Chris Lattner | 10262ab | 2004-08-18 02:22:55 +0000 | [diff] [blame] | 245 | << "\t" << CommentString << " double least significant word " |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 246 | << Val << "\n"; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 247 | } else { |
Jim Laskey | b74c666 | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 248 | O << Data32bitsDirective << unsigned(DoubleToBits(Val)) |
Chris Lattner | 10262ab | 2004-08-18 02:22:55 +0000 | [diff] [blame] | 249 | << "\t" << CommentString << " double least significant word " << Val |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 250 | << "\n"; |
Jim Laskey | b74c666 | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 251 | O << Data32bitsDirective << unsigned(DoubleToBits(Val) >> 32) |
Chris Lattner | 10262ab | 2004-08-18 02:22:55 +0000 | [diff] [blame] | 252 | << "\t" << CommentString << " double most significant word " << Val |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 253 | << "\n"; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 254 | } |
| 255 | return; |
| 256 | } else { |
Jim Laskey | b74c666 | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 257 | O << Data32bitsDirective << FloatToBits(Val) << "\t" << CommentString |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 258 | << " float " << Val << "\n"; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 259 | return; |
| 260 | } |
| 261 | } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) { |
| 262 | if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { |
| 263 | uint64_t Val = CI->getRawValue(); |
Misha Brukman | 835702a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 264 | |
Chris Lattner | 9fa0fc4 | 2004-08-17 06:48:16 +0000 | [diff] [blame] | 265 | if (Data64bitsDirective) |
| 266 | O << Data64bitsDirective << Val << "\n"; |
| 267 | else if (TD.isBigEndian()) { |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 268 | O << Data32bitsDirective << unsigned(Val >> 32) |
Chris Lattner | 10262ab | 2004-08-18 02:22:55 +0000 | [diff] [blame] | 269 | << "\t" << CommentString << " Double-word most significant word " |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 270 | << Val << "\n"; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 271 | O << Data32bitsDirective << unsigned(Val) |
Chris Lattner | 10262ab | 2004-08-18 02:22:55 +0000 | [diff] [blame] | 272 | << "\t" << CommentString << " Double-word least significant word " |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 273 | << Val << "\n"; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 274 | } else { |
| 275 | O << Data32bitsDirective << unsigned(Val) |
Chris Lattner | 10262ab | 2004-08-18 02:22:55 +0000 | [diff] [blame] | 276 | << "\t" << CommentString << " Double-word least significant word " |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 277 | << Val << "\n"; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 278 | O << Data32bitsDirective << unsigned(Val >> 32) |
Chris Lattner | 10262ab | 2004-08-18 02:22:55 +0000 | [diff] [blame] | 279 | << "\t" << CommentString << " Double-word most significant word " |
Chris Lattner | da6beac | 2004-08-17 16:27:05 +0000 | [diff] [blame] | 280 | << Val << "\n"; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 281 | } |
| 282 | return; |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | const Type *type = CV->getType(); |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 287 | switch (type->getTypeID()) { |
Misha Brukman | 835702a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 288 | case Type::BoolTyID: |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 289 | case Type::UByteTyID: case Type::SByteTyID: |
| 290 | O << Data8bitsDirective; |
| 291 | break; |
| 292 | case Type::UShortTyID: case Type::ShortTyID: |
| 293 | O << Data16bitsDirective; |
| 294 | break; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 295 | case Type::PointerTyID: |
Andrew Lenharth | c8770aa | 2005-02-04 13:47:16 +0000 | [diff] [blame] | 296 | if (TD.getPointerSize() == 8) { |
| 297 | O << Data64bitsDirective; |
| 298 | break; |
| 299 | } |
| 300 | //Fall through for pointer size == int size |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 301 | case Type::UIntTyID: case Type::IntTyID: |
| 302 | O << Data32bitsDirective; |
| 303 | break; |
Misha Brukman | 835702a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 304 | case Type::ULongTyID: case Type::LongTyID: |
Chris Lattner | 88e2d2e | 2005-08-08 04:26:32 +0000 | [diff] [blame] | 305 | assert(Data64bitsDirective &&"Target cannot handle 64-bit constant exprs!"); |
| 306 | O << Data64bitsDirective; |
| 307 | break; |
Chris Lattner | 8452a1f | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 308 | case Type::FloatTyID: case Type::DoubleTyID: |
| 309 | assert (0 && "Should have already output floating point constant."); |
| 310 | default: |
| 311 | assert (0 && "Can't handle printing this type of thing"); |
| 312 | break; |
| 313 | } |
| 314 | emitConstantValueOnly(CV); |
| 315 | O << "\n"; |
| 316 | } |