Merge [2116], [2117], [2118], and [2119] from trunk.

[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
This commit is contained in:
Peter Johnson 2008-10-08 07:37:52 +00:00
parent 5afe24a8a0
commit d1b8e92eab
9 changed files with 263 additions and 66 deletions

View 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. */

View 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)
{

View 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

View file

@ -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

View 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

View 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

View 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

View 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

View 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]);