changeset 9459593cb649 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=9459593cb649
description:
        x86: implement fild, fucomi, and fucomip x87 insts

        fild loads an integer value into the x87 top of stack register.
        fucomi/fucomip compare two x87 register values (the latter
        also doing a stack pop).
        These instructions are used by some versions of GNU libstdc++.

diffstat:

 src/arch/x86/isa/decoder/x87.isa                                               
              |  17 ++++++--
 
src/arch/x86/isa/insts/x87/compare_and_test/floating_point_unordered_compare.py 
             |  16 +++++++-
 
src/arch/x86/isa/insts/x87/data_transfer_and_conversion/convert_and_load_or_store_integer.py
 |  17 ++++++++-
 src/arch/x86/isa/microops/fpop.isa                                             
              |   2 +
 src/arch/x86/isa/microops/ldstop.isa                                           
              |  19 ++++++++++
 5 files changed, 63 insertions(+), 8 deletions(-)

diffs (169 lines):

diff -r a84eecaaa866 -r 9459593cb649 src/arch/x86/isa/decoder/x87.isa
--- a/src/arch/x86/isa/decoder/x87.isa  Tue Oct 06 18:08:28 2015 -0500
+++ b/src/arch/x86/isa/decoder/x87.isa  Tue Oct 06 17:26:50 2015 -0700
@@ -1,5 +1,7 @@
 // Copyright (c) 2007 The Hewlett-Packard Development Company
 // Copyright (c) 2012-13 Mark D. Hill and David A. Wood
+// Copyright (c) 2015 Advanced Micro Devices, Inc.
+//
 // All rights reserved.
 //
 // The license below extends only to copyright in the software and shall
@@ -36,6 +38,7 @@
 //
 // Authors: Gabe Black
 //          Nilay Vaish
