2008-01-29 20:37:37 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2011-02-25 00:54:04 +03:00
|
|
|
// $Id$
|
2008-01-29 20:37:37 +03:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2012-08-05 17:52:40 +04:00
|
|
|
// Copyright (c) 2008-2012 Stanislav Shwartsman
|
2008-01-29 20:37:37 +03:00
|
|
|
// Written by Stanislav Shwartsman [sshwarts at sourceforge net]
|
|
|
|
//
|
|
|
|
// This library is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation; either
|
|
|
|
// version 2 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
2009-01-16 21:18:59 +03:00
|
|
|
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA B 02110-1301 USA
|
2008-01-29 20:37:37 +03:00
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef BX_INSTR_H
|
2009-11-04 18:48:28 +03:00
|
|
|
#define BX_INSTR_H
|
2008-01-29 20:37:37 +03:00
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
class bxInstruction_c;
|
|
|
|
|
2011-07-07 00:01:18 +04:00
|
|
|
typedef void BX_INSF_TYPE;
|
|
|
|
|
2011-09-06 19:35:39 +04:00
|
|
|
#if BX_SUPPORT_HANDLERS_CHAINING_SPEEDUPS
|
|
|
|
|
2011-09-13 21:55:36 +04:00
|
|
|
#define BX_SYNC_TIME_IF_SINGLE_PROCESSOR(allowed_delta) { \
|
|
|
|
if (BX_SMP_PROCESSORS == 1) { \
|
2012-04-06 13:41:58 +04:00
|
|
|
Bit32u delta = BX_CPU_THIS_PTR icount - BX_CPU_THIS_PTR icount_last_sync; \
|
|
|
|
if (delta >= allowed_delta) { \
|
2012-08-28 20:05:39 +04:00
|
|
|
BX_CPU_THIS_PTR sync_icount(); \
|
2011-09-13 21:55:36 +04:00
|
|
|
BX_TICKN(delta); \
|
|
|
|
} \
|
|
|
|
} \
|
2011-09-06 19:35:39 +04:00
|
|
|
}
|
2011-08-21 18:38:33 +04:00
|
|
|
|
2011-09-05 21:14:49 +04:00
|
|
|
#define BX_COMMIT_INSTRUCTION(i) { \
|
2011-08-21 18:31:08 +04:00
|
|
|
BX_CPU_THIS_PTR prev_rip = RIP; /* commit new RIP */ \
|
2011-09-05 21:14:49 +04:00
|
|
|
BX_INSTR_AFTER_EXECUTION(BX_CPU_ID, (i)); \
|
2011-09-13 21:55:36 +04:00
|
|
|
BX_CPU_THIS_PTR icount++; \
|
2011-09-05 21:14:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define BX_EXECUTE_INSTRUCTION(i) { \
|
|
|
|
BX_INSTR_BEFORE_EXECUTION(BX_CPU_ID, (i)); \
|
|
|
|
RIP += (i)->ilen(); \
|
2012-09-04 19:45:05 +04:00
|
|
|
return BX_CPU_CALL_METHOD(i->execute1, (i)); \
|
2011-09-05 21:14:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define BX_NEXT_TRACE(i) { \
|
|
|
|
BX_COMMIT_INSTRUCTION(i); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
2012-08-21 23:58:41 +04:00
|
|
|
#define BX_LINK_TRACE(i) { \
|
|
|
|
BX_COMMIT_INSTRUCTION(i); \
|
|
|
|
linkTrace(i); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:14:49 +04:00
|
|
|
#define BX_NEXT_INSTR(i) { \
|
|
|
|
BX_COMMIT_INSTRUCTION(i); \
|
2011-08-21 18:31:08 +04:00
|
|
|
if (BX_CPU_THIS_PTR async_event) return; \
|
|
|
|
++i; \
|
2011-09-05 21:14:49 +04:00
|
|
|
BX_EXECUTE_INSTRUCTION(i); \
|
2011-08-21 18:31:08 +04:00
|
|
|
}
|
|
|
|
|
2011-09-13 21:55:36 +04:00
|
|
|
#else // BX_SUPPORT_HANDLERS_CHAINING_SPEEDUPS
|
2011-08-21 18:38:33 +04:00
|
|
|
|
2011-09-05 21:14:49 +04:00
|
|
|
#define BX_NEXT_TRACE(i) { return; }
|
2011-08-21 18:38:33 +04:00
|
|
|
#define BX_NEXT_INSTR(i) { return; }
|
2012-08-21 23:58:41 +04:00
|
|
|
#define BX_LINK_TRACE(i) { return; }
|
2011-08-21 18:38:33 +04:00
|
|
|
|
2011-09-13 21:55:36 +04:00
|
|
|
#define BX_SYNC_TIME_IF_SINGLE_PROCESSOR(allowed_delta) \
|
2011-09-06 19:35:39 +04:00
|
|
|
if (BX_SMP_PROCESSORS == 1) BX_TICK1()
|
|
|
|
|
2011-08-21 18:38:33 +04:00
|
|
|
#endif
|
2011-07-07 00:01:18 +04:00
|
|
|
|
2008-03-23 00:29:41 +03:00
|
|
|
// <TAG-TYPE-EXECUTEPTR-START>
|
|
|
|
#if BX_USE_CPU_SMF
|
2011-07-07 00:01:18 +04:00
|
|
|
typedef BX_INSF_TYPE (BX_CPP_AttrRegparmN(1) *BxExecutePtr_tR)(bxInstruction_c *);
|
2008-08-08 13:22:49 +04:00
|
|
|
typedef bx_address (BX_CPP_AttrRegparmN(1) *BxResolvePtr_tR)(bxInstruction_c *);
|
2011-07-07 00:01:18 +04:00
|
|
|
typedef void (BX_CPP_AttrRegparmN(1) *BxRepIterationPtr_tR)(bxInstruction_c *);
|
2008-03-23 00:29:41 +03:00
|
|
|
#else
|
2011-07-07 00:01:18 +04:00
|
|
|
typedef BX_INSF_TYPE (BX_CPU_C::*BxExecutePtr_tR)(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
2008-08-08 13:22:49 +04:00
|
|
|
typedef bx_address (BX_CPU_C::*BxResolvePtr_tR)(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
2011-07-07 00:01:18 +04:00
|
|
|
typedef void (BX_CPU_C::*BxRepIterationPtr_tR)(bxInstruction_c *) BX_CPP_AttrRegparmN(1);
|
2008-03-23 00:29:41 +03:00
|
|
|
#endif
|
|
|
|
// <TAG-TYPE-EXECUTEPTR-END>
|
|
|
|
|
2010-10-19 02:19:45 +04:00
|
|
|
extern bx_address bx_asize_mask[];
|
|
|
|
|
2011-03-26 02:06:34 +03:00
|
|
|
const char *get_bx_opcode_name(Bit16u ia_opcode);
|
|
|
|
|
2008-01-29 20:37:37 +03:00
|
|
|
// <TAG-CLASS-INSTRUCTION-START>
|
|
|
|
class bxInstruction_c {
|
|
|
|
public:
|
|
|
|
// Function pointers; a function to resolve the modRM address
|
|
|
|
// given the current state of the CPU and the instruction data,
|
|
|
|
// and a function to execute the instruction after resolving
|
|
|
|
// the memory address (if any).
|
2012-09-04 19:45:05 +04:00
|
|
|
BxExecutePtr_tR execute1;
|
2012-08-21 23:58:41 +04:00
|
|
|
|
|
|
|
union {
|
|
|
|
BxExecutePtr_tR execute2;
|
|
|
|
bxInstruction_c *next;
|
|
|
|
} handlers;
|
|
|
|
|
2008-10-11 00:49:16 +04:00
|
|
|
BxResolvePtr_tR ResolveModrm;
|
2008-01-29 20:37:37 +03:00
|
|
|
|
|
|
|
struct {
|
2012-08-05 17:52:40 +04:00
|
|
|
// 15...0 opcode
|
2010-01-09 18:11:32 +03:00
|
|
|
Bit16u ia_opcode;
|
2008-01-29 20:37:37 +03:00
|
|
|
|
2008-04-05 21:51:55 +04:00
|
|
|
// 7...4 (unused)
|
|
|
|
// 3...0 ilen (0..15)
|
2010-09-24 00:38:02 +04:00
|
|
|
Bit8u ilen;
|
2008-01-29 20:37:37 +03:00
|
|
|
|
2012-08-05 17:52:40 +04:00
|
|
|
// 7...6 VEX Vector Length (0=no VL, 1=128 bit, 2=256 bit)
|
|
|
|
// repUsed (0=none, 2=0xF2, 3=0xF3)
|
2010-10-19 02:19:45 +04:00
|
|
|
// 5...5 extend8bit
|
|
|
|
// 4...4 mod==c0 (modrm)
|
|
|
|
// 3...3 os64
|
|
|
|
// 2...2 os32
|
|
|
|
// 1...1 as64
|
|
|
|
// 0...0 as32
|
2008-04-05 21:51:55 +04:00
|
|
|
Bit8u metaInfo1;
|
2008-01-29 20:37:37 +03:00
|
|
|
} metaInfo;
|
|
|
|
|
2012-08-05 17:52:40 +04:00
|
|
|
#define BX_INSTR_METADATA_DST 0
|
|
|
|
#define BX_INSTR_METADATA_SRC1 1
|
|
|
|
#define BX_INSTR_METADATA_SRC2 2
|
|
|
|
#define BX_INSTR_METADATA_SRC3 3
|
|
|
|
#define BX_INSTR_METADATA_SEG 4
|
|
|
|
#define BX_INSTR_METADATA_BASE 5
|
|
|
|
#define BX_INSTR_METADATA_INDEX 6
|
|
|
|
#define BX_INSTR_METADATA_SCALE 7
|
2008-02-05 00:28:53 +03:00
|
|
|
|
2008-03-31 21:33:34 +04:00
|
|
|
// using 5-bit field for registers (16 regs in 64-bit, RIP, NIL)
|
|
|
|
Bit8u metaData[8];
|
2008-01-29 20:37:37 +03:00
|
|
|
|
|
|
|
union {
|
|
|
|
// Form (longest case): [opcode+modrm+sib/displacement32/immediate32]
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
Bit32u Id;
|
|
|
|
Bit16u Iw;
|
|
|
|
Bit8u Ib;
|
|
|
|
};
|
|
|
|
union {
|
|
|
|
Bit16u displ16u; // for 16-bit modrm forms
|
|
|
|
Bit32u displ32u; // for 32-bit modrm forms
|
|
|
|
|
2012-08-19 22:44:08 +04:00
|
|
|
Bit32u Id2;
|
2008-01-29 20:37:37 +03:00
|
|
|
Bit16u Iw2;
|
|
|
|
Bit8u Ib2;
|
|
|
|
};
|
2010-09-25 13:55:40 +04:00
|
|
|
} modRMForm;
|
2008-01-29 20:37:37 +03:00
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
|
|
|
struct {
|
|
|
|
Bit64u Iq; // for MOV Rx,imm64
|
|
|
|
} IqForm;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2011-07-23 23:58:38 +04:00
|
|
|
#ifdef BX_INSTR_STORE_OPCODE_BYTES
|
|
|
|
Bit8u opcode_bytes[16];
|
|
|
|
|
|
|
|
BX_CPP_INLINE const Bit8u* get_opcode_bytes(void) const {
|
|
|
|
return opcode_bytes;
|
|
|
|
}
|
|
|
|
|
|
|
|
BX_CPP_INLINE void set_opcode_bytes(const Bit8u *opcode) {
|
|
|
|
memcpy(opcode_bytes, opcode, ilen());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-21 23:58:41 +04:00
|
|
|
BX_CPP_INLINE BxExecutePtr_tR execute2(void) const {
|
|
|
|
return handlers.execute2;
|
|
|
|
}
|
|
|
|
|
2010-01-09 18:11:32 +03:00
|
|
|
BX_CPP_INLINE unsigned seg(void) const {
|
|
|
|
return metaData[BX_INSTR_METADATA_SEG];
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
2010-01-09 18:11:32 +03:00
|
|
|
BX_CPP_INLINE void setSeg(unsigned val) {
|
|
|
|
metaData[BX_INSTR_METADATA_SEG] = val;
|
|
|
|
}
|
|
|
|
|
2012-05-11 10:35:16 +04:00
|
|
|
BX_CPP_INLINE void setFoo(unsigned foo) {
|
2011-09-20 10:02:27 +04:00
|
|
|
// none of x87 instructions has immediate
|
2012-05-11 10:35:16 +04:00
|
|
|
modRMForm.Iw = foo;
|
|
|
|
}
|
|
|
|
BX_CPP_INLINE unsigned foo() const {
|
|
|
|
return modRMForm.Iw;
|
2008-03-31 21:33:34 +04:00
|
|
|
}
|
2012-05-11 10:35:16 +04:00
|
|
|
BX_CPP_INLINE unsigned b1() const {
|
|
|
|
return modRMForm.Iw >> 8;
|
2008-03-31 21:33:34 +04:00
|
|
|
}
|
2012-05-11 10:35:16 +04:00
|
|
|
|
2008-02-05 00:28:53 +03:00
|
|
|
BX_CPP_INLINE void setSibScale(unsigned scale) {
|
2008-03-31 21:33:34 +04:00
|
|
|
metaData[BX_INSTR_METADATA_SCALE] = scale;
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned sibScale() const {
|
2008-03-31 21:33:34 +04:00
|
|
|
return metaData[BX_INSTR_METADATA_SCALE];
|
2008-02-05 00:28:53 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void setSibIndex(unsigned index) {
|
2008-03-31 21:33:34 +04:00
|
|
|
metaData[BX_INSTR_METADATA_INDEX] = index;
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned sibIndex() const {
|
2008-03-31 21:33:34 +04:00
|
|
|
return metaData[BX_INSTR_METADATA_INDEX];
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
2008-01-30 01:26:29 +03:00
|
|
|
BX_CPP_INLINE void setSibBase(unsigned base) {
|
2008-03-31 21:33:34 +04:00
|
|
|
metaData[BX_INSTR_METADATA_BASE] = base;
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned sibBase() const {
|
2008-03-31 21:33:34 +04:00
|
|
|
return metaData[BX_INSTR_METADATA_BASE];
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
2009-01-12 23:14:37 +03:00
|
|
|
BX_CPP_INLINE Bit32s displ32s() const { return (Bit32s) modRMForm.displ32u; }
|
|
|
|
BX_CPP_INLINE Bit16s displ16s() const { return (Bit16s) modRMForm.displ16u; }
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE Bit32u Id() const { return modRMForm.Id; }
|
|
|
|
BX_CPP_INLINE Bit16u Iw() const { return modRMForm.Iw; }
|
|
|
|
BX_CPP_INLINE Bit8u Ib() const { return modRMForm.Ib; }
|
2012-08-28 20:05:39 +04:00
|
|
|
BX_CPP_INLINE Bit16u Id2() const { return modRMForm.Id2; }
|
2010-09-25 13:55:40 +04:00
|
|
|
BX_CPP_INLINE Bit16u Iw2() const { return modRMForm.Iw2; }
|
|
|
|
BX_CPP_INLINE Bit8u Ib2() const { return modRMForm.Ib2; }
|
2008-01-29 20:37:37 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE Bit64u Iq() const { return IqForm.Iq; }
|
2008-01-29 20:37:37 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Info in the metaInfo field.
|
|
|
|
// Note: the 'L' at the end of certain flags, means the value returned
|
|
|
|
// is for Logical comparisons, eg if (i->os32L() && i->as32L()). If you
|
|
|
|
// want a bx_bool value, use os32B() etc. This makes for smaller
|
|
|
|
// code, when a strict 0 or 1 is not necessary.
|
2008-02-05 00:28:53 +03:00
|
|
|
BX_CPP_INLINE void init(unsigned os32, unsigned as32, unsigned os64, unsigned as64)
|
2008-01-29 20:37:37 +03:00
|
|
|
{
|
2012-08-05 17:52:40 +04:00
|
|
|
metaInfo.metaInfo1 = (os32<<2) | (os64<<3) | (as32<<0) | (as64<<1); // VL = 0
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned os32L(void) const {
|
2010-10-19 02:19:45 +04:00
|
|
|
return metaInfo.metaInfo1 & (1<<2);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void setOs32B(unsigned bit) {
|
2010-10-19 02:19:45 +04:00
|
|
|
metaInfo.metaInfo1 = (metaInfo.metaInfo1 & ~(1<<2)) | (bit<<2);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void assertOs32(void) {
|
2010-10-19 02:19:45 +04:00
|
|
|
metaInfo.metaInfo1 |= (1<<2);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#if BX_SUPPORT_X86_64
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned os64L(void) const {
|
2010-10-19 02:19:45 +04:00
|
|
|
return metaInfo.metaInfo1 & (1<<3);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void assertOs64(void) {
|
2010-10-19 02:19:45 +04:00
|
|
|
metaInfo.metaInfo1 |= (1<<3);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
#else
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned os64L(void) const { return 0; }
|
2008-01-29 20:37:37 +03:00
|
|
|
#endif
|
|
|
|
|
2010-10-19 02:19:45 +04:00
|
|
|
|
|
|
|
BX_CPP_INLINE unsigned as32L(void) const {
|
|
|
|
return metaInfo.metaInfo1 & 0x1;
|
|
|
|
}
|
|
|
|
BX_CPP_INLINE void setAs32B(unsigned bit) {
|
|
|
|
metaInfo.metaInfo1 = (metaInfo.metaInfo1 & ~0x1) | (bit);
|
|
|
|
}
|
|
|
|
|
2008-01-29 20:37:37 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned as64L(void) const {
|
2010-10-19 02:19:45 +04:00
|
|
|
return metaInfo.metaInfo1 & (1<<1);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
2010-10-19 02:19:45 +04:00
|
|
|
BX_CPP_INLINE void clearAs64(void) {
|
|
|
|
metaInfo.metaInfo1 &= ~(1<<1);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
#else
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned as64L(void) const { return 0; }
|
2008-01-29 20:37:37 +03:00
|
|
|
#endif
|
|
|
|
|
2010-10-19 02:19:45 +04:00
|
|
|
BX_CPP_INLINE unsigned asize(void) const {
|
|
|
|
return metaInfo.metaInfo1 & 0x3;
|
|
|
|
}
|
|
|
|
BX_CPP_INLINE bx_address asize_mask(void) const {
|
|
|
|
return bx_asize_mask[asize()];
|
|
|
|
}
|
|
|
|
|
2008-01-29 20:37:37 +03:00
|
|
|
#if BX_SUPPORT_X86_64
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned extend8bitL(void) const {
|
2010-10-19 02:19:45 +04:00
|
|
|
return metaInfo.metaInfo1 & (1<<5);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void assertExtend8bit(void) {
|
2010-10-19 02:19:45 +04:00
|
|
|
metaInfo.metaInfo1 |= (1<<5);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned ilen(void) const {
|
2010-09-24 00:38:02 +04:00
|
|
|
return metaInfo.ilen;
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void setILen(unsigned ilen) {
|
2010-09-24 00:38:02 +04:00
|
|
|
metaInfo.ilen = ilen;
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
|
2010-01-09 18:11:32 +03:00
|
|
|
BX_CPP_INLINE unsigned getIaOpcode(void) const {
|
2012-05-11 10:35:16 +04:00
|
|
|
return metaInfo.ia_opcode;
|
2010-01-09 18:11:32 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void setIaOpcode(Bit16u op) {
|
2012-05-11 10:35:16 +04:00
|
|
|
metaInfo.ia_opcode = op;
|
2010-01-09 18:11:32 +03:00
|
|
|
}
|
2011-03-26 02:06:34 +03:00
|
|
|
BX_CPP_INLINE const char* getIaOpcodeName(void) const {
|
|
|
|
return get_bx_opcode_name(getIaOpcode());
|
|
|
|
}
|
2010-01-09 18:11:32 +03:00
|
|
|
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned repUsedL(void) const {
|
2010-10-19 02:19:45 +04:00
|
|
|
return metaInfo.metaInfo1 >> 6;
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
2008-07-13 13:59:59 +04:00
|
|
|
BX_CPP_INLINE unsigned repUsedValue(void) const {
|
2010-10-19 02:19:45 +04:00
|
|
|
return metaInfo.metaInfo1 >> 6;
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void setRepUsed(unsigned value) {
|
2010-10-19 02:19:45 +04:00
|
|
|
metaInfo.metaInfo1 = (metaInfo.metaInfo1 & 0x3f) | (value << 6);
|
2008-01-29 20:37:37 +03:00
|
|
|
}
|
|
|
|
|
2011-03-19 23:09:34 +03:00
|
|
|
BX_CPP_INLINE unsigned getVL(void) const {
|
2011-06-11 16:22:54 +04:00
|
|
|
#if BX_SUPPORT_AVX
|
2012-08-05 17:52:40 +04:00
|
|
|
return metaInfo.metaInfo1 >> 6;
|
2011-06-11 16:22:54 +04:00
|
|
|
#else
|
2011-06-12 00:12:15 +04:00
|
|
|
return 0;
|
2011-06-11 16:22:54 +04:00
|
|
|
#endif
|
2011-03-19 23:09:34 +03:00
|
|
|
}
|
|
|
|
BX_CPP_INLINE void setVL(unsigned value) {
|
2012-08-05 17:52:40 +04:00
|
|
|
metaInfo.metaInfo1 = (metaInfo.metaInfo1 & 0x3f) | (value << 6);
|
2011-03-19 23:09:34 +03:00
|
|
|
}
|
|
|
|
|
2012-08-05 17:52:40 +04:00
|
|
|
BX_CPP_INLINE void setSrcReg(unsigned src, unsigned reg) {
|
|
|
|
metaData[src] = reg;
|
2011-10-20 00:54:04 +04:00
|
|
|
}
|
2012-08-05 17:52:40 +04:00
|
|
|
|
|
|
|
BX_CPP_INLINE unsigned dst() const {
|
|
|
|
return metaData[BX_INSTR_METADATA_DST];
|
2011-10-20 00:54:04 +04:00
|
|
|
}
|
2012-08-05 17:52:40 +04:00
|
|
|
|
|
|
|
BX_CPP_INLINE unsigned src1() const {
|
|
|
|
return metaData[BX_INSTR_METADATA_SRC1];
|
2011-10-20 00:54:04 +04:00
|
|
|
}
|
2012-08-05 17:52:40 +04:00
|
|
|
BX_CPP_INLINE unsigned src2() const {
|
|
|
|
return metaData[BX_INSTR_METADATA_SRC2];
|
2011-03-19 23:09:34 +03:00
|
|
|
}
|
2012-08-05 17:52:40 +04:00
|
|
|
BX_CPP_INLINE unsigned src3() const {
|
|
|
|
return metaData[BX_INSTR_METADATA_SRC3];
|
2011-03-19 23:09:34 +03:00
|
|
|
}
|
|
|
|
|
2012-08-05 17:52:40 +04:00
|
|
|
BX_CPP_INLINE unsigned src() const { return src1(); }
|
|
|
|
|
2010-01-09 18:11:32 +03:00
|
|
|
BX_CPP_INLINE unsigned modC0() const
|
|
|
|
{
|
|
|
|
// This is a cheaper way to test for modRM instructions where
|
|
|
|
// the mod field is 0xc0. FetchDecode flags this condition since
|
|
|
|
// it is quite common to be tested for.
|
2010-10-19 02:19:45 +04:00
|
|
|
return metaInfo.metaInfo1 & (1<<4);
|
2008-04-05 21:51:55 +04:00
|
|
|
}
|
2011-08-28 00:09:18 +04:00
|
|
|
BX_CPP_INLINE void assertModC0()
|
2010-01-09 18:11:32 +03:00
|
|
|
{
|
2011-08-28 00:09:18 +04:00
|
|
|
metaInfo.metaInfo1 |= (1<<4);
|
2012-08-19 22:44:08 +04:00
|
|
|
}
|
|
|
|
|
2012-08-21 23:58:41 +04:00
|
|
|
#if BX_SUPPORT_HANDLERS_CHAINING_SPEEDUPS
|
|
|
|
BX_CPP_INLINE bxInstruction_c* getNextTrace() const {
|
|
|
|
return handlers.next;
|
|
|
|
}
|
|
|
|
BX_CPP_INLINE void setNextTrace(bxInstruction_c* iptr) {
|
|
|
|
handlers.next = iptr;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-08-19 22:44:08 +04:00
|
|
|
};
|
2008-01-29 20:37:37 +03:00
|
|
|
// <TAG-CLASS-INSTRUCTION-END>
|
|
|
|
|
2009-11-04 18:48:28 +03:00
|
|
|
enum {
|
2012-08-05 17:52:40 +04:00
|
|
|
#define bx_define_opcode(a, b, c, d, s1, s2, s3, s4, e) a,
|
2009-11-04 18:48:28 +03:00
|
|
|
#include "ia_opcodes.h"
|
|
|
|
BX_IA_LAST
|
|
|
|
};
|
|
|
|
#undef bx_define_opcode
|
|
|
|
|
2008-01-29 20:37:37 +03:00
|
|
|
#endif
|