Make sure to put an _ prefix on all identifiers!
authorChris Lattner <sabre@nondot.org>
Tue, 17 Aug 2004 02:29:00 +0000 (02:29 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Aug 2004 02:29:00 +0000 (02:29 +0000)
Also, add some (currently disabled) code to print float's as 32-bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15846 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PowerPC/PPC32AsmPrinter.cpp
lib/Target/PowerPC/PPCAsmPrinter.cpp

index 151580c8d26894c23e4c79167f45a0e7f92622de..42030ff141008d8a978d880bfd4d506facc8ce9b 100644 (file)
@@ -46,7 +46,9 @@ namespace {
     std::set<std::string> Strings;
 
     PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM)
-      : AsmPrinter(O, TM), LabelNumber(0) {}
+      : AsmPrinter(O, TM), LabelNumber(0) {
+      UsesUnderscorePrefix = 1;
+    }
 
     /// Unique incrementer for label values for referencing Global values.
     ///
@@ -193,21 +195,32 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
     // FP Constants are printed as integer constants to avoid losing
     // precision...
     double Val = CFP->getValue();
-    union DU {                            // Abide by C TBAA rules
-      double FVal;
-      uint64_t UVal;
-      struct {
-        uint32_t MSWord;
-        uint32_t LSWord;
-      } T;
-    } U;
-    U.FVal = Val;
-    
-    O << ".long\t" << U.T.MSWord << "\t; double most significant word " 
-      << Val << "\n";
-    O << ".long\t" << U.T.LSWord << "\t; double least significant word " 
-      << Val << "\n";
-    return;
+    if (1 || CFP->getType() == Type::DoubleTy) {
+      union DU {                            // Abide by C TBAA rules
+        double FVal;
+        uint64_t UVal;
+        struct {
+          uint32_t MSWord;
+          uint32_t LSWord;
+        } T;
+      } U;
+      U.FVal = Val;
+      
+      O << ".long\t" << U.T.MSWord << "\t; double most significant word " 
+        << Val << "\n";
+      O << ".long\t" << U.T.LSWord << "\t; double least significant word " 
+        << Val << "\n";
+      return;
+    } else {
+      union FU {                            // Abide by C TBAA rules
+        float FVal;
+        int32_t UVal;
+      } U;
+      U.FVal = Val;
+      
+      O << ".long\t" << U.UVal << "\t; float " << Val << "\n";
+      return;
+    }
   } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
     if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
       union DU {                            // Abide by C TBAA rules
index 151580c8d26894c23e4c79167f45a0e7f92622de..42030ff141008d8a978d880bfd4d506facc8ce9b 100644 (file)
@@ -46,7 +46,9 @@ namespace {
     std::set<std::string> Strings;
 
     PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM)
-      : AsmPrinter(O, TM), LabelNumber(0) {}
+      : AsmPrinter(O, TM), LabelNumber(0) {
+      UsesUnderscorePrefix = 1;
+    }
 
     /// Unique incrementer for label values for referencing Global values.
     ///
@@ -193,21 +195,32 @@ void PowerPCAsmPrinter::emitGlobalConstant(const Constant *CV) {
     // FP Constants are printed as integer constants to avoid losing
     // precision...
     double Val = CFP->getValue();
-    union DU {                            // Abide by C TBAA rules
-      double FVal;
-      uint64_t UVal;
-      struct {
-        uint32_t MSWord;
-        uint32_t LSWord;
-      } T;
-    } U;
-    U.FVal = Val;
-    
-    O << ".long\t" << U.T.MSWord << "\t; double most significant word " 
-      << Val << "\n";
-    O << ".long\t" << U.T.LSWord << "\t; double least significant word " 
-      << Val << "\n";
-    return;
+    if (1 || CFP->getType() == Type::DoubleTy) {
+      union DU {                            // Abide by C TBAA rules
+        double FVal;
+        uint64_t UVal;
+        struct {
+          uint32_t MSWord;
+          uint32_t LSWord;
+        } T;
+      } U;
+      U.FVal = Val;
+      
+      O << ".long\t" << U.T.MSWord << "\t; double most significant word " 
+        << Val << "\n";
+      O << ".long\t" << U.T.LSWord << "\t; double least significant word " 
+        << Val << "\n";
+      return;
+    } else {
+      union FU {                            // Abide by C TBAA rules
+        float FVal;
+        int32_t UVal;
+      } U;
+      U.FVal = Val;
+      
+      O << ".long\t" << U.UVal << "\t; float " << Val << "\n";
+      return;
+    }
   } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) {
     if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
       union DU {                            // Abide by C TBAA rules