Support cast float to float, cast double to float, and cast float to double.
authorBrian Gaeke <gaeke@uiuc.edu>
Thu, 24 Jun 2004 21:22:08 +0000 (21:22 +0000)
committerBrian Gaeke <gaeke@uiuc.edu>
Thu, 24 Jun 2004 21:22:08 +0000 (21:22 +0000)
(It's not yet clear how to copy doubles from register to register.)

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

lib/Target/Sparc/InstSelectSimple.cpp
lib/Target/Sparc/SparcV8ISelSimple.cpp
lib/Target/SparcV8/InstSelectSimple.cpp
lib/Target/SparcV8/SparcV8ISelSimple.cpp

index bbfe3cb65f54f00d05c173d7e8692df562198cdd..12045197b7cee600ed0b0272f46186c14d28611d 100644 (file)
@@ -517,16 +517,33 @@ void V8ISel::emitCastOperation(MachineBasicBlock *BB,
       }
     }
   } else {
-    if (oldTyClass < cLong && newTyClass == cFloat) {
-      // cast int to float.  Store it to a stack slot and then load
-      // it using ldf into a floating point register. then do fitos.
-      std::cerr << "Casts to float still unsupported: SrcTy = "
-                << *SrcTy << ", DestTy = " << *DestTy << "\n";
-      abort ();
-    } else if (oldTyClass < cLong && newTyClass == cDouble) {
-      std::cerr << "Casts to double still unsupported: SrcTy = "
-                << *SrcTy << ", DestTy = " << *DestTy << "\n";
-      abort ();
+    if (newTyClass == cFloat) {
+      switch (oldTyClass) {
+      case cFloat:
+        BuildMI (*BB, IP, V8::FMOVS, 1, DestReg).addReg (SrcReg);
+        break;
+      case cDouble:
+        BuildMI (*BB, IP, V8::FDTOS, 1, DestReg).addReg (SrcReg);
+        break;
+      default:
+        // cast int to float.  Store it to a stack slot and then load
+        // it using ldf into a floating point register. then do fitos.
+        std::cerr << "Casts to float still unsupported: SrcTy = "
+                  << *SrcTy << ", DestTy = " << *DestTy << "\n";
+        abort ();
+        break;
+      }
+    } else if (newTyClass == cDouble) {
+      switch (oldTyClass) {
+      case cFloat:
+        BuildMI (*BB, IP, V8::FSTOD, 1, DestReg).addReg (SrcReg);
+        break;
+      default:
+        std::cerr << "Casts to double still unsupported: SrcTy = "
+                  << *SrcTy << ", DestTy = " << *DestTy << "\n";
+        abort ();
+        break;
+      }
     } else {
       std::cerr << "Cast still unsupported: SrcTy = "
                 << *SrcTy << ", DestTy = " << *DestTy << "\n";
index bbfe3cb65f54f00d05c173d7e8692df562198cdd..12045197b7cee600ed0b0272f46186c14d28611d 100644 (file)
@@ -517,16 +517,33 @@ void V8ISel::emitCastOperation(MachineBasicBlock *BB,
       }
     }
   } else {
-    if (oldTyClass < cLong && newTyClass == cFloat) {
-      // cast int to float.  Store it to a stack slot and then load
-      // it using ldf into a floating point register. then do fitos.
-      std::cerr << "Casts to float still unsupported: SrcTy = "
-                << *SrcTy << ", DestTy = " << *DestTy << "\n";
-      abort ();
-    } else if (oldTyClass < cLong && newTyClass == cDouble) {
-      std::cerr << "Casts to double still unsupported: SrcTy = "
-                << *SrcTy << ", DestTy = " << *DestTy << "\n";
-      abort ();
+    if (newTyClass == cFloat) {
+      switch (oldTyClass) {
+      case cFloat:
+        BuildMI (*BB, IP, V8::FMOVS, 1, DestReg).addReg (SrcReg);
+        break;
+      case cDouble:
+        BuildMI (*BB, IP, V8::FDTOS, 1, DestReg).addReg (SrcReg);
+        break;
+      default:
+        // cast int to float.  Store it to a stack slot and then load
+        // it using ldf into a floating point register. then do fitos.
+        std::cerr << "Casts to float still unsupported: SrcTy = "
+                  << *SrcTy << ", DestTy = " << *DestTy << "\n";
+        abort ();
+        break;
+      }
+    } else if (newTyClass == cDouble) {
+      switch (oldTyClass) {
+      case cFloat:
+        BuildMI (*BB, IP, V8::FSTOD, 1, DestReg).addReg (SrcReg);
+        break;
+      default:
+        std::cerr << "Casts to double still unsupported: SrcTy = "
+                  << *SrcTy << ", DestTy = " << *DestTy << "\n";
+        abort ();
+        break;
+      }
     } else {
       std::cerr << "Cast still unsupported: SrcTy = "
                 << *SrcTy << ", DestTy = " << *DestTy << "\n";
index bbfe3cb65f54f00d05c173d7e8692df562198cdd..12045197b7cee600ed0b0272f46186c14d28611d 100644 (file)
@@ -517,16 +517,33 @@ void V8ISel::emitCastOperation(MachineBasicBlock *BB,
       }
     }
   } else {
-    if (oldTyClass < cLong && newTyClass == cFloat) {
-      // cast int to float.  Store it to a stack slot and then load
-      // it using ldf into a floating point register. then do fitos.
-      std::cerr << "Casts to float still unsupported: SrcTy = "
-                << *SrcTy << ", DestTy = " << *DestTy << "\n";
-      abort ();
-    } else if (oldTyClass < cLong && newTyClass == cDouble) {
-      std::cerr << "Casts to double still unsupported: SrcTy = "
-                << *SrcTy << ", DestTy = " << *DestTy << "\n";
-      abort ();
+    if (newTyClass == cFloat) {
+      switch (oldTyClass) {
+      case cFloat:
+        BuildMI (*BB, IP, V8::FMOVS, 1, DestReg).addReg (SrcReg);
+        break;
+      case cDouble:
+        BuildMI (*BB, IP, V8::FDTOS, 1, DestReg).addReg (SrcReg);
+        break;
+      default:
+        // cast int to float.  Store it to a stack slot and then load
+        // it using ldf into a floating point register. then do fitos.
+        std::cerr << "Casts to float still unsupported: SrcTy = "
+                  << *SrcTy << ", DestTy = " << *DestTy << "\n";
+        abort ();
+        break;
+      }
+    } else if (newTyClass == cDouble) {
+      switch (oldTyClass) {
+      case cFloat:
+        BuildMI (*BB, IP, V8::FSTOD, 1, DestReg).addReg (SrcReg);
+        break;
+      default:
+        std::cerr << "Casts to double still unsupported: SrcTy = "
+                  << *SrcTy << ", DestTy = " << *DestTy << "\n";
+        abort ();
+        break;
+      }
     } else {
       std::cerr << "Cast still unsupported: SrcTy = "
                 << *SrcTy << ", DestTy = " << *DestTy << "\n";
index bbfe3cb65f54f00d05c173d7e8692df562198cdd..12045197b7cee600ed0b0272f46186c14d28611d 100644 (file)
@@ -517,16 +517,33 @@ void V8ISel::emitCastOperation(MachineBasicBlock *BB,
       }
     }
   } else {
-    if (oldTyClass < cLong && newTyClass == cFloat) {
-      // cast int to float.  Store it to a stack slot and then load
-      // it using ldf into a floating point register. then do fitos.
-      std::cerr << "Casts to float still unsupported: SrcTy = "
-                << *SrcTy << ", DestTy = " << *DestTy << "\n";
-      abort ();
-    } else if (oldTyClass < cLong && newTyClass == cDouble) {
-      std::cerr << "Casts to double still unsupported: SrcTy = "
-                << *SrcTy << ", DestTy = " << *DestTy << "\n";
-      abort ();
+    if (newTyClass == cFloat) {
+      switch (oldTyClass) {
+      case cFloat:
+        BuildMI (*BB, IP, V8::FMOVS, 1, DestReg).addReg (SrcReg);
+        break;
+      case cDouble:
+        BuildMI (*BB, IP, V8::FDTOS, 1, DestReg).addReg (SrcReg);
+        break;
+      default:
+        // cast int to float.  Store it to a stack slot and then load
+        // it using ldf into a floating point register. then do fitos.
+        std::cerr << "Casts to float still unsupported: SrcTy = "
+                  << *SrcTy << ", DestTy = " << *DestTy << "\n";
+        abort ();
+        break;
+      }
+    } else if (newTyClass == cDouble) {
+      switch (oldTyClass) {
+      case cFloat:
+        BuildMI (*BB, IP, V8::FSTOD, 1, DestReg).addReg (SrcReg);
+        break;
+      default:
+        std::cerr << "Casts to double still unsupported: SrcTy = "
+                  << *SrcTy << ", DestTy = " << *DestTy << "\n";
+        abort ();
+        break;
+      }
     } else {
       std::cerr << "Cast still unsupported: SrcTy = "
                 << *SrcTy << ", DestTy = " << *DestTy << "\n";