Commit 297bb128 authored by Keith Randall's avatar Keith Randall

cmd/6a, cmd/8a, cmd/6l, cmd/8l: add AES instructions

Instructions for use in AES hashing.  See CL#7543043

R=rsc
CC=golang-dev
https://golang.org/cl/7548043
parent 4c203172
......@@ -932,6 +932,8 @@ struct
"PCMPGTW", LTYPE3, APCMPGTW,
"PEXTRW", LTYPEX, APEXTRW,
"PINSRW", LTYPEX, APINSRW,
"PINSRD", LTYPEX, APINSRD,
"PINSRQ", LTYPEX, APINSRQ,
"PMADDWL", LTYPE3, APMADDWL,
"PMAXSW", LTYPE3, APMAXSW,
"PMAXUB", LTYPE3, APMAXUB,
......@@ -949,6 +951,7 @@ struct
"PSHUFL", LTYPEX, APSHUFL,
"PSHUFLW", LTYPEX, APSHUFLW,
"PSHUFW", LTYPEX, APSHUFW,
"PSHUFB", LTYPEM, APSHUFB,
"PSLLO", LTYPE3, APSLLO,
"PSLLDQ", LTYPE3, APSLLO, /* syn */
"PSLLL", LTYPE3, APSLLL,
......
......@@ -654,6 +654,8 @@ enum as
APFSUB,
APFSUBR,
APINSRW,
APINSRD,
APINSRQ,
APMADDWL,
APMAXSW,
APMAXUB,
......@@ -671,6 +673,7 @@ enum as
APSHUFL,
APSHUFLW,
APSHUFW,
APSHUFB,
APSLLO,
APSLLL,
APSLLQ,
......
......@@ -263,6 +263,7 @@ enum
Zo_iw,
Zm_o,
Zm_r,
Zm2_r,
Zm_r_xm,
Zm_r_i_xm,
Zm_r_3d,
......@@ -292,10 +293,11 @@ enum
P32 = 0x32, /* 32-bit only */
Pe = 0x66, /* operand escape */
Pm = 0x0f, /* 2byte opcode escape */
Pq = 0xff, /* both escape */
Pq = 0xff, /* both escapes: 66 0f */
Pb = 0xfe, /* byte operands */
Pf2 = 0xf2, /* xmm escape 1 */
Pf3 = 0xf3, /* xmm escape 2 */
Pf2 = 0xf2, /* xmm escape 1: f2 0f */
Pf3 = 0xf3, /* xmm escape 2: f3 0f */
Pq3 = 0x67, /* xmm escape 3: 66 48 0f */
Pw = 0x48, /* Rex.w */
Py = 0x80, /* defaults to 64-bit mode */
......
......@@ -522,6 +522,11 @@ uchar ymshuf[] =
Ymm, Ymr, Zibm_r, 2,
0
};
uchar ymshufb[] =
{
Yxm, Yxr, Zm2_r, 2,
0
};
uchar yxshuf[] =
{
Yxm, Yxr, Zibm_r, 2,
......@@ -532,6 +537,11 @@ uchar yextrw[] =
Yxr, Yrl, Zibm_r, 2,
0
};
uchar yinsr[] =
{
Ymm, Yxr, Zibm_r, 3,
0
};
uchar ypsdq[] =
{
Yi8, Yxr, Zibo_m, 2,
......@@ -983,6 +993,8 @@ Optab optab[] =
{ APFSUB, ymfp, Px, 0x9a },
{ APFSUBR, ymfp, Px, 0xaa },
{ APINSRW, yextrw, Pq, 0xc4,(00) },
{ APINSRD, yinsr, Pq, 0x3a, 0x22, (00) },
{ APINSRQ, yinsr, Pq3, 0x3a, 0x22, (00) },
{ APMADDWL, ymm, Py, 0xf5,Pe,0xf5 },
{ APMAXSW, yxm, Pe, 0xee },
{ APMAXUB, yxm, Pe, 0xde },
......@@ -1008,6 +1020,7 @@ Optab optab[] =
{ APSHUFL, yxshuf, Pq, 0x70,(00) },
{ APSHUFLW, yxshuf, Pf2, 0x70,(00) },
{ APSHUFW, ymshuf, Pm, 0x70,(00) },
{ APSHUFB, ymshufb,Pq, 0x38, 0x00 },
{ APSLLO, ypsdq, Pq, 0x73,(07) },
{ APSLLL, yps, Py, 0xf2, 0x72,(06), Pe,0xf2, Pe,0x72,(06) },
{ APSLLQ, yps, Py, 0xf3, 0x73,(06), Pe,0xf3, Pe,0x73,(06) },
......
......@@ -1161,6 +1161,11 @@ found:
*andptr++ = Pe;
*andptr++ = Pm;
break;
case Pq3: /* 16 bit escape, Rex.w, and opcode escape */
*andptr++ = Pe;
*andptr++ = Pw;
*andptr++ = Pm;
break;
case Pf2: /* xmm opcode escape */
case Pf3:
......@@ -1229,6 +1234,11 @@ found:
*andptr++ = op;
asmand(&p->from, &p->to);
break;
case Zm2_r:
*andptr++ = op;
*andptr++ = o->op[z+1];
asmand(&p->from, &p->to);
break;
case Zm_r_xm:
mediaop(o, op, t[3], z);
......
......@@ -54,7 +54,7 @@
%left '*' '/' '%'
%token <lval> LTYPE0 LTYPE1 LTYPE2 LTYPE3 LTYPE4
%token <lval> LTYPEC LTYPED LTYPEN LTYPER LTYPET LTYPES LTYPEM LTYPEI LTYPEG LTYPEXC
%token <lval> LCONST LFP LPC LSB
%token <lval> LTYPEX LCONST LFP LPC LSB
%token <lval> LBREG LLREG LSREG LFREG LXREG
%token <dval> LFCONST
%token <sval> LSCONST LSP
......@@ -63,7 +63,7 @@
%type <con2> con2
%type <gen> mem imm imm2 reg nam rel rem rim rom omem nmem
%type <gen2> nonnon nonrel nonrem rimnon rimrem remrim
%type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9
%type <gen2> spec1 spec2 spec3 spec4 spec5 spec6 spec7 spec8 spec9 spec10
%%
prog:
| prog
......@@ -117,6 +117,7 @@ inst:
| LTYPEI spec7 { outcode($1, &$2); }
| LTYPEG spec8 { outcode($1, &$2); }
| LTYPEXC spec9 { outcode($1, &$2); }
| LTYPEX spec10 { outcode($1, &$2); }
nonnon:
{
......@@ -296,6 +297,16 @@ spec9: /* CMPPS/CMPPD */
$$.to.offset = $5;
}
spec10: /* PINSRD */
imm ',' rem ',' reg
{
$$.from = $3;
$$.to = $5;
if($1.type != D_CONST)
yyerror("illegal constant");
$$.to.offset = $1.offset;
}
rem:
reg
| mem
......
......@@ -306,6 +306,7 @@ struct
"CMPXCHGB", LTYPE3, ACMPXCHGB,
"CMPXCHGL", LTYPE3, ACMPXCHGL,
"CMPXCHGW", LTYPE3, ACMPXCHGW,
"CPUID", LTYPE0, ACPUID,
"DAA", LTYPE0, ADAA,
"DAS", LTYPE0, ADAS,
"DATA", LTYPED, ADATA,
......@@ -408,6 +409,7 @@ struct
"MOVB", LTYPE3, AMOVB,
"MOVL", LTYPEM, AMOVL,
"MOVW", LTYPEM, AMOVW,
"MOVQ", LTYPEM, AMOVQ,
"MOVBLSX", LTYPE3, AMOVBLSX,
"MOVBLZX", LTYPE3, AMOVBLZX,
"MOVBWSX", LTYPE3, AMOVBWSX,
......@@ -437,6 +439,7 @@ struct
"OUTSL", LTYPE0, AOUTSL,
"OUTSW", LTYPE0, AOUTSW,
"PAUSE", LTYPEN, APAUSE,
"PINSRD", LTYPEX, APINSRD,
"POPAL", LTYPE0, APOPAL,
"POPAW", LTYPE0, APOPAW,
"POPFL", LTYPE0, APOPFL,
......@@ -687,6 +690,7 @@ struct
"ADDPS", LTYPE3, AADDPS,
"ADDSD", LTYPE3, AADDSD,
"ADDSS", LTYPE3, AADDSS,
"AESENC", LTYPE3, AAESENC,
"ANDNPD", LTYPE3, AANDNPD,
"ANDNPS", LTYPE3, AANDNPS,
"ANDPD", LTYPE3, AANDPD,
......@@ -755,11 +759,13 @@ struct
"ORPD", LTYPE3, AORPD,
"ORPS", LTYPE3, AORPS,
"PADDQ", LTYPE3, APADDQ,
"PAND", LTYPE3, APAND,
"PMAXSW", LTYPE3, APMAXSW,
"PMAXUB", LTYPE3, APMAXUB,
"PMINSW", LTYPE3, APMINSW,
"PMINUB", LTYPE3, APMINUB,
"PSADBW", LTYPE3, APSADBW,
"PSHUFB", LTYPE3, APSHUFB,
"PSUBB", LTYPE3, APSUBB,
"PSUBL", LTYPE3, APSUBL,
"PSUBQ", LTYPE3, APSUBQ,
......
This diff is collapsed.
/* A Bison parser, made by GNU Bison 2.6.5. */
/* A Bison parser, made by GNU Bison 2.5. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -30,15 +30,6 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_YY_Y_TAB_H_INCLUDED
# define YY_YY_Y_TAB_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int yydebug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
......@@ -61,21 +52,22 @@ extern int yydebug;
LTYPEI = 270,
LTYPEG = 271,
LTYPEXC = 272,
LCONST = 273,
LFP = 274,
LPC = 275,
LSB = 276,
LBREG = 277,
LLREG = 278,
LSREG = 279,
LFREG = 280,
LXREG = 281,
LFCONST = 282,
LSCONST = 283,
LSP = 284,
LNAME = 285,
LLAB = 286,
LVAR = 287
LTYPEX = 273,
LCONST = 274,
LFP = 275,
LPC = 276,
LSB = 277,
LBREG = 278,
LLREG = 279,
LSREG = 280,
LFREG = 281,
LXREG = 282,
LFCONST = 283,
LSCONST = 284,
LSP = 285,
LNAME = 286,
LLAB = 287,
LVAR = 288
};
#endif
/* Tokens. */
......@@ -94,28 +86,31 @@ extern int yydebug;
#define LTYPEI 270
#define LTYPEG 271
#define LTYPEXC 272
#define LCONST 273
#define LFP 274
#define LPC 275
#define LSB 276
#define LBREG 277
#define LLREG 278
#define LSREG 279
#define LFREG 280
#define LXREG 281
#define LFCONST 282
#define LSCONST 283
#define LSP 284
#define LNAME 285
#define LLAB 286
#define LVAR 287
#define LTYPEX 273
#define LCONST 274
#define LFP 275
#define LPC 276
#define LSB 277
#define LBREG 278
#define LLREG 279
#define LSREG 280
#define LFREG 281
#define LXREG 282
#define LFCONST 283
#define LSCONST 284
#define LSP 285
#define LNAME 286
#define LLAB 287
#define LVAR 288
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2042 of yacc.c */
/* Line 2068 of yacc.c */
#line 37 "a.y"
Sym *sym;
......@@ -130,8 +125,9 @@ typedef union YYSTYPE
Gen2 gen2;
/* Line 2042 of yacc.c */
#line 135 "y.tab.h"
/* Line 2068 of yacc.c */
#line 131 "y.tab.h"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
......@@ -140,18 +136,4 @@ typedef union YYSTYPE
extern YYSTYPE yylval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (void);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_YY_Y_TAB_H_INCLUDED */
......@@ -153,6 +153,7 @@ enum as
AMOVB,
AMOVL,
AMOVW,
AMOVQ,
AMOVBLSX,
AMOVBLZX,
AMOVBWSX,
......@@ -397,6 +398,7 @@ enum as
ACMPXCHGW,
ACMPXCHG8B,
ACPUID,
ARDTSC,
AXADDB,
......@@ -531,6 +533,7 @@ enum as
AORPD,
AORPS,
APADDQ,
APAND,
APMAXSW,
APMAXUB,
APMINSW,
......@@ -566,7 +569,12 @@ enum as
AUNPCKLPS,
AXORPD,
AXORPS,
/* SSE 3+ */
AAESENC,
APINSRD,
APSHUFB,
AUSEFIELD,
ALOCALS,
ATYPE,
......
......@@ -172,7 +172,7 @@ struct Optab
short as;
uchar* ytab;
uchar prefix;
uchar op[10];
uchar op[12];
};
enum
......@@ -217,6 +217,7 @@ enum
Zxxx = 0,
Zlit,
Zlitm_r,
Z_rp,
Zbr,
Zcall,
......@@ -233,6 +234,7 @@ enum
Zloop,
Zm_o,
Zm_r,
Zm2_r,
Zm_r_xm,
Zm_r_i_xm,
Zaut_r,
......@@ -249,6 +251,7 @@ enum
Zib_rr,
Zil_rr,
Zclr,
Zibm_r, /* mmx1,mmx2/mem64,imm8 */
Zbyte,
Zmov,
Zmax,
......
......@@ -150,9 +150,16 @@ uchar ymovl[] =
// Yi0, Yml, Zibo_m, 2, // shorter but slower AND $0,dst
Yi32, Yrl, Zil_rp, 1,
Yi32, Yml, Zilo_m, 2,
Yml, Yxr, Zm_r_xm, 2, // XMM MOVD (32 bit)
Yxr, Yml, Zr_m_xm, 2, // XMM MOVD (32 bit)
Yiauto, Yrl, Zaut_r, 2,
0
};
uchar ymovq[] =
{
Yml, Yxr, Zm_r_xm, 2,
0
};
uchar ym_rl[] =
{
Ym, Yrl, Zm_r, 1,
......@@ -435,6 +442,21 @@ uchar yprefetch[] =
Ym, Ynone, Zm_o, 2,
0,
};
uchar yaes[] =
{
Yxm, Yxr, Zlitm_r, 2,
0
};
uchar yinsrd[] =
{
Yml, Yxr, Zibm_r, 2,
0
};
uchar ymshufb[] =
{
Yxm, Yxr, Zm2_r, 2,
0
};
Optab optab[] =
/* as, ytab, andproto, opcode */
......@@ -552,8 +574,9 @@ Optab optab[] =
{ ALSLL, yml_rl, Pm, 0x03 },
{ ALSLW, yml_rl, Pq, 0x03 },
{ AMOVB, ymovb, Pb, 0x88,0x8a,0xb0,0xc6,(00) },
{ AMOVL, ymovl, Px, 0x89,0x8b,0x31,0x83,(04),0xb8,0xc7,(00) },
{ AMOVL, ymovl, Px, 0x89,0x8b,0x31,0x83,(04),0xb8,0xc7,(00),Pe,0x6e,Pe,0x7e },
{ AMOVW, ymovl, Pe, 0x89,0x8b,0x31,0x83,(04),0xb8,0xc7,(00) },
{ AMOVQ, ymovq, Pf3, 0x7e },
{ AMOVBLSX, ymb_rl, Pm, 0xbe },
{ AMOVBLZX, ymb_rl, Pm, 0xb6 },
{ AMOVBWSX, ymb_rl, Pq, 0xbe },
......@@ -793,6 +816,7 @@ Optab optab[] =
{ ACMPXCHGW, yrl_ml, Pm, 0xb1 },
{ ACMPXCHG8B, yscond, Pm, 0xc7,(01) },
{ ACPUID, ynone, Pm, 0xa2 },
{ ARDTSC, ynone, Pm, 0x31 },
{ AXADDB, yrb_mb, Pb, 0x0f,0xc0 },
......@@ -925,6 +949,7 @@ Optab optab[] =
{ AORPD, yxm, Pq, 0x56 },
{ AORPS, yxm, Pm, 0x56 },
{ APADDQ, yxm, Pe, 0xd4 },
{ APAND, yxm, Pe, 0xdb },
{ APMAXSW, yxm, Pe, 0xee },
{ APMAXUB, yxm, Pe, 0xde },
{ APMINSW, yxm, Pe, 0xea },
......@@ -961,6 +986,10 @@ Optab optab[] =
{ AXORPD, yxm, Pe, 0x57 },
{ AXORPS, yxm, Pm, 0x57 },
{ AAESENC, yaes, Pq, 0x38,0xdc,(0) },
{ APINSRD, yinsrd, Pq, 0x3a, 0x22, (00) },
{ APSHUFB, ymshufb,Pq, 0x38, 0x00 },
{ AUSEFIELD, ynop, Px, 0,0 },
{ ALOCALS },
{ ATYPE },
......
......@@ -1003,11 +1003,23 @@ found:
*andptr++ = op;
break;
case Zlitm_r:
for(; op = o->op[z]; z++)
*andptr++ = op;
asmand(&p->from, reg[p->to.type]);
break;
case Zm_r:
*andptr++ = op;
asmand(&p->from, reg[p->to.type]);
break;
case Zm2_r:
*andptr++ = op;
*andptr++ = o->op[z+1];
asmand(&p->from, reg[p->to.type]);
break;
case Zm_r_xm:
mediaop(o, op, t[3], z);
asmand(&p->from, reg[p->to.type]);
......@@ -1019,6 +1031,13 @@ found:
*andptr++ = p->to.offset;
break;
case Zibm_r:
while ((op = o->op[z++]) != 0)
*andptr++ = op;
asmand(&p->from, reg[p->to.type]);
*andptr++ = p->to.offset;
break;
case Zaut_r:
*andptr++ = 0x8d; /* leal */
if(p->from.type != D_ADDR)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment