1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:14:44 -07:00

libmach: support more 386/amd64 instructions

R=golang-dev, dave, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/10030043
This commit is contained in:
Anthony Martin 2013-07-20 00:38:26 -07:00
parent cae5213b91
commit 87976e72a8

View File

@ -480,7 +480,14 @@ static Optable optab0FAE[8]=
[0x07] = { 0,0, "SFENCE" }, [0x07] = { 0,0, "SFENCE" },
}; };
/* 0F18 */ static Optable optab0F18[4]=
{
[0x00] = { 0,0, "PREFETCHNTA %e" },
[0x01] = { 0,0, "PREFECTCH0 %e" },
[0x02] = { 0,0, "PREFECTCH1 %e" },
[0x03] = { 0,0, "PREFECTCH2 %e" },
};
/* 0F0D */ /* 0F0D */
static Optable optab0FBA[8]= static Optable optab0FBA[8]=
@ -523,6 +530,22 @@ static Optable optab0FC7[8]=
[0x01] = { 0,0, "CMPXCHG8B %e" }, [0x01] = { 0,0, "CMPXCHG8B %e" },
}; };
static Optable optab660F38[256]=
{
[0x00] = { RM,0, "PSHUFB %x,%X" },
[0xdc] = { RM,0, "AESENC %x,%X" },
[0xdb] = { RM,0, "AESIMC %x,%X," },
[0xdd] = { RM,0, "AESENCLAST %x,%X" },
[0xde] = { RM,0, "AESDEC %x,%X" },
[0xdf] = { RM,0, "AESDECLAST %x,%X" },
};
static Optable optab660F3A[256]=
{
[0x22] = { RM,Ib, "PINSR%S %i,%e,%X" },
[0xdf] = { RM,Ib, "AESKEYGENASSIST %i,%x,%X" },
};
static Optable optab660F71[8]= static Optable optab660F71[8]=
{ {
[0x02] = { Ib,0, "PSRLW %i,%X" }, [0x02] = { Ib,0, "PSRLW %i,%X" },
@ -550,6 +573,8 @@ static Optable optab660F[256]=
[0x2B] = { RM,0, "MOVNTPD %x,%e" }, [0x2B] = { RM,0, "MOVNTPD %x,%e" },
[0x2E] = { RM,0, "UCOMISD %x,%X" }, [0x2E] = { RM,0, "UCOMISD %x,%X" },
[0x2F] = { RM,0, "COMISD %x,%X" }, [0x2F] = { RM,0, "COMISD %x,%X" },
[0x38] = { AUX,0, optab660F38 },
[0x3A] = { AUX,0, optab660F3A },
[0x5A] = { RM,0, "CVTPD2PS %x,%X" }, [0x5A] = { RM,0, "CVTPD2PS %x,%X" },
[0x5B] = { RM,0, "CVTPS2PL %x,%X" }, [0x5B] = { RM,0, "CVTPS2PL %x,%X" },
[0x6A] = { RM,0, "PUNPCKHLQ %x,%X" }, [0x6A] = { RM,0, "PUNPCKHLQ %x,%X" },
@ -574,6 +599,12 @@ static Optable optab660F[256]=
[0xF7] = { RM,0, "MASKMOVOU %x,%X" }, [0xF7] = { RM,0, "MASKMOVOU %x,%X" },
}; };
static Optable optabF20F38[256]=
{
[0xf0] = { RM,0, "CRC32B %e, %r" },
[0xf1] = { RM,0, "CRC32%S %e, %r" },
};
static Optable optabF20F[256]= static Optable optabF20F[256]=
{ {
[0x10] = { RM,0, "MOVSD %x,%X" }, [0x10] = { RM,0, "MOVSD %x,%X" },
@ -581,6 +612,7 @@ static Optable optabF20F[256]=
[0x2A] = { RM,0, "CVTS%S2SD %e,%X" }, [0x2A] = { RM,0, "CVTS%S2SD %e,%X" },
[0x2C] = { RM,0, "CVTTSD2S%S %x,%r" }, [0x2C] = { RM,0, "CVTTSD2S%S %x,%r" },
[0x2D] = { RM,0, "CVTSD2S%S %x,%r" }, [0x2D] = { RM,0, "CVTSD2S%S %x,%r" },
[0x38] = { AUX,0, optabF20F38 },
[0x5A] = { RM,0, "CVTSD2SS %x,%X" }, [0x5A] = { RM,0, "CVTSD2SS %x,%X" },
[0x6F] = { RM,0, "MOVOU %x,%X" }, [0x6F] = { RM,0, "MOVOU %x,%X" },
[0x70] = { RM,Ib, "PSHUFLW %i,%x,%X" }, [0x70] = { RM,Ib, "PSHUFLW %i,%x,%X" },
@ -627,6 +659,7 @@ static Optable optab0F[256]=
[0x15] = { RM,0, "UNPCKH%s %x,%X" }, [0x15] = { RM,0, "UNPCKH%s %x,%X" },
[0x16] = { RM,0, "MOV[L]H%s %x,%X" }, /* TO DO: L if source is XMM */ [0x16] = { RM,0, "MOV[L]H%s %x,%X" }, /* TO DO: L if source is XMM */
[0x17] = { RM,0, "MOVH%s %X,%x" }, [0x17] = { RM,0, "MOVH%s %X,%x" },
[0x18] = { RMOP,0, optab0F18 },
[0x1F] = { RM,0, "NOP%S %e" }, [0x1F] = { RM,0, "NOP%S %e" },
[0x20] = { RMR,0, "MOVL %C,%e" }, [0x20] = { RMR,0, "MOVL %C,%e" },
[0x21] = { RMR,0, "MOVL %D,%e" }, [0x21] = { RMR,0, "MOVL %D,%e" },
@ -1863,14 +1896,23 @@ badop:
return 0; return 0;
obase = (Optable*)op->proto; obase = (Optable*)op->proto;
switch (ip->opre) { switch (ip->opre) {
case 0x66: op = optab660F; break; case 0x66:
case 0xF2: op = optabF20F; break; op = optab660F;
case 0xF3: op = optabF30F; break; break;
default: op = nil; break; case 0xF2:
op = optabF20F;
ip->prefix = 0; /* discard REPNE */
break;
case 0xF3:
op = optabF30F;
ip->prefix = 0; /* discard REP */
break;
default:
op = nil;
break;
} }
if(op != nil && op[c].proto != nil) if(op != nil && op[c].proto != nil)
obase = op; obase = op;
norex = 1; /* no more rex prefixes */
/* otherwise the optab entry captures it */ /* otherwise the optab entry captures it */
goto newop; goto newop;
case AUX: /* Multi-byte op code - Auxiliary table */ case AUX: /* Multi-byte op code - Auxiliary table */
@ -1885,8 +1927,6 @@ badop:
ip->prefix = (char*)op->proto; ip->prefix = (char*)op->proto;
if (igetc(map, ip, &c) < 0) if (igetc(map, ip, &c) < 0)
return 0; return 0;
if (ip->opre && c == 0x0F)
ip->prefix = 0;
goto newop; goto newop;
case SEG: /* Segment Prefix */ case SEG: /* Segment Prefix */
ip->segment = (char*)op->proto; ip->segment = (char*)op->proto;