From patchwork Thu Jul 5 21:29:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 9869 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 0E3AE23E4F for ; Thu, 5 Jul 2012 21:29:08 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id D27D8A180D3 for ; Thu, 5 Jul 2012 21:29:07 +0000 (UTC) Received: by mail-yw0-f52.google.com with SMTP id p61so9447433yhp.11 for ; Thu, 05 Jul 2012 14:29:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=nDtHXEAr0hChjVFOeZRljkBvMjJ/JowDsMC1yjqwXpk=; b=G3HePVuKucZroeexoHbLt5WW5N1MuVVhf8LUnC30O49qPf9wZ1d+YE879BWWui16kt C8TglBeLYnLiDekdOOOt97Xxd/RIT0M+h07v5e4tphNlQ0cw42ae1vu0CO/F3ThbTm8b cYKpQTpcgJYoBwvKm60D9bVrI1SfmwUNyfuK/9cG3pO8SHtFvaMrRxEem2Bq0LQfmUuN 3Cl2wvTY23F6GgW3Gdw3b4/y163lbiCnel4J9i+icGRYQuOxo53CwrF3YMyL89dgxiZV MrTSQrkkwKO4BHCXR1keRD+Du+63mCZrCUaaCzyubIRBZcoL215ES8SROYhOhQjba8tI wYQQ== Received: by 10.50.203.39 with SMTP id kn7mr868669igc.53.1341523747324; Thu, 05 Jul 2012 14:29:07 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp1079ibb; Thu, 5 Jul 2012 14:29:04 -0700 (PDT) Received: by 10.216.255.73 with SMTP id i51mr189650wes.46.1341523743646; Thu, 05 Jul 2012 14:29:03 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id ay5si2024663wib.22.2012.07.05.14.29.02 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 05 Jul 2012 14:29:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1Smtbh-0005uq-16; Thu, 05 Jul 2012 22:29:01 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Stefan Weil , Blue Swirl Subject: [PATCH 3/3] target-i386: make it clearer that op table accesses don't overrun Date: Thu, 5 Jul 2012 22:29:00 +0100 Message-Id: <1341523740-22711-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1341523740-22711-1-git-send-email-peter.maydell@linaro.org> References: <1341523740-22711-1-git-send-email-peter.maydell@linaro.org> X-Gm-Message-State: ALoCoQmjycIW9VU5im5PxoLUmprt29d3Yqvt/8EWk/ePQeEdeD27why4dYQwKGp+ndVheYYZ0zdO Rephrase some of the expressions used to select an entry in the SSE op table arrays so that it's clearer that they don't overrun the op table array size. Signed-off-by: Peter Maydell Reviewed-by: Stefan Weil --- target-i386/translate.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target-i386/translate.c b/target-i386/translate.c index 5899e09..1988dae 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -2964,16 +2964,16 @@ static const SSEFunc_0_pl sse_op_table3aq[] = { static const SSEFunc_i_p sse_op_table3bi[] = { gen_helper_cvttss2si, - gen_helper_cvttsd2si, gen_helper_cvtss2si, + gen_helper_cvttsd2si, gen_helper_cvtsd2si }; #ifdef TARGET_X86_64 static const SSEFunc_l_p sse_op_table3bq[] = { gen_helper_cvttss2sq, - gen_helper_cvttsd2sq, gen_helper_cvtss2sq, + gen_helper_cvttsd2sq, gen_helper_cvtsd2sq }; #endif @@ -3571,12 +3571,12 @@ static void gen_sse(DisasContext *s, int b, target_ulong pc_start, int rex_r) op1_offset = offsetof(CPUX86State,xmm_regs[reg]); tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op1_offset); if (ot == OT_LONG) { - SSEFunc_0_pi sse_fn_pi = sse_op_table3ai[(b >> 8) - 2]; + SSEFunc_0_pi sse_fn_pi = sse_op_table3ai[(b >> 8) & 1]; tcg_gen_trunc_tl_i32(cpu_tmp2_i32, cpu_T[0]); sse_fn_pi(cpu_ptr0, cpu_tmp2_i32); } else { #ifdef TARGET_X86_64 - SSEFunc_0_pl sse_fn_pl = sse_op_table3aq[(b >> 8) - 2]; + SSEFunc_0_pl sse_fn_pl = sse_op_table3aq[(b >> 8) & 1]; sse_fn_pl(cpu_ptr0, cpu_T[0]); #else goto illegal_op; @@ -3635,13 +3635,13 @@ static void gen_sse(DisasContext *s, int b, target_ulong pc_start, int rex_r) tcg_gen_addi_ptr(cpu_ptr0, cpu_env, op2_offset); if (ot == OT_LONG) { SSEFunc_i_p sse_fn_i_p = - sse_op_table3bi[(b >> 8) - 2 + (b & 1) * 2]; + sse_op_table3bi[((b >> 7) & 2) | (b & 1)]; sse_fn_i_p(cpu_tmp2_i32, cpu_ptr0); tcg_gen_extu_i32_tl(cpu_T[0], cpu_tmp2_i32); } else { #ifdef TARGET_X86_64 SSEFunc_l_p sse_fn_l_p = - sse_op_table3bq[(b >> 8) - 2 + (b & 1) * 2]; + sse_op_table3bq[((b >> 7) & 2) | (b & 1)]; sse_fn_l_p(cpu_T[0], cpu_ptr0); #else goto illegal_op;