Typo.
[oota-llvm.git] / lib / CodeGen / AsmPrinter.cpp
index 3d8dd75a161d76659ff3d06c6ce8e969387fccd6..47a53457fc9823f5470a6f05a66cb472ceb72852 100644 (file)
@@ -160,6 +160,12 @@ bool AsmPrinter::doFinalization(Module &M) {
   return false;
 }
 
+std::string AsmPrinter::getCurrentFunctionEHName(const MachineFunction *MF) {
+  assert(MF && "No machine function?");
+  return Mang->makeNameProper(MF->getFunction()->getName() + ".eh",
+                              TAI->getGlobalPrefix());
+}
+
 void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
   // What's my mangled name?
   CurrentFnName = Mang->getValueName(MF.getFunction());
@@ -612,6 +618,17 @@ void AsmPrinter::EmitString(const std::string &String) const {
 }
 
 
+/// EmitFile - Emit a .file directive.
+void AsmPrinter::EmitFile(unsigned Number, const std::string &Name) const {
+  O << "\t.file\t" << Number << " \"";
+  for (unsigned i = 0, N = Name.size(); i < N; ++i) {
+    unsigned char C = Name[i];
+    printStringChar(O, C);
+  }
+  O << "\"";
+}
+
+
 //===----------------------------------------------------------------------===//
 
 // EmitAlignment - Emit an alignment directive to the specified power of
@@ -799,8 +816,12 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
     if (CVA->isString()) {
       EmitString(CVA);
     } else { // Not a string.  Print the values in successive locations
-      for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i)
+      for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i) {
         EmitGlobalConstant(CVA->getOperand(i));
+        const Type* EltTy = CVA->getType()->getElementType();
+        uint64_t padSize = TD->getABITypeSize(EltTy) - TD->getTypeSize(EltTy);
+        EmitZeros(padSize);
+      }
     }
     return;
   } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) {
@@ -859,7 +880,9 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
       return;
     } else if (CFP->getType() == Type::X86_FP80Ty) {
       // all long double variants are printed as hex
-      const uint64_t *p = CFP->getValueAPF().convertToAPInt().getRawData();
+      // api needed to prevent premature destruction
+      APInt api = CFP->getValueAPF().convertToAPInt();
+      const uint64_t *p = api.getRawData();
       if (TD->isBigEndian()) {
         O << TAI->getData16bitsDirective() << uint16_t(p[0] >> 48)
           << "\t" << TAI->getCommentString()
@@ -894,6 +917,39 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
           << " long double most significant halfword\n";
       }
       return;
+    } else if (CFP->getType() == Type::PPC_FP128Ty) {
+      // all long double variants are printed as hex
+      // api needed to prevent premature destruction
+      APInt api = CFP->getValueAPF().convertToAPInt();
+      const uint64_t *p = api.getRawData();
+      if (TD->isBigEndian()) {
+        O << TAI->getData32bitsDirective() << uint32_t(p[0] >> 32)
+          << "\t" << TAI->getCommentString()
+          << " long double most significant word\n";
+        O << TAI->getData32bitsDirective() << uint32_t(p[0])
+          << "\t" << TAI->getCommentString()
+          << " long double next word\n";
+        O << TAI->getData32bitsDirective() << uint32_t(p[1] >> 32)
+          << "\t" << TAI->getCommentString()
+          << " long double next word\n";
+        O << TAI->getData32bitsDirective() << uint32_t(p[1])
+          << "\t" << TAI->getCommentString()
+          << " long double least significant word\n";
+       } else {
+        O << TAI->getData32bitsDirective() << uint32_t(p[1])
+          << "\t" << TAI->getCommentString()
+          << " long double least significant word\n";
+        O << TAI->getData32bitsDirective() << uint32_t(p[1] >> 32)
+          << "\t" << TAI->getCommentString()
+          << " long double next word\n";
+        O << TAI->getData32bitsDirective() << uint32_t(p[0])
+          << "\t" << TAI->getCommentString()
+          << " long double next word\n";
+        O << TAI->getData32bitsDirective() << uint32_t(p[0] >> 32)
+          << "\t" << TAI->getCommentString()
+          << " long double most significant word\n";
+      }
+      return;
     } else assert(0 && "Floating point constant type not handled");
   } else if (CV->getType() == Type::Int64Ty) {
     if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
@@ -1186,7 +1242,7 @@ bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
 void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB,
                                       bool printColon,
                                       bool printComment) const {
-  O << TAI->getPrivateGlobalPrefix() << "BB" << FunctionNumber << "_"
+  O << TAI->getPrivateGlobalPrefix() << "BB" << getFunctionNumber() << "_"
     << MBB->getNumber();
   if (printColon)
     O << ':';
@@ -1252,6 +1308,7 @@ void AsmPrinter::printDataDirective(const Type *type) {
     }
     break;
   case Type::FloatTyID: case Type::DoubleTyID:
+  case Type::X86_FP80TyID: case Type::FP128TyID: case Type::PPC_FP128TyID:
     assert (0 && "Should have already output floating point constant.");
   default:
     assert (0 && "Can't handle printing this type of thing");