X86: Implement a basic prefetch instruction.
authorGabe Black <gblack@eecs.umich.edu>
Wed, 25 Feb 2009 18:19:22 +0000 (10:19 -0800)
committerGabe Black <gblack@eecs.umich.edu>
Wed, 25 Feb 2009 18:19:22 +0000 (10:19 -0800)
src/arch/x86/isa/decoder/two_byte_opcodes.isa
src/arch/x86/isa/includes.isa
src/arch/x86/isa/insts/general_purpose/cache_and_memory_management.py
src/arch/x86/isa/microops/ldstop.isa

index fa49c55d3bebf684de4b9c92c5bc5cb91a00ebfb..a0a08df8f13bac08b02defbbf970872d9b78c075 100644 (file)
                 0x2: Inst::UD2();
                 0x3: Inst::UD2();
                 0x4: Inst::UD2();
-                0x5: prefetch();
+                0x5: Inst::PREFETCH(Mb);
                 0x6: FailUnimpl::femms();
                 0x7: FailUnimpl::threednow();
             }
                 //group17();
                 0x0: decode MODRM_REG {
                     0x0: prefetch_nta();
-                    0x1: prefetch_t0();
+                    0x1: Inst::PREFETCH_T0(Mb);
                     0x2: prefetch_t1();
                     0x3: prefetch_t2();
                     default: Inst::HINT_NOP();
index 10bac86ed23a702dabdd070ce3e90c84e56bb4a4..8626f117af0e12893df270acd725df4b79ff878e 100644 (file)
@@ -157,6 +157,7 @@ output exec {{
 #include "sim/sim_exit.hh"
 #include "mem/packet.hh"
 #include "mem/packet_access.hh"
+#include "mem/request.hh"
 #include "sim/pseudo_inst.hh"
 
 using namespace X86ISA;
index 08b842825734fb9dc10278fa76fa885fc122c224..dbd2d8b84912b78d56c6a730168a79dc4300ba11 100644 (file)
 #
 # Authors: Gabe Black
 
-microcode = ""
+microcode = '''
+def macroop PREFETCH_M
+{
+    ld t0, seg, sib, disp, dataSize=1, prefetch=True
+};
+
+def macroop PREFETCH_P
+{
+    rdip t7
+    ld t0, seg, riprel, disp, dataSize=1, prefetch=True
+};
+
+def macroop PREFETCH_T0_M
+{
+    ld t0, seg, sib, disp, dataSize=1, prefetch=True
+};
+
+def macroop PREFETCH_T0_P
+{
+    rdip t7
+    ld t0, seg, riprel, disp, dataSize=1, prefetch=True
+};
+
+'''
+
 #let {{
 #    class LFENCE(Inst):
 #       "GenFault ${new UnimpInstFault}"
@@ -63,8 +87,6 @@ microcode = ""
 #       "GenFault ${new UnimpInstFault}"
 #    class PREFETCHlevel(Inst):
 #       "GenFault ${new UnimpInstFault}"
-#    class PREFETCH(Inst):
-#       "GenFault ${new UnimpInstFault}"
 #    class PREFETCHW(Inst):
 #       "GenFault ${new UnimpInstFault}"
 #    class CLFLUSH(Inst):
index a1aaddfe2e28919acb6e3bfa76053da81dabd9e8..3bc2381742527aea6f21615f061d09292add51c9 100644 (file)
@@ -155,9 +155,11 @@ def template MicroLoadExecute {{
 
         fault = read(xc, EA, Mem, memFlags);
 
-        if(fault == NoFault)
-        {
+        if (fault == NoFault) {
             %(code)s;
+        } else if (memFlags & Request::PF_EXCLUSIVE) {
+            // For prefetches, ignore any faults/exceptions.
+            return NoFault;
         }
         if(fault == NoFault)
         {
@@ -361,7 +363,7 @@ def template MicroLdStOpConstructor {{
 let {{
     class LdStOp(X86Microop):
         def __init__(self, data, segment, addr, disp,
-                dataSize, addressSize, baseFlags, atCPL0):
+                dataSize, addressSize, baseFlags, atCPL0, prefetch):
             self.data = data
             [self.scale, self.index, self.base] = addr
             self.disp = disp
@@ -371,6 +373,8 @@ let {{
             self.memFlags = baseFlags
             if atCPL0:
                 self.memFlags += " | (CPL0FlagBit << FlagShift)"
+            if prefetch:
+                self.memFlags += " | Request::PF_EXCLUSIVE"
 
         def getAllocator(self, *microFlags):
             allocator = '''new %(class_name)s(machInst, macrocodeBlock
@@ -420,9 +424,10 @@ let {{
             def __init__(self, data, segment, addr, disp = 0,
                     dataSize="env.dataSize",
                     addressSize="env.addressSize",
-                    atCPL0=False):
+                    atCPL0=False, prefetch=False):
                 super(LoadOp, self).__init__(data, segment, addr,
-                        disp, dataSize, addressSize, mem_flags, atCPL0)
+                        disp, dataSize, addressSize, mem_flags,
+                        atCPL0, prefetch)
                 self.className = Name
                 self.mnemonic = name
 
@@ -460,7 +465,7 @@ let {{
                     addressSize="env.addressSize",
                     atCPL0=False):
                 super(StoreOp, self).__init__(data, segment, addr,
-                        disp, dataSize, addressSize, mem_flags, atCPL0)
+                        disp, dataSize, addressSize, mem_flags, atCPL0, False)
                 self.className = Name
                 self.mnemonic = name
 
@@ -484,7 +489,7 @@ let {{
         def __init__(self, data, segment, addr, disp = 0,
                 dataSize="env.dataSize", addressSize="env.addressSize"):
             super(LeaOp, self).__init__(data, segment,
-                    addr, disp, dataSize, addressSize, "0", False)
+                    addr, disp, dataSize, addressSize, "0", False, False)
             self.className = "Lea"
             self.mnemonic = "lea"
 
@@ -503,7 +508,7 @@ let {{
                 dataSize="env.dataSize",
                 addressSize="env.addressSize"):
             super(TiaOp, self).__init__("NUM_INTREGS", segment,
-                    addr, disp, dataSize, addressSize, "0", False)
+                    addr, disp, dataSize, addressSize, "0", False, False)
             self.className = "Tia"
             self.mnemonic = "tia"
 
@@ -514,7 +519,7 @@ let {{
                 dataSize="env.dataSize",
                 addressSize="env.addressSize", atCPL0=False):
             super(CdaOp, self).__init__("NUM_INTREGS", segment,
-                    addr, disp, dataSize, addressSize, "0", atCPL0)
+                    addr, disp, dataSize, addressSize, "0", atCPL0, False)
             self.className = "Cda"
             self.mnemonic = "cda"