From patchwork Wed Aug 21 17:29:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 11107821 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EE2EF14DE for ; Wed, 21 Aug 2019 18:10:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C633522D6D for ; Wed, 21 Aug 2019 18:10:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cQQ1ZVTc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C633522D6D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:51548 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0V4S-0004y1-ES for patchwork-qemu-devel@patchwork.kernel.org; Wed, 21 Aug 2019 14:10:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41013) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i0URL-0001E1-3V for qemu-devel@nongnu.org; Wed, 21 Aug 2019 13:30:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i0URJ-0007b1-PD for qemu-devel@nongnu.org; Wed, 21 Aug 2019 13:30:30 -0400 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]:39258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i0URJ-0007ZQ-L2 for qemu-devel@nongnu.org; Wed, 21 Aug 2019 13:30:29 -0400 Received: by mail-yb1-xb41.google.com with SMTP id s142so1341277ybc.6 for ; Wed, 21 Aug 2019 10:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hFsqTxXX8rsrnf3xHudaOJA2J0Kvvq2y/vZUzrj1f20=; b=cQQ1ZVTcTBv8Uj6li4mk6ryBIR5zQQgliyaoqbyowP5pn9LBxc3agOclMK7x9C6PeD yCdPEbCZmkery0Zhv+zSj3rTWxgInPchZOyMpZjFwACidgLpcoWmV5zA4vnEzgIMDJ/h axg9HwbOwS9AO1QsFXxtbFo16+G8rbWXv1eVxjsxe1VeI2DpXUs6pO2mzChwgYjpU026 gS/0K8K9mhsle0voO+e1DaK/KrvDbPw3LUxVYXTcCoYByddbidA8S7K2Rny7DcM2/6AJ HtkYba53xXI19W9RwcSluppljL1pzIHpzeQXdy5MdYBJZHeSPq4mUxQJTR7/HZxPCAz9 f1sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hFsqTxXX8rsrnf3xHudaOJA2J0Kvvq2y/vZUzrj1f20=; b=lAQukZTKuVJpwkPCnVEtDWJ0LWGTS5AkKJp5AaUqaZX4YAcFkSxdBhFP2QL9WVBSdb 7r6P3jxQRzOw/CLsPwqH1Q7BSPIamRlEeixlD9PDoSoiBUighKNVle/dIZd6yc7QxJ29 nAozX9wbL65KUdmbWxobu86KpN48A/ybfV6oCFNmWlMkQ1HOUmhsSZ8cMqJCuWEZbP6g ZDsaDIEWpeeTK0Y6cZGIPtz/imunx/lfg0C6xms8nAoXifb+rmTUblAkEhsuu3zOpzYi ulKUDghLSibsI/uhcAyxf9ribpo1iU821cWUbzlXKJLpGwr4l8yFiMrgzM+bI+3vXxHl diZw== X-Gm-Message-State: APjAAAVQQhenk62j6uiFpMMfoN7i90Y1ydu/RJQqalGfGJfzc+nzOvV+ /OekY8PuDiRpU0WMESFCJIm1dQiJ X-Google-Smtp-Source: APXvYqxmjOtU0//ZaXx+NhkHAhUPbeWbu2XjIlc1QD4mkVt6rUh5ZjYZkDKh2Po4fxjLxcuGZpkmmg== X-Received: by 2002:a25:76ca:: with SMTP id r193mr26498443ybc.33.1566408628987; Wed, 21 Aug 2019 10:30:28 -0700 (PDT) Received: from localhost.localdomain ([2601:c0:c67f:e390::3]) by smtp.gmail.com with ESMTPSA id l71sm2826167ywl.39.2019.08.21.10.30.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Aug 2019 10:30:28 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Wed, 21 Aug 2019 13:29:04 -0400 Message-Id: <20190821172951.15333-29-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190821172951.15333-1-jan.bobek@gmail.com> References: <20190821172951.15333-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b41 Subject: [Qemu-devel] [RFC PATCH v4 28/75] target/i386: introduce P*, N*, Q* (MMX) operands X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" These address the MMX-technology register file; the corresponding cpu_env offset is passed as the operand value. Notably, offset of the entire register is pased at all times, regardless of the operand-size suffix. Signed-off-by: Jan Bobek --- target/i386/translate.c | 80 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/target/i386/translate.c b/target/i386/translate.c index d6d32c7f06..815354f12b 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -5032,6 +5032,86 @@ INSNOP_LDST(tcg_i64, Mq) } } +/* + * MMX-technology register operands + */ +typedef unsigned int insnop_arg_t(mm); +typedef struct {} insnop_ctxt_t(mm); + +INSNOP_INIT(mm) +{ + return true; +} +INSNOP_PREPARE(mm) +{ + return offsetof(CPUX86State, mmx_t0); +} +INSNOP_FINALIZE(mm) +{ +} + +#define DEF_INSNOP_MM(opT, opTmmid) \ + typedef insnop_arg_t(mm) insnop_arg_t(opT); \ + typedef struct { \ + insnop_ctxt_t(opTmmid) mmid; \ + } insnop_ctxt_t(opT); \ + \ + INSNOP_INIT(opT) \ + { \ + return insnop_init(opTmmid)(&ctxt->mmid, env, s, modrm, is_write); \ + } \ + INSNOP_PREPARE(opT) \ + { \ + const insnop_arg_t(opTmmid) mmid = \ + insnop_prepare(opTmmid)(&ctxt->mmid, env, s, modrm, is_write); \ + const insnop_arg_t(opT) arg = \ + offsetof(CPUX86State, fpregs[mmid & 7].mmx); \ + insnop_finalize(opTmmid)(&ctxt->mmid, env, s, modrm, is_write, mmid); \ + return arg; \ + } \ + INSNOP_FINALIZE(opT) \ + { \ + } + +DEF_INSNOP_MM(P, modrm_reg) +DEF_INSNOP_ALIAS(Pq, P) + +DEF_INSNOP_MM(N, modrm_rm_direct) +DEF_INSNOP_ALIAS(Nd, N) +DEF_INSNOP_ALIAS(Nq, N) + +DEF_INSNOP_LDST(MQd, mm, Md) +DEF_INSNOP_LDST(MQq, mm, Mq) +DEF_INSNOP_EITHER(Qd, Nd, MQd) +DEF_INSNOP_EITHER(Qq, Nq, MQq) + +INSNOP_LDST(mm, Md) +{ + const insnop_arg_t(mm) ofs = offsetof(MMXReg, MMX_L(0)); + const TCGv_i32 r32 = tcg_temp_new_i32(); + if (is_write) { + tcg_gen_ld_i32(r32, cpu_env, arg + ofs); + tcg_gen_qemu_st_i32(r32, ptr, s->mem_index, MO_LEUL); + } else { + tcg_gen_qemu_ld_i32(r32, ptr, s->mem_index, MO_LEUL); + tcg_gen_st_i32(r32, cpu_env, arg + ofs); + } + tcg_temp_free_i32(r32); +} +INSNOP_LDST(mm, Mq) +{ + const insnop_arg_t(mm) ofs = offsetof(MMXReg, MMX_Q(0)); + const TCGv_i64 r64 = tcg_temp_new_i64(); + if (is_write) { + tcg_gen_ld_i64(r64, cpu_env, arg + ofs); + tcg_gen_qemu_st_i64(r64, ptr, s->mem_index, MO_LEQ); + } else { + tcg_gen_qemu_ld_i64(r64, ptr, s->mem_index, MO_LEQ); + tcg_gen_st_i64(r64, cpu_env, arg + ofs); + } + tcg_temp_free_i64(r64); +} + static void gen_sse_ng(CPUX86State *env, DisasContext *s, int b) { enum {