]> granicus.if.org Git - yasm/commitdiff
Merge [2116], [2117], [2118], and [2119] from trunk.
authorPeter Johnson <peter@tortall.net>
Wed, 8 Oct 2008 07:37:52 +0000 (07:37 -0000)
committerPeter Johnson <peter@tortall.net>
Wed, 8 Oct 2008 07:37:52 +0000 (07:37 -0000)
[2116]: Fix absolute path handling.
[2117]: Fix expression leveling bug.
[2118], [2119]: Add support for newly specified AVX/AES instructions.

svn path=/branches/yasm-0.7.x/; revision=2146

libyasm/expr.c
libyasm/file.c
libyasm/file.h
modules/arch/x86/gen_x86_insn.py
modules/arch/x86/tests/aes.asm
modules/arch/x86/tests/aes.hex
modules/arch/x86/tests/avx.asm
modules/arch/x86/tests/avx.hex
modules/arch/x86/x86id.c

index fe7cb9a9de45a257633679553b58a78279a69c86..14a52264d56bb84e7c14f1e22529dc5461873755 100644 (file)
@@ -43,6 +43,9 @@
 #include "arch.h"
 
 
+static /*@only@*/ yasm_expr *expr_level_op
+    (/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
+     int simplify_ident, int simplify_reg_mul);
 static int expr_traverse_nodes_post(/*@null@*/ yasm_expr *e,
                                     /*@null@*/ void *d,
                                     int (*func) (/*@null@*/ yasm_expr *e,
@@ -116,7 +119,7 @@ yasm_expr_create(yasm_expr_op op, yasm_expr__item *left,
 
     ptr->line = line;
 
-    return ptr;
+    return expr_level_op(ptr, 1, 1, 0);
 }
 /*@=compmempass@*/
 
@@ -779,7 +782,8 @@ expr_level_op(/*@returned@*/ /*@only@*/ yasm_expr *e, int fold_const,
             if (i == first_int_term)
                 first_int_term = o;
             o--;
-        }
+        } else
+            o--;
     }
 
     /* Simplify identities, make IDENT if possible, and save to e->numterms. */
index a231d89da421bac590ec7b2ff03a2acf9af31b59..01359de3069c6533d5ec98c314410e242ab0f9c3 100644 (file)
@@ -247,52 +247,18 @@ yasm__getcwd(void)
     return buf;
 }
 
-/* FIXME: dumb way for now */
 char *
-yasm__abspath_unix(const char *path)
+yasm__abspath(const char *path)
 {
     char *curdir, *abspath;
-    static const char pathsep[2] = "/";
 
     curdir = yasm__getcwd();
-
-    abspath = yasm_xmalloc(strlen(curdir) + strlen(path) + 2);
-    strcpy(abspath, curdir);
-    strcat(abspath, pathsep);
-    strcat(abspath, path);
-
+    abspath = yasm__combpath(curdir, path);
     yasm_xfree(curdir);
 
     return abspath;
 }
 
