HLE: Split the LOCK and REP prefix slots
authorH. Peter Anvin <hpa@zytor.com>
Sat, 25 Feb 2012 04:57:04 +0000 (20:57 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Sat, 25 Feb 2012 04:57:04 +0000 (20:57 -0800)
With HLE, the sequence REP LOCK actually makes sense, so support it.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
assemble.c
disasm.c
nasm.h
parser.c

index f1583fd..691e792 100644 (file)
@@ -1027,13 +1027,13 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits,
             break;
 
         case 0336:
-            if (!ins->prefixes[PPS_LREP])
-                ins->prefixes[PPS_LREP] = P_REP;
+            if (!ins->prefixes[PPS_REP])
+                ins->prefixes[PPS_REP] = P_REP;
             break;
 
         case 0337:
-            if (!ins->prefixes[PPS_LREP])
-                ins->prefixes[PPS_LREP] = P_REPNE;
+            if (!ins->prefixes[PPS_REP])
+                ins->prefixes[PPS_REP] = P_REPNE;
             break;
 
         case 0340:
@@ -1183,7 +1183,7 @@ static int64_t calcsize(int32_t segment, int64_t offset, int bits,
                    !(ins->rex & (REX_P|REX_W|REX_X|REX_B)) &&
                    cpu >= IF_X86_64) {
             /* LOCK-as-REX.R */
-            assert_no_prefix(ins, PPS_LREP);
+            assert_no_prefix(ins, PPS_LOCK);
             length++;
         } else {
             errfunc(ERR_NONFATAL, "invalid operands in non-64-bit mode");
index 66ea7b0..9bedcc7 100644 (file)
--- a/disasm.c
+++ b/disasm.c
@@ -918,14 +918,14 @@ static int matches(const struct itemplate *t, uint8_t *data,
     }
 
     if (lock) {
-       if (ins->prefixes[PPS_LREP])
+       if (ins->prefixes[PPS_LOCK])
            return false;
-       ins->prefixes[PPS_LREP] = P_LOCK;
+       ins->prefixes[PPS_LOCK] = P_LOCK;
     }
     if (drep) {
-       if (ins->prefixes[PPS_LREP])
+       if (ins->prefixes[PPS_REP])
            return false;
-        ins->prefixes[PPS_LREP] = drep;
+        ins->prefixes[PPS_REP] = drep;
     }
     ins->prefixes[PPS_WAIT] = dwait;
     if (!o_used) {
diff --git a/nasm.h b/nasm.h
index 01f9ffc..23def29 100644 (file)
--- a/nasm.h
+++ b/nasm.h
@@ -544,12 +544,13 @@ enum ea_type {
  * preferences, you can change this.  REX prefixes are handled
  * differently for the time being.
  *
- * Note that LOCK and REP are in the same slot.  This is
- * an x86 architectural constraint.
+ * LOCK and REP used to be one slot; this is no longer the case since
+ * the introduction of HLE.
  */
 enum prefix_pos {
     PPS_WAIT,   /* WAIT (technically not a prefix!) */
-    PPS_LREP,   /* Lock or REP prefix */
+    PPS_REP,    /* REP/HLE prefix */
+    PPS_LOCK,   /* LOCK prefix */
     PPS_SEG,    /* Segment override prefix */
     PPS_OSIZE,  /* Operand size prefix */
     PPS_ASIZE,  /* Address size prefix */
index 37d7138..3a592fe 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -81,12 +81,13 @@ static int prefix_slot(int prefix)
     case R_GS:
         return PPS_SEG;
     case P_LOCK:
+        return PPS_LOCK;
     case P_REP:
     case P_REPE:
     case P_REPZ:
     case P_REPNE:
     case P_REPNZ:
-        return PPS_LREP;
+        return PPS_REP;
     case P_O16:
     case P_O32:
     case P_O64: