Commit 863d9b66 authored by Russ Cox's avatar Russ Cox

cmd/asm: add requested amd64 instructions

Add amd64 instructions I promised to add for Go 1.6
at the beginning of January.

These may be the last instructions added by hand.
I intend to generate the whole set mechanically for Go 1.7.

Fixes #13822.

Change-Id: I8c6bae2efd25f717f9ec750402e50f408a911d2b
Reviewed-on: https://go-review.googlesource.com/18853Reviewed-by: 's avatarRob Pike <r@golang.org>
parent 8d881b81
......@@ -162,11 +162,11 @@ func archX86(linkArch *obj.LinkArch) *Arch {
instructions["MOVDQ2Q"] = x86.AMOVQ
instructions["MOVNTDQ"] = x86.AMOVNTO
instructions["MOVOA"] = x86.AMOVO
instructions["MOVOA"] = x86.AMOVO
instructions["PF2ID"] = x86.APF2IL
instructions["PI2FD"] = x86.API2FL
instructions["PSLLDQ"] = x86.APSLLO
instructions["PSRLDQ"] = x86.APSRLO
instructions["PADDD"] = x86.APADDL
return &Arch{
LinkArch: linkArch,
......
......@@ -121,5 +121,11 @@ label:
loop:
LOOP loop // LOOP
// Intel pseudonyms for our own renamings.
PADDD M2, M1 // PADDL M2, M1
MOVDQ2Q X1, M1 // MOVQ X1, M1
MOVNTDQ X1, (AX) // MOVNTO X1, (AX)
MOVOA (AX), X1 // MOVO (AX), X1
// LTYPE0 nonnon { outcode($1, &$2); }
RET // c3
......@@ -601,15 +601,15 @@ const (
APADDUSB
APADDUSW
APADDW
APAND
APANDB
APANDL
APANDN
APANDSB
APANDSW
APANDUSB
APANDUSW
APANDW
APAND
APANDN
APAVGB
APAVGW
APCMPEQB
......@@ -618,10 +618,10 @@ const (
APCMPGTB
APCMPGTL
APCMPGTW
APEXTRW
APEXTRB
APEXTRD
APEXTRQ
APEXTRW
APFACC
APFADD
APFCMPEQ
......@@ -633,42 +633,63 @@ const (
APFNACC
APFPNACC
APFRCP
APFRCPIT1
APFRCPI2T
APFRCPIT1
APFRSQIT1
APFRSQRT
APFSUB
APFSUBR
APINSRW
APHADDD
APHADDSW
APHADDW
APHMINPOSUW
APHSUBD
APHSUBSW
APHSUBW
APINSRB
APINSRD
APINSRQ
APINSRW
APMADDWL
APMAXSW
APMAXUB
APMINSW
APMINUB
APMOVMSKB
APMOVSXBD
APMOVSXBQ
APMOVSXBW
APMOVSXDQ
APMOVSXWD
APMOVSXWQ
APMOVZXBD
APMOVZXBQ
APMOVZXBW
APMOVZXDQ
APMOVZXWD
APMOVZXWQ
APMULDQ
APMULHRW
APMULHUW
APMULHW
APMULLD
APMULLW
APMULULQ
APOR
APSADBW
APSHUFB
APSHUFHW
APSHUFL
APSHUFLW
APSHUFW
APSHUFB
APSLLO
APSLLL
APSLLO
APSLLQ
APSLLW
APSRAL
APSRAW
APSRLO
APSRLL
APSRLO
APSRLQ
APSRLW
APSUBB
......
......@@ -550,15 +550,15 @@ var Anames = []string{
"PADDUSB",
"PADDUSW",
"PADDW",
"PAND",
"PANDB",
"PANDL",
"PANDN",
"PANDSB",
"PANDSW",
"PANDUSB",
"PANDUSW",
"PANDW",
"PAND",
"PANDN",
"PAVGB",
"PAVGW",
"PCMPEQB",
......@@ -567,10 +567,10 @@ var Anames = []string{
"PCMPGTB",
"PCMPGTL",
"PCMPGTW",
"PEXTRW",
"PEXTRB",
"PEXTRD",
"PEXTRQ",
"PEXTRW",
"PFACC",
"PFADD",
"PFCMPEQ",
......@@ -582,42 +582,63 @@ var Anames = []string{
"PFNACC",
"PFPNACC",
"PFRCP",
"PFRCPIT1",
"PFRCPI2T",
"PFRCPIT1",
"PFRSQIT1",
"PFRSQRT",
"PFSUB",
"PFSUBR",
"PINSRW",
"PHADDD",
"PHADDSW",
"PHADDW",
"PHMINPOSUW",
"PHSUBD",
"PHSUBSW",
"PHSUBW",
"PINSRB",
"PINSRD",
"PINSRQ",
"PINSRW",
"PMADDWL",
"PMAXSW",
"PMAXUB",
"PMINSW",
"PMINUB",
"PMOVMSKB",
"PMOVSXBD",
"PMOVSXBQ",
"PMOVSXBW",
"PMOVSXDQ",
"PMOVSXWD",
"PMOVSXWQ",
"PMOVZXBD",
"PMOVZXBQ",
"PMOVZXBW",
"PMOVZXDQ",
"PMOVZXWD",
"PMOVZXWQ",
"PMULDQ",
"PMULHRW",
"PMULHUW",
"PMULHW",
"PMULLD",
"PMULLW",
"PMULULQ",
"POR",
"PSADBW",
"PSHUFB",
"PSHUFHW",
"PSHUFL",
"PSHUFLW",
"PSHUFW",
"PSHUFB",
"PSLLO",
"PSLLL",
"PSLLO",
"PSLLQ",
"PSLLW",
"PSRAL",
"PSRAW",
"PSRLO",
"PSRLL",
"PSRLO",
"PSRLQ",
"PSRLW",
"PSUBB",
......
......@@ -222,6 +222,7 @@ const (
Pf3 = 0xf3 /* xmm escape 2: f3 0f */
Pef3 = 0xf5 /* xmm escape 2 with 16-bit prefix: 66 f3 0f */
Pq3 = 0x67 /* xmm escape 3: 66 48 0f */
Pq4 = 0x68 /* xmm escape 4: 66 0F 38 */
Pfw = 0xf4 /* Pf3 with Rex.w: f3 48 0f */
Pw = 0x48 /* Rex.w */
Pw8 = 0x90 // symbolic; exact value doesn't matter
......@@ -675,6 +676,10 @@ var yxm = []ytab{
{Yxm, Ynone, Yxr, Zm_r_xm, 1},
}
var yxm_q4 = []ytab{
{Yxm, Ynone, Yxr, Zm_r, 1},
}
var yxcvm1 = []ytab{
{Yxm, Ynone, Yxr, Zm_r_xm, 2},
{Yxm, Ynone, Ymr, Zm_r_xm, 2},
......@@ -817,6 +822,10 @@ var yxabort = []ytab{
{Yu8, Ynone, Ynone, Zib_, 1},
}
var ylddqu = []ytab{
{Ym, Ynone, Yxr, Zm_r, 1},
}
// VEX instructions that come in two forms:
// VTHING xmm2/m128, xmmV, xmm1
// VTHING ymm2/m256, ymmV, ymm1
......@@ -873,6 +882,11 @@ var yvex_xxmyxm = []ytab{
{Yyr, Ynone, Yxm, Zvex_r_v_rm, 2},
}
var ymmxmm0f38 = []ytab{
{Ymm, Ynone, Ymr, Zlitm_r, 3},
{Yxm, Ynone, Yxr, Zlitm_r, 5},
}
/*
* You are doasm, holding in your hand a Prog* with p->as set to, say, ACRC32,
* and p->from and p->to as operands (Addr*). The linker scans optab to find
......@@ -1149,6 +1163,7 @@ var optab =
{ALAHF, ynone, Px, [23]uint8{0x9f}},
{ALARL, yml_rl, Pm, [23]uint8{0x02}},
{ALARW, yml_rl, Pq, [23]uint8{0x02}},
{ALDDQU, ylddqu, Pf2, [23]uint8{0xf0}},
{ALDMXCSR, ysvrs, Pm, [23]uint8{0xae, 02, 0xae, 02}},
{ALEAL, ym_rl, Px, [23]uint8{0x8d}},
{ALEAQ, ym_rl, Pw, [23]uint8{0x8d}},
......@@ -1293,6 +1308,13 @@ var optab =
{APFRSQRT, ymfp, Px, [23]uint8{0x97}},
{APFSUB, ymfp, Px, [23]uint8{0x9a}},
{APFSUBR, ymfp, Px, [23]uint8{0xaa}},
{APHADDD, ymmxmm0f38, Px, [23]uint8{0x0F, 0x38, 0x02, 0, 0x66, 0x0F, 0x38, 0x02, 0}},
{APHADDSW, yxm_q4, Pq4, [23]uint8{0x03}},
{APHADDW, yxm_q4, Pq4, [23]uint8{0x01}},
{APHMINPOSUW, yxm_q4, Pq4, [23]uint8{0x41}},
{APHSUBD, yxm_q4, Pq4, [23]uint8{0x06}},
{APHSUBSW, yxm_q4, Pq4, [23]uint8{0x07}},
{APHSUBW, yxm_q4, Pq4, [23]uint8{0x05}},
{APINSRW, yinsrw, Pq, [23]uint8{0xc4, 00}},
{APINSRB, yinsr, Pq, [23]uint8{0x3a, 0x20, 00}},
{APINSRD, yinsr, Pq, [23]uint8{0x3a, 0x22, 00}},
......@@ -1303,9 +1325,23 @@ var optab =
{APMINSW, yxm, Pe, [23]uint8{0xea}},
{APMINUB, yxm, Pe, [23]uint8{0xda}},
{APMOVMSKB, ymskb, Px, [23]uint8{Pe, 0xd7, 0xd7}},
{APMOVSXBD, yxm_q4, Pq4, [23]uint8{0x21}},
{APMOVSXBQ, yxm_q4, Pq4, [23]uint8{0x22}},
{APMOVSXBW, yxm_q4, Pq4, [23]uint8{0x20}},
{APMOVSXDQ, yxm_q4, Pq4, [23]uint8{0x25}},
{APMOVSXWD, yxm_q4, Pq4, [23]uint8{0x23}},
{APMOVSXWQ, yxm_q4, Pq4, [23]uint8{0x24}},
{APMOVZXBD, yxm_q4, Pq4, [23]uint8{0x31}},
{APMOVZXBQ, yxm_q4, Pq4, [23]uint8{0x32}},
{APMOVZXBW, yxm_q4, Pq4, [23]uint8{0x30}},
{APMOVZXDQ, yxm_q4, Pq4, [23]uint8{0x35}},
{APMOVZXWD, yxm_q4, Pq4, [23]uint8{0x33}},
{APMOVZXWQ, yxm_q4, Pq4, [23]uint8{0x34}},
{APMULDQ, yxm_q4, Pq4, [23]uint8{0x28}},
{APMULHRW, ymfp, Px, [23]uint8{0xb7}},
{APMULHUW, ymm, Py1, [23]uint8{0xe4, Pe, 0xe4}},
{APMULHW, ymm, Py1, [23]uint8{0xe5, Pe, 0xe5}},
{APMULLD, yxm_q4, Pq4, [23]uint8{0x40}},
{APMULLW, ymm, Py1, [23]uint8{0xd5, Pe, 0xd5}},
{APMULULQ, ymm, Py1, [23]uint8{0xf4, Pe, 0xf4}},
{APOPAL, ynone, P32, [23]uint8{0x61}},
......@@ -3292,6 +3328,12 @@ func doasm(ctxt *obj.Link, p *obj.Prog) {
ctxt.Andptr[0] = Pm
ctxt.Andptr = ctxt.Andptr[1:]
case Pq4: /* 66 0F 38 */
ctxt.Andptr[0] = 0x66
ctxt.Andptr[1] = 0x0F
ctxt.Andptr[2] = 0x38
ctxt.Andptr = ctxt.Andptr[3:]
case Pf2, /* xmm opcode escape */
Pf3:
ctxt.Andptr[0] = byte(o.prefix)
......
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