KVM: x86 emulator: simplify ALU opcode block decode further

The ALU opcode block is very regular; introduce D6ALU() to define decode
flags for 6 instructions at a time.

Suggested by Paolo Bonzini.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
Avi Kivity 2010-08-26 18:34:55 +03:00
parent 217fc9cfca
commit 6230f7fc04
1 changed files with 14 additions and 18 deletions

View File

@ -2387,6 +2387,11 @@ static int em_rdtsc(struct x86_emulate_ctxt *ctxt)
#define D2bv(_f) D((_f) | ByteOp), D(_f) #define D2bv(_f) D((_f) | ByteOp), D(_f)
#define I2bv(_f, _e) I((_f) | ByteOp, _e), I(_f, _e) #define I2bv(_f, _e) I((_f) | ByteOp, _e), I(_f, _e)
#define D6ALU(_f) D2bv((_f) | DstMem | SrcReg | ModRM), \
D2bv(((_f) | DstReg | SrcMem | ModRM) & ~Lock), \
D2bv(((_f) & ~Lock) | DstAcc | SrcImm)
static struct opcode group1[] = { static struct opcode group1[] = {
X7(D(Lock)), N X7(D(Lock)), N
}; };
@ -2439,35 +2444,25 @@ static struct group_dual group9 = { {
static struct opcode opcode_table[256] = { static struct opcode opcode_table[256] = {
/* 0x00 - 0x07 */ /* 0x00 - 0x07 */
D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), D6ALU(Lock),
D2bv(DstAcc | SrcImm),
D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64),
/* 0x08 - 0x0F */ /* 0x08 - 0x0F */
D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), D6ALU(Lock),
D2bv(DstAcc | SrcImm),
D(ImplicitOps | Stack | No64), N, D(ImplicitOps | Stack | No64), N,
/* 0x10 - 0x17 */ /* 0x10 - 0x17 */
D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), D6ALU(Lock),
D2bv(DstAcc | SrcImm),
D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64),
/* 0x18 - 0x1F */ /* 0x18 - 0x1F */
D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), D6ALU(Lock),
D2bv(DstAcc | SrcImm),
D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64),
/* 0x20 - 0x27 */ /* 0x20 - 0x27 */
D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), D6ALU(Lock), N, N,
D2bv(DstAcc | SrcImm), N, N,
/* 0x28 - 0x2F */ /* 0x28 - 0x2F */
D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), D6ALU(Lock), N, I(ByteOp | DstAcc | No64, em_das),
D2bv(DstAcc | SrcImm),
N, I(ByteOp | DstAcc | No64, em_das),
/* 0x30 - 0x37 */ /* 0x30 - 0x37 */
D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), D6ALU(Lock), N, N,
D2bv(DstAcc | SrcImm), N, N,
/* 0x38 - 0x3F */ /* 0x38 - 0x3F */
D2bv(DstMem | SrcReg | ModRM), D2bv(DstReg | SrcMem | ModRM), D6ALU(0), N, N,
D2bv(DstAcc | SrcImm),
N, N,
/* 0x40 - 0x4F */ /* 0x40 - 0x4F */
X16(D(DstReg)), X16(D(DstReg)),
/* 0x50 - 0x57 */ /* 0x50 - 0x57 */
@ -2618,6 +2613,7 @@ static struct opcode twobyte_table[256] = {
#undef D2bv #undef D2bv
#undef I2bv #undef I2bv
#undef D6ALU
static unsigned imm_size(struct decode_cache *c) static unsigned imm_size(struct decode_cache *c)
{ {