X86: Implement a media floating point subtract microop.
authorGabe Black <gblack@eecs.umich.edu>
Tue, 18 Aug 2009 01:36:18 +0000 (18:36 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Tue, 18 Aug 2009 01:36:18 +0000 (18:36 -0700)
src/arch/x86/isa/microops/mediaop.isa

index 334944222fffe615e7d7b33652c058752d3a73e2..b9cfc00750992dea64429ba01ba264b11618dd96 100644 (file)
@@ -620,4 +620,50 @@ let {{
             }
             FpDestReg.uqw = result;
         '''
+
+    class Msubf(MediaOp):
+        code = '''
+            union floatInt
+            {
+                float f;
+                uint32_t i;
+            };
+            union doubleInt
+            {
+                double d;
+                uint64_t i;
+            };
+
+            assert(srcSize == destSize);
+            int size = srcSize;
+            int sizeBits = size * 8;
+            assert(srcSize == 4 || srcSize == 8);
+            int items = (ext & 0x1) ? 1: (sizeof(FloatRegBits) / size);
+            uint64_t result = FpDestReg.uqw;
+
+            for (int i = 0; i < items; i++) {
+                int hiIndex = (i + 1) * sizeBits - 1;
+                int loIndex = (i + 0) * sizeBits;
+                uint64_t arg1Bits = bits(FpSrcReg1.uqw, hiIndex, loIndex);
+                uint64_t arg2Bits = bits(FpSrcReg2.uqw, hiIndex, loIndex);
+                uint64_t resBits;
+
+                if (size == 4) {
+                    floatInt arg1, arg2, res;
+                    arg1.i = arg1Bits;
+                    arg2.i = arg2Bits;
+                    res.f = arg1.f - arg2.f;
+                    resBits = res.i;
+                } else {
+                    doubleInt arg1, arg2, res;
+                    arg1.i = arg1Bits;
+                    arg2.i = arg2Bits;
+                    res.d = arg1.d - arg2.d;
+                    resBits = res.i;
+                }
+
+                result = insertBits(result, hiIndex, loIndex, resBits);
+            }
+            FpDestReg.uqw = result;
+        '''
 }};