+//          Steve Reinhardt
 
 format WarnUnimpl {
     0x1B: decode OPCODE_OP_BOTTOM3 {
@@ -174,7 +177,7 @@
         0x3: decode MODRM_REG {
             0x0: decode MODRM_MOD {
                 0x3: fcmovnb();
-                default: fild();
+                default: Inst::FILD(Md); // 32-bit int
             }
             0x1: decode MODRM_MOD {
                 0x3: fcmovne();
@@ -197,7 +200,9 @@
                 default: Inst::UD2();
             }
             0x5: decode MODRM_MOD {
-                0x3: fucomi();
+                // 'R' insists on having a size qualifier, so I picked 'q',
+                // but I don't think it has any effect
+                0x3: Inst::FUCOMI(Rq);
                 // 80-bit load
                 default: Inst::FLD80(M);
             }
@@ -331,7 +336,7 @@
                 // The ffreep instruction isn't entirely real. It should work
                 // the same as ffree but then also pop the register stack.
                 0x3: ffreep();
-                default: fild();
+                default: Inst::FILD(Mw); // 16-bit int
             }
             0x1: decode MODRM_MOD {
                 0x3: Inst::UD2();
@@ -353,8 +358,10 @@
                 default: fbld();
             }
             0x5: decode MODRM_MOD {
-                0x3: fucomip();
-                default: fild();
+                // 'R' insists on having a size qualifier, so I picked 'q',
+                // but I don't think it has any effect
+                0x3: Inst::FUCOMIP(Rq);
+                default: Inst::FILD(Mq); // 64-bit int
             }
             0x6: decode MODRM_MOD {
                 0x3: fcomip();
diff -r a84eecaaa866 -r 9459593cb649 
src/arch/x86/isa/insts/x87/compare_and_test/floating_point_unordered_compare.py
--- 
a/src/arch/x86/isa/insts/x87/compare_and_test/floating_point_unordered_compare.py
   Tue Oct 06 18:08:28 2015 -0500
+++ 
b/src/arch/x86/isa/insts/x87/compare_and_test/floating_point_unordered_compare.py
   Tue Oct 06 17:26:50 2015 -0700
@@ -1,4 +1,6 @@
 # Copyright (c) 2007 The Hewlett-Packard Development Company
+# Copyright (c) 2015 Advanced Micro Devices, Inc.
+#
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -34,11 +36,21 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Authors: Gabe Black
+#          Steve Reinhardt
 
 microcode = '''
 # FUCOM
 # FUCOMP
 # FUCOMPP
-# FUCOMI
-# FUCOMIP
+
+# fucomi
+def macroop FUCOMI_R {
+    compfp st(0), sti
+};
+
+# fucomi with stack pop (caused by spm=1)
+def macroop FUCOMIP_R {
+    compfp st(0), sti, spm=1
+};
+
 '''
diff -r a84eecaaa866 -r 9459593cb649 
src/arch/x86/isa/insts/x87/data_transfer_and_conversion/convert_and_load_or_store_integer.py
--- 
a/src/arch/x86/isa/insts/x87/data_transfer_and_conversion/convert_and_load_or_store_integer.py
      Tue Oct 06 18:08:28 2015 -0500
+++ 
b/src/arch/x86/isa/insts/x87/data_transfer_and_conversion/convert_and_load_or_store_integer.py
      Tue Oct 06 17:26:50 2015 -0700
@@ -1,4 +1,6 @@
 # Copyright (c) 2007 The Hewlett-Packard Development Company
+# Copyright (c) 2015 Advanced Micro Devices, Inc.
+#
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -34,9 +36,22 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 # Authors: Gabe Black
+#          Steve Reinhardt
 
 microcode = '''
-# FILD
+# fild common case
+def macroop FILD_M {
+    ldifp87 ufp1, seg, sib, disp
+    movfp st(-1), ufp1, spm=-1
+};
+
+# fild with RIP-relative addressing
+def macroop FILD_P {
+    rdip t7
+    ldifp87 ufp1, seg, riprel, disp
+    movfp st(-1), ufp1, spm=-1
+};
+
 # FIST
 # FISTP
 # FISTTP
diff -r a84eecaaa866 -r 9459593cb649 src/arch/x86/isa/microops/fpop.isa
--- a/src/arch/x86/isa/microops/fpop.isa        Tue Oct 06 18:08:28 2015 -0500
+++ b/src/arch/x86/isa/microops/fpop.isa        Tue Oct 06 17:26:50 2015 -0700
@@ -1,5 +1,7 @@
 // Copyright (c) 2007 The Hewlett-Packard Development Company
 // Copyright (c) 2012-2013 Mark D. Hill and David A. Wood
+// Copyright (c) 2015 Advanced Micro Devices, Inc.
+//
 // All rights reserved.
 //
 // The license below extends only to copyright in the software and shall
diff -r a84eecaaa866 -r 9459593cb649 src/arch/x86/isa/microops/ldstop.isa
--- a/src/arch/x86/isa/microops/ldstop.isa      Tue Oct 06 18:08:28 2015 -0500
+++ b/src/arch/x86/isa/microops/ldstop.isa      Tue Oct 06 17:26:50 2015 -0700
@@ -427,6 +427,25 @@
         }
     ''', big = False)
 
+    # Load integer from memory into x87 top-of-stack register.
+    # Used to implement fild instruction.
+    defineMicroLoadOp('Ldifp87', code='''
+        switch (dataSize)
+        {
+          case 2:
+            FpData_df = (int64_t)sext<16>(Mem);
+            break;
+          case 4:
+            FpData_df = (int64_t)sext<32>(Mem);
+            break;
+          case 8:
+            FpData_df = (int64_t)Mem;
+            break;
+          default:
+            panic("Unhandled data size in LdIFp87.\\n");
+        }
+    ''', big = False)
+
     def defineMicroStoreOp(mnemonic, code, completeCode="", mem_flags="0"):
         global header_output
         global decoder_output
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to