X86: Implement microops and instructions that manipulate the flags register.
authorGabe Black <gblack@eecs.umich.edu>
Sun, 5 Aug 2007 03:24:18 +0000 (20:24 -0700)
committerGabe Black <gblack@eecs.umich.edu>
Sun, 5 Aug 2007 03:24:18 +0000 (20:24 -0700)
--HG--
extra : convert_revision : 566841577bf4a98cac0b65292fe0f7daf89a9203

src/arch/x86/isa/decoder/one_byte_opcodes.isa
src/arch/x86/isa/insts/flags/set_and_clear.py
src/arch/x86/isa/insts/semaphores.py
src/arch/x86/isa/microops/regop.isa
src/arch/x86/isa/specialize.isa
src/arch/x86/miscregs.hh

index 7c627b0c2ac8302fb9d6093eecfa1b3b6d03fd78..cce07d6fe22c67a5626abc5778f0f4c076f96dff 100644 (file)
             }
         }
         0x1F: decode OPCODE_OP_BOTTOM3 {
-            0x0: clc();
-            0x1: stc();
-            0x2: cli();
-            0x3: sti();
-            0x4: cld();
-            0x5: std();
             format Inst {
+                0x0: CLC();
+                0x1: STC();
+                0x2: WarnUnimpl::cli();
+                0x3: WarnUnimpl::sti();
+                0x4: CLD();
+                0x5: STD();
                 //0x6: group4();
                 0x6: decode MODRM_REG {
                     0x0: INC(Eb);
index d70b953823ce591d79a6b9d7645a220250740073..4c655e0b2b107165894ba8b9e496ff36b2082ece 100644 (file)
 #
 # Authors: Gabe Black
 
-microcode = ""
+microcode = '''
+def macroop CLD {
+    ruflags t1
+    limm t2, "~((uint64_t)DFBit)"
+    and t1, t1, t2
+    wruflags t1, t0
+};
+
+def macroop STD {
+    ruflags t1
+    limm t2, "DFBit"
+    or t1, t1, t2
+    wruflags t1, t0
+};
+
+def macroop CLC {
+    ruflags t1
+    andi t2, t1, "CFBit"
+    wruflags t1, t2
+};
+
+def macroop STC {
+    ruflags t1
+    ori t1, t1, "CFBit"
+    wruflags t1, t0
+};
+
+def macroop CMC {
+    ruflags t1
+    wruflagsi t1, "CFBit"
+};
+'''
 #let {{
-#    class CLC(Inst):
-#      "GenFault ${new UnimpInstFault}"
-#    class CMC(Inst):
-#      "GenFault ${new UnimpInstFault}"
-#    class STC(Inst):
-#      "GenFault ${new UnimpInstFault}"
-#    class CLD(Inst):
-#      "GenFault ${new UnimpInstFault}"
-#    class STD(Inst):
-#      "GenFault ${new UnimpInstFault}"
 #    class CLI(Inst):
 #      "GenFault ${new UnimpInstFault}"
 #    class STI(Inst):
index 882213a3fb886ec520d5130b5a73d68cda7e2da9..800f1b325365a39d32392ef12ad0fd63eeb551fa 100644 (file)
@@ -80,12 +80,6 @@ def macroop CMPXCHG_P_R {
 };
 '''
 #let {{
-#    class CMPXCHG(Inst):
-#      "GenFault ${new UnimpInstFault}"
-#    class CMPXCHG8B(Inst):
-#      "GenFault ${new UnimpInstFault}"
-#    class CMPXCHG16B(Inst):
-#      "GenFault ${new UnimpInstFault}"
 #    class XADD(Inst):
 #      "GenFault ${new UnimpInstFault}"
 #    class XCHG(Inst):
index 3c562efc067314683341fc5c92a274a28d246b56..ac88be6577230c15f026122b2218d78e5d71e5d6 100644 (file)
@@ -615,8 +615,12 @@ let {{
             ''')
 
     defineMicroRegOpWr('Wrip', 'RIP = psrc1 + op2', elseCode="RIP = RIP;")
+    defineMicroRegOpWr('Wruflags', 'ccFlagBits = psrc1 ^ op2')
 
     defineMicroRegOpRd('Rdip', 'DestReg = RIP')
+    defineMicroRegOpRd('Ruflags', 'DestReg = ccFlagBits')
+    defineMicroRegOpImm('Ruflag', 'DestReg = bits(ccFlagBits, imm8);', \
+            flagCode = genCCFlagBitsLogic)
 
     defineMicroRegOpImm('Sext', '''
             IntReg val = psrc1;
index 690061de7200b6a0beff42dfbd98e7c058e94d78..59e9577d99411efc3b2546ca1f4d1600ab3e1ac7 100644 (file)
@@ -176,6 +176,10 @@ let {{
                 # Non register modrm settings should cause an error
                 env.addReg(ModRMRMIndex)
                 Name += "_R"
+            elif opType.tag in ("X", "Y"):
+                # This type of memory addressing is for string instructions.
+                # They'll use the right index and segment internally.
+                Name += "_M"
             else:
                 raise Exception, "Unrecognized tag %s." % opType.tag
 
index b2294292e3446401e4f31cf9f18b8cd5614cf46d..8792bf6dd3d897656f0047ae6d3a014a73ccec8b 100644 (file)
@@ -70,6 +70,7 @@ namespace X86ISA
         EZFBit = 1 << 5,
         ZFBit = 1 << 6,
         SFBit = 1 << 7,
+        DFBit = 1 << 10,
         OFBit = 1 << 11
     };