From patchwork Sun May 27 14:13:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 137012 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1785853lji; Sun, 27 May 2018 07:16:58 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKgDoSwk3DTmXyJXUT+I3hvJlrpt87hLEWYtGXEH9ixeQYuZIJJLlXFawWOjJJr/j/cfKPg X-Received: by 2002:a37:aaca:: with SMTP id t193-v6mr8547466qke.104.1527430618498; Sun, 27 May 2018 07:16:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527430618; cv=none; d=google.com; s=arc-20160816; b=EEl19MubODKzFq/RbpwYwwspcwPcu6Ha1ob+gKekJmrcV5JnBAVrlZ8c4yBTUqWi7n E5hTBMxxQN1LV1RY3JPZ5w6rsCAe4bZJZTnbkv+ft1wiKn38VUEjLE4pyfXaoQZba58E Q5oO7ohHGdZ4c8JhwRRLwN10IKfdQp+m3icg4RkBguLqGsmbCUVDCF3D1IG6/FohWp0H NQEGTH3wMgjlxS1w5DpO45Gu5Uwk5uLNfeHGRmdCYjgptIujKdhU8HOVfC3qzGibHfHe iV36hF1zk9RgcwSNlBOsbYZg7jENPSlVoyU9QUO3mjbyZWQgGoftP7JKrBQ85cxtY0qF ESAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=/0ZGkCb7Sjx7eXtRm4QaOBlfYw+yU8MW3fU4EH6sJQI=; b=JpI4/g9rlFrH1pLoFHBtHb9qXCtMhZD5JYU34PPKe91OiXBL643G1c53IwYrXNo+cj I7ju4KCF7tBRDr1enkf1e0Ca7X2PjYvS3cIa7ZM8UsBQ/8EWHd51/3qRsuph42YXRm4K Cb0fopsxxYvRz6n5kW6rnMB/UY9lPq8RWa6K1shx1bDGjAfyh50pcS0sFk9gSNBitd+w 8bM6Xc82DYVJ8eQNEwfzKt0GrwpzN6JjvowJ2927pXnyZ6ifXh0YYn6FZdzV1MWMsZLB 7PZkM4gKiE+KhU6etp8gqmkJJyMlrMwXGnwBQ2zo+vqq1vnfI2GG6UVIb4tziK1cX86n QRPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RFnoxHr0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b25-v6si859437qtb.276.2018.05.27.07.16.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 27 May 2018 07:16:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=RFnoxHr0; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:52216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMwTh-0002bo-CR for patch@linaro.org; Sun, 27 May 2018 10:16:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57741) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fMwQY-0008Uq-Q4 for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fMwQW-0004Og-Bk for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:42 -0400 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:38509) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fMwQW-0004OQ-5e for qemu-devel@nongnu.org; Sun, 27 May 2018 10:13:40 -0400 Received: by mail-pg0-x22a.google.com with SMTP id c9-v6so1370614pgf.5 for ; Sun, 27 May 2018 07:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/0ZGkCb7Sjx7eXtRm4QaOBlfYw+yU8MW3fU4EH6sJQI=; b=RFnoxHr0S6eJSj08w3hMFArFNwWFcR5EuuEpqKNQ3zkUeA4p0/5+JTl4fdDAuaDkzt 9KP89hRlrfA0mg4qT7yqEWVTpmSdTR1j8l7o249qZ15XohzjDENxDMrEi3+8WWatQ1Ws ISB1cpqpjFI+BLLXQqGPLxHONwNR+IlPilXZs= 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; bh=/0ZGkCb7Sjx7eXtRm4QaOBlfYw+yU8MW3fU4EH6sJQI=; b=ciUbXWwJVRSSdIxp/3vs1i0rr8Z3tGly5baZ6mFPNsiT4tRvTRydtiUCGPCQz5lUl6 Otzo840DLikShQiu6rqwSe2bro9aU2b6ye/GhCWuA59QBqwN1jLQ1elHR1yiTWUVnHie yCiz9WgvoS06bJcgoKODrNkErAVk5NiZH4x9WueHbiohauvdiZIyyx2I3+Nl/oQS+hQX 55rm7x2vtSdriVal2IlhAenvHSPw93m6mjf4FCq6aE+Zmz2KWvUVkc8aNASG7405wnYe zf6nY6iz9UQwgt0C7XsYrbmylT3LU+voVlq06/a8uBaFRO//cUyS3w4JpyaD8V/2W4xZ MNDA== X-Gm-Message-State: ALKqPwf6aZW44O82V6k+cAQs5NSt46EFbYTIrAcAx3fG+t0pVZdD+lsq 1pGj6fd6BmEXKsmBUGEyE1FBLTt/x7o= X-Received: by 2002:a65:665a:: with SMTP id z26-v6mr7501697pgv.302.1527430418867; Sun, 27 May 2018 07:13:38 -0700 (PDT) Received: from cloudburst.twiddle.net (50-233-235-3-static.hfc.comcastbusiness.net. [50.233.235.3]) by smtp.gmail.com with ESMTPSA id b89-v6sm66680075pfd.85.2018.05.27.07.13.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 27 May 2018 07:13:38 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 27 May 2018 09:13:11 -0500 Message-Id: <20180527141324.11937-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180527141324.11937-1-richard.henderson@linaro.org> References: <20180527141324.11937-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22a Subject: [Qemu-devel] [PATCH 07/20] target/openrisc: Form the spr index from tcg X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stafford Horne Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Rather than pass base+offset to the helper, pass the full index. In most cases the base is r0 and optimization yields a constant. Signed-off-by: Richard Henderson --- target/openrisc/helper.h | 4 ++-- target/openrisc/sys_helper.c | 9 +++------ target/openrisc/translate.c | 16 +++++++++------- 3 files changed, 14 insertions(+), 15 deletions(-) -- 2.17.0 Reviewed-by: Philippe Mathieu-Daudé diff --git a/target/openrisc/helper.h b/target/openrisc/helper.h index e37dabc77a..9db9bf3963 100644 --- a/target/openrisc/helper.h +++ b/target/openrisc/helper.h @@ -56,5 +56,5 @@ FOP_CMP(le) DEF_HELPER_FLAGS_1(rfe, 0, void, env) /* sys */ -DEF_HELPER_FLAGS_4(mtspr, 0, void, env, tl, tl, tl) -DEF_HELPER_FLAGS_4(mfspr, TCG_CALL_NO_WG, tl, env, tl, tl, tl) +DEF_HELPER_FLAGS_3(mtspr, 0, void, env, tl, tl) +DEF_HELPER_FLAGS_3(mfspr, TCG_CALL_NO_WG, tl, env, tl, tl) diff --git a/target/openrisc/sys_helper.c b/target/openrisc/sys_helper.c index b284064381..a8d287d6ef 100644 --- a/target/openrisc/sys_helper.c +++ b/target/openrisc/sys_helper.c @@ -27,13 +27,11 @@ #define TO_SPR(group, number) (((group) << 11) + (number)) -void HELPER(mtspr)(CPUOpenRISCState *env, - target_ulong ra, target_ulong rb, target_ulong offset) +void HELPER(mtspr)(CPUOpenRISCState *env, target_ulong spr, target_ulong rb) { #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); - int spr = (ra | offset); int idx; switch (spr) { @@ -201,13 +199,12 @@ void HELPER(mtspr)(CPUOpenRISCState *env, #endif } -target_ulong HELPER(mfspr)(CPUOpenRISCState *env, - target_ulong rd, target_ulong ra, uint32_t offset) +target_ulong HELPER(mfspr)(CPUOpenRISCState *env, target_ulong rd, + target_ulong spr) { #ifndef CONFIG_USER_ONLY OpenRISCCPU *cpu = openrisc_env_get_cpu(env); CPUState *cs = CPU(cpu); - int spr = (ra | offset); int idx; switch (spr) { diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index c7bfb395b0..b26c473870 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -926,9 +926,10 @@ static bool trans_l_mfspr(DisasContext *dc, arg_l_mfspr *a, uint32_t insn) if (is_user(dc)) { gen_illegal_exception(dc); } else { - TCGv_i32 ti = tcg_const_i32(a->k); - gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], cpu_R[a->a], ti); - tcg_temp_free_i32(ti); + TCGv spr = tcg_temp_new(); + tcg_gen_ori_tl(spr, cpu_R[a->a], a->k); + gen_helper_mfspr(cpu_R[a->d], cpu_env, cpu_R[a->d], spr); + tcg_temp_free(spr); } return true; } @@ -940,7 +941,7 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) if (is_user(dc)) { gen_illegal_exception(dc); } else { - TCGv_i32 ti; + TCGv spr; /* For SR, we will need to exit the TB to recognize the new * exception state. For NPC, in theory this counts as a branch @@ -953,9 +954,10 @@ static bool trans_l_mtspr(DisasContext *dc, arg_l_mtspr *a, uint32_t insn) tcg_gen_movi_tl(cpu_ppc, dc->base.pc_next); tcg_gen_movi_tl(cpu_pc, dc->base.pc_next + 4); - ti = tcg_const_i32(a->k); - gen_helper_mtspr(cpu_env, cpu_R[a->a], cpu_R[a->b], ti); - tcg_temp_free_i32(ti); + spr = tcg_temp_new(); + tcg_gen_ori_tl(spr, cpu_R[a->a], a->k); + gen_helper_mtspr(cpu_env, spr, cpu_R[a->b]); + tcg_temp_free(spr); /* For PPC, we want the value that was just written and not the generic update that we'd get from DISAS_EXIT. */