-/* FIXME: dumb way for now */
-char *
-yasm__abspath_win(const char *path)
-{
-    char *curdir, *abspath, *ch;
-    static const char pathsep[2] = "\\";
-
-    curdir = yasm__getcwd();
-
-    abspath = yasm_xmalloc(strlen(curdir) + strlen(path) + 2);
-    strcpy(abspath, curdir);
-    strcat(abspath, pathsep);
-    strcat(abspath, path);
-
-    yasm_xfree(curdir);
-
-    /* Replace all / with \ */
-    ch = abspath;
-    while (*ch) {
-        if (*ch == '/')
-            *ch = '\\';
-        ch++;
-    }
-
-    return abspath;
-}
-
 char *
 yasm__combpath_unix(const char *from, const char *to)
 {
index 4a1cd00554e94b14d2b193f2e6be61ec6a3cfb88..3eeeb8e89f9de8c54ab9e742397a6e06c2b47f2d 100644 (file)
@@ -121,35 +121,12 @@ size_t yasm__splitpath_win(const char *path, /*@out@*/ const char **tail);
  */
 /*@only@*/ char *yasm__getcwd(void);
 
-/** Convert a UNIX relative or absolute pathname into an absolute pathname.
- * \internal
- * \param path  pathname
- * \return Absolute version of path (newly allocated).
- */
-/*@only@*/ char *yasm__abspath_unix(const char *path);
-
-/** Convert a Windows relative or absolute pathname into an absolute pathname.
- * \internal
- * \param path  pathname
- * \return Absolute version of path (newly allocated).
- */
-/*@only@*/ char *yasm__abspath_win(const char *path);
-
 /** Convert a relative or absolute pathname into an absolute pathname.
- * Unless otherwise defined, defaults to yasm__abspath_unix().
  * \internal
  * \param path  pathname
  * \return Absolute version of path (newly allocated).
  */
-#ifndef yasm__abspath
-# if defined (_WIN32) || defined (WIN32) || defined (__MSDOS__) || \
- defined (__DJGPP__) || defined (__OS2__) || defined (__CYGWIN__) || \
- defined (__CYGWIN32__)
-#  define yasm__abspath(path)   yasm__abspath_win(path)
-# else
-#  define yasm__abspath(path)   yasm__abspath_unix(path)
-# endif
-#endif
+/*@only@*/ char *yasm__abspath(const char *path);
 
 /** Build a UNIX pathname that is equivalent to accessing the "to" pathname
  * when you're in the directory containing "from".  Result is relative if both
index b45dd3adcd680e896747f08423bb0a3caa465538..a361c483042d854405fc111287b5715ce2e13e45 100755 (executable)
@@ -4493,6 +4493,14 @@ add_group("movnt",
     opcode=[0x0F, 0x00],
     operands=[Operand(type="Mem", size=128, relaxed=True, dest="EA"),
               Operand(type="SIMDReg", size=128, dest="Spare")])
+add_group("movnt",
+    cpu=["AVX"],
+    modifiers=["PreAdd", "Op1Add"],
+    vex=256,
+    prefix=0x00,
+    opcode=[0x0F, 0x00],
+    operands=[Operand(type="Mem", size=256, relaxed=True, dest="EA"),
+              Operand(type="SIMDReg", size=256, dest="Spare")])
 
 add_insn("movntps", "movnt", modifiers=[0, 0x2B])
 add_insn("vmovntps", "movnt", modifiers=[0, 0x2B, VEXL0], avx=True)
@@ -6473,21 +6481,47 @@ add_insn("vfnmsubss", "fma_128_m32", modifiers=[0x7E])
 
 add_group("aes",
     cpu=["AES"],
+    modifiers=["Op1Add", "Op2Add", "SetVEX"],
+    prefix=0x66,
+    opcode=[0x0F, 0x00, 0x00],
+    operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"),
+              Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")])
+add_group("aes",
+    cpu=["AES", "AVX"],
     modifiers=["Op1Add", "Op2Add"],
+    vex=128,
     prefix=0x66,
     opcode=[0x0F, 0x00, 0x00],
     operands=[Operand(type="SIMDReg", size=128, dest="Spare"),
+              Operand(type="SIMDReg", size=128, dest="VEX"),
               Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")])
 
+
 add_insn("aesenc", "aes", modifiers=[0x38, 0xDC])
 add_insn("aesenclast", "aes", modifiers=[0x38, 0xDD])
 add_insn("aesdec", "aes", modifiers=[0x38, 0xDE])
 add_insn("aesdeclast", "aes", modifiers=[0x38, 0xDF])
-add_insn("aesimc", "aes", modifiers=[0x38, 0xDB])
+
+add_insn("vaesenc", "aes", modifiers=[0x38, 0xDC, VEXL0], avx=True)
+add_insn("vaesenclast", "aes", modifiers=[0x38, 0xDD, VEXL0], avx=True)
+add_insn("vaesdec", "aes", modifiers=[0x38, 0xDE, VEXL0], avx=True)
+add_insn("vaesdeclast", "aes", modifiers=[0x38, 0xDF, VEXL0], avx=True)
+
+add_group("aesimc",
+    cpu=["AES"],
+    modifiers=["Op1Add", "Op2Add", "SetVEX"],
+    prefix=0x66,
+    opcode=[0x0F, 0x00, 0x00],
+    operands=[Operand(type="SIMDReg", size=128, dest="SpareVEX"),
+              Operand(type="SIMDRM", size=128, relaxed=True, dest="EA")])
+
+add_insn("aesimc", "aesimc", modifiers=[0x38, 0xDB])
+add_insn("vaesimc", "aesimc", modifiers=[0x38, 0xDB, VEXL0], avx=True)
+
 
 add_group("aes_imm",
     cpu=["AES"],
-    modifiers=["Op1Add", "Op2Add"],
+    modifiers=["Op1Add", "Op2Add", "SetVEX"],
     prefix=0x66,
     opcode=[0x0F, 0x00, 0x00],
     operands=[Operand(type="SIMDReg", size=128, dest="Spare"),
@@ -6495,6 +6529,8 @@ add_group("aes_imm",
               Operand(type="Imm", size=8, relaxed=True, dest="Imm")])
 
 add_insn("aeskeygenassist", "aes_imm", modifiers=[0x3A, 0xDF])
+add_insn("vaeskeygenassist", "aes_imm", modifiers=[0x3A, 0xDF, VEXL0],
+         avx=True)
 
 #####################################################################
 # Intel PCLMULQDQ instruction
index 7f514ecafb9a71440a14785d93c31a6797d0d9aa..52c587d585dddc5ddef923f57e8bc8db5945f414 100644 (file)
@@ -5,26 +5,57 @@ aesenc xmm1, dqword [rax]
 aesenc xmm10, xmm12
 aesenc xmm10, [rax+r15*4]
 aesenc xmm10, [r14+r15*4]
+vaesenc xmm1, xmm2
+vaesenc xmm1, [rax]
+vaesenc xmm1, dqword [rax]
+vaesenc xmm1, xmm2, xmm3
+vaesenc xmm1, xmm2, [rax]
+vaesenc xmm1, xmm2, dqword [rax]
 
 aesenclast xmm1, xmm2
 aesenclast xmm1, [rax]
 aesenclast xmm1, dqword [rax]
+vaesenclast xmm1, xmm2
+vaesenclast xmm1, [rax]
+vaesenclast xmm1, dqword [rax]
+vaesenclast xmm1, xmm2, xmm3
+vaesenclast xmm1, xmm2, [rax]
+vaesenclast xmm1, xmm2, dqword [rax]
 
 aesdec xmm1, xmm2
 aesdec xmm1, [rax]
 aesdec xmm1, dqword [rax]
+vaesdec xmm1, xmm2
+vaesdec xmm1, [rax]
+vaesdec xmm1, dqword [rax]
+vaesdec xmm1, xmm2, xmm3
+vaesdec xmm1, xmm2, [rax]
+vaesdec xmm1, xmm2, dqword [rax]
 
 aesdeclast xmm1, xmm2
 aesdeclast xmm1, [rax]
 aesdeclast xmm1, dqword [rax]
+vaesdeclast xmm1, xmm2
+vaesdeclast xmm1, [rax]
+vaesdeclast xmm1, dqword [rax]
+vaesdeclast xmm1, xmm2, xmm3
+vaesdeclast xmm1, xmm2, [rax]
+vaesdeclast xmm1, xmm2, dqword [rax]
 
 aesimc xmm1, xmm2
 aesimc xmm1, [rax]
 aesimc xmm1, dqword [rax]
+vaesimc xmm1, xmm2
+vaesimc xmm1, [rax]
+vaesimc xmm1, dqword [rax]
+; no 3-operand form
 
 aeskeygenassist xmm1, xmm2, 5
 aeskeygenassist xmm1, [rax], byte 5
 aeskeygenassist xmm1, dqword [rax], 5
+vaeskeygenassist xmm1, xmm2, 5
+vaeskeygenassist xmm1, [rax], byte 5
+vaeskeygenassist xmm1, dqword [rax], 5
 
 pclmulqdq xmm1, xmm2, 5
 pclmulqdq xmm1, [rax], byte 5
index f87172c0b3d3756b77e3bdb0bf180206338afc0a..5396dee7125b65353eef6fa104b9ba2d827e5378 100644 (file)
@@ -33,6 +33,36 @@ b8
 dc 
 14 
 be 
+c4 
+e2 
+71 
+dc 
+ca 
+c4 
+e2 
+71 
+dc 
+08 
+c4 
+e2 
+71 
+dc 
+08 
+c4 
+e2 
+69 
+dc 
+cb 
+c4 
+e2 
+69 
+dc 
+08 
+c4 
+e2 
+69 
+dc 
+08 
 66 
 0f 
 38 
@@ -48,6 +78,36 @@ dd
 38 
 dd 
 08 
+c4 
+e2 
+71 
+dd 
+ca 
+c4 
+e2 
+71 
+dd 
+08 
+c4 
+e2 
+71 
+dd 
+08 
+c4 
+e2 
+69 
+dd 
+cb 
+c4 
+e2 
+69 
+dd 
+08 
+c4 
+e2 
+69 
+dd 
+08 
 66 
 0f 
 38 
@@ -63,6 +123,36 @@ de
 38 
 de 
 08 
+c4 
+e2 
+71 
+de 
+ca 
+c4 
+e2 
+71 
+de 
+08 
+c4 
+e2 
+71 
+de 
+08 
+c4 
+e2 
+69 
+de 
+cb 
+c4 
+e2 
+69 
+de 
+08 
+c4 
+e2 
+69 
+de 
+08 
 66 
 0f 
 38 
@@ -78,6 +168,36 @@ df
 38 
 df 
 08 
+c4 
+e2 
+71 
+df 
+ca 
+c4 
+e2 
+71 
+df 
+08 
+c4 
+e2 
+71 
+df 
+08 
+c4 
+e2 
+69 
+df 
+cb 
+c4 
+e2 
+69 
+df 
+08 
+c4 
+e2 
+69 
+df 
+08 
 66 
 0f 
 38 
@@ -93,6 +213,21 @@ db
 38 
 db 
 08 
+c4 
+e2 
+71 
+db 
+ca 
+c4 
+e2 
+71 
+db 
+08 
+c4 
+e2 
+71 
+db 
+08 
 66 
 0f 
 3a 
@@ -111,6 +246,24 @@ df
 df 
 08 
 05 
+c4 
+e3 
+79 
+df 
+ca 
+05 
+c4 
+e3 
+79 
+df 
+08 
+05 
+c4 
+e3 
+79 
+df 
+08 
+05 
 66 
 0f 
 3a 
index 2a2ad59463f908ade6619496c512be0f594fca76..6461ea0535762beb7ea7e05772571616948ce60a 100644 (file)
@@ -921,6 +921,8 @@ movntdq [rax], xmm1
 movntdq dqword [rax], xmm1
 vmovntdq [rax], xmm1
 vmovntdq dqword [rax], xmm1
+vmovntdq [rax], ymm1
+vmovntdq yword [rax], ymm1
 
 movntdqa xmm1, [rax]
 movntdqa xmm1, dqword [rax]
@@ -931,11 +933,15 @@ movntpd [rax], xmm1
 movntpd dqword [rax], xmm1
 vmovntpd [rax], xmm1
 vmovntpd dqword [rax], xmm1
+vmovntpd [rax], ymm1
+vmovntpd yword [rax], ymm1
 
 movntps [rax], xmm1
 movntps dqword [rax], xmm1
 vmovntps [rax], xmm1
 vmovntps dqword [rax], xmm1
+vmovntps [rax], ymm1
+vmovntps yword [rax], ymm1
 
 movsd xmm1, xmm2
 vmovsd xmm1, xmm2
index 1a73e38600ecf0309a3f43965ebc467704b11176..c9ada3e10a6fe3e67a6faa6cd5199014aa22c167 100644 (file)
@@ -3466,6 +3466,14 @@ c5
 f9 
 e7 
 08 
+c5 
+fd 
+e7 
+08 
+c5 
+fd 
+e7 
+08 
 66 
 0f 
 38 
@@ -3502,6 +3510,14 @@ c5
 f9 
 2b 
 08 
+c5 
+fd 
+2b 
+08 
+c5 
+fd 
+2b 
+08 
 0f 
 2b 
 08 
@@ -3516,6 +3532,14 @@ c5
 f8 
 2b 
 08 
+c5 
+fc 
+2b 
+08 
+c5 
+fc 
+2b 
+08 
 f2 
 0f 
 10 
index 07d05a0e18f06ad620e1bd02bfee84da77f9fcee..2e51a4339f451fd01057007420559d65328b451a 100644 (file)
@@ -1718,12 +1718,12 @@ yasm_x86__parse_check_insnprefix(yasm_arch *arch, const char *id,
     yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch;
     /*@null@*/ const insnprefix_parse_data *pdata;
     size_t i;
-    static char lcaseid[16];
+    static char lcaseid[17];
 
     *bc = (yasm_bytecode *)NULL;
     *prefix = 0;
 
-    if (id_len > 15)
+    if (id_len > 16)
         return YASM_ARCH_NOTINSNPREFIX;
     for (i=0; i<id_len; i++)
         lcaseid[i] = tolower(id[i]);