diff mbox

[46/57] target-i386: Implement ANDN

Message ID 1359000221-19834-47-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson Jan. 24, 2013, 4:03 a.m. UTC
As this is the first of the BMI insns to be implemented,
this carries quite a bit more baggage than normal.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-i386/cpu.c       | 10 +++++-----
 target-i386/translate.c | 19 +++++++++++++++++--
 2 files changed, 22 insertions(+), 7 deletions(-)

Comments

Andreas Färber Jan. 24, 2013, 4:51 p.m. UTC | #1
Am 24.01.2013 05:03, schrieb Richard Henderson:
> As this is the first of the BMI insns to be implemented,
> this carries quite a bit more baggage than normal.
> 
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  target-i386/cpu.c       | 10 +++++-----
>  target-i386/translate.c | 19 +++++++++++++++++--
>  2 files changed, 22 insertions(+), 7 deletions(-)
> 
> diff --git a/target-i386/cpu.c b/target-i386/cpu.c
> index 776b670..30893b6 100644
> --- a/target-i386/cpu.c
> +++ b/target-i386/cpu.c
> @@ -399,12 +399,12 @@ typedef struct x86_def_t {
>  #define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM | \
>            CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A)
>  #define TCG_SVM_FEATURES 0
> -#define TCG_7_0_EBX_FEATURES (CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_SMAP)
> +#define TCG_7_0_EBX_FEATURES (CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_SMAP \
> +          CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_BMI2)
>            /* missing:
> -          CPUID_7_0_EBX_FSGSBASE, CPUID_7_0_EBX_BMI1, CPUID_7_0_EBX_HLE,
> -          CPUID_7_0_EBX_AVX2, CPUID_7_0_EBX_BMI2, CPUID_7_0_EBX_ERMS,
> -          CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM, CPUID_7_0_EBX_RDSEED,
> -          CPUID_7_0_EBX_ADX */
> +          CPUID_7_0_EBX_FSGSBASE, CPUID_7_0_EBX_HLE, CPUID_7_0_EBX_AVX2,
> +          CPUID_7_0_EBX_ERMS, CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM,
> +          CPUID_7_0_EBX_RDSEED, CPUID_7_0_EBX_ADX */
>  
>  /* maintains list of cpu model definitions
>   */

Note this will conflict with the upcoming 1.4 qom-cpu pull, which drops
the duplicate list built from the array.

Andreas
Richard Henderson Jan. 24, 2013, 4:53 p.m. UTC | #2
On 2013-01-24 08:51, Andreas Färber wrote:
> Note this will conflict with the upcoming 1.4 qom-cpu pull, which drops
> the duplicate list built from the array.

Ok, thanks for the heads-up.  I'll rebase as mainline changes.


r~
diff mbox

Patch

diff --git a/target-i386/cpu.c b/target-i386/cpu.c
index 776b670..30893b6 100644
--- a/target-i386/cpu.c
+++ b/target-i386/cpu.c
@@ -399,12 +399,12 @@  typedef struct x86_def_t {
 #define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM | \
           CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A)
 #define TCG_SVM_FEATURES 0
-#define TCG_7_0_EBX_FEATURES (CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_SMAP)
+#define TCG_7_0_EBX_FEATURES (CPUID_7_0_EBX_SMEP | CPUID_7_0_EBX_SMAP \
+          CPUID_7_0_EBX_BMI1 | CPUID_7_0_EBX_BMI2)
           /* missing:
-          CPUID_7_0_EBX_FSGSBASE, CPUID_7_0_EBX_BMI1, CPUID_7_0_EBX_HLE,
-          CPUID_7_0_EBX_AVX2, CPUID_7_0_EBX_BMI2, CPUID_7_0_EBX_ERMS,
-          CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM, CPUID_7_0_EBX_RDSEED,
-          CPUID_7_0_EBX_ADX */
+          CPUID_7_0_EBX_FSGSBASE, CPUID_7_0_EBX_HLE, CPUID_7_0_EBX_AVX2,
+          CPUID_7_0_EBX_ERMS, CPUID_7_0_EBX_INVPCID, CPUID_7_0_EBX_RTM,
+          CPUID_7_0_EBX_RDSEED, CPUID_7_0_EBX_ADX */
 
 /* maintains list of cpu model definitions
  */
diff --git a/target-i386/translate.c b/target-i386/translate.c
index cee6095..8e75cba 100644
--- a/target-i386/translate.c
+++ b/target-i386/translate.c
@@ -2960,8 +2960,9 @@  static const SSEFunc_0_epp sse_op_table1[256][4] = {
     [0xc6] = { (SSEFunc_0_epp)gen_helper_shufps,
                (SSEFunc_0_epp)gen_helper_shufpd }, /* XXX: casts */
 
-    [0x38] = { SSE_SPECIAL, SSE_SPECIAL, NULL, SSE_SPECIAL }, /* SSSE3/SSE4 */
-    [0x3a] = { SSE_SPECIAL, SSE_SPECIAL }, /* SSSE3/SSE4 */
+    /* SSSE3, SSE4, MOVBE, CRC32, BMI1, BMI2, ADX.  */
+    [0x38] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL },
+    [0x3a] = { SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL, SSE_SPECIAL },
 
     /* MMX ops and their SSE extensions */
     [0x60] = MMX_OP2(punpcklbw),
@@ -4016,6 +4017,20 @@  static void gen_sse(CPUX86State *env, DisasContext *s, int b,
                 }
                 break;
 
+            case 0x0f2: /* andn Gy, By, Ey */
+                if (!(s->cpuid_7_0_ebx_features & CPUID_7_0_EBX_BMI1)
+                    || !(s->prefix & PREFIX_VEX)
+                    || s->vex_l != 0) {
+                    goto illegal_op;
+                }
+                ot = s->dflag == 2 ? OT_QUAD : OT_LONG;
+                gen_ldst_modrm(env, s, modrm, ot, OR_TMP0, 0);
+                tcg_gen_andc_tl(cpu_T[0], cpu_regs[s->vex_v], cpu_T[0]);
+                gen_op_mov_reg_T0(ot, reg);
+                gen_op_update1_cc();
+                set_cc_op(s, CC_OP_LOGICB + ot);
+                break;
+
             default:
                 goto illegal_op;
             }