From patchwork Mon Jun 18 18:40:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 139055 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4287579lji; Mon, 18 Jun 2018 11:51:01 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLq/Mral/kNsJb6XrGJcKnKmVPlkQTHvlhrtjWvt4hkGOvBKxRvnKuu7ld13rcXFYVZ9YIy X-Received: by 2002:ac8:2439:: with SMTP id c54-v6mr12557841qtc.125.1529347861043; Mon, 18 Jun 2018 11:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529347861; cv=none; d=google.com; s=arc-20160816; b=ABnZoYFXhwxXtMaUO/hylgqsXX2fGec33btbq3wpz5ObRNACri4T/afqO5rvQycl4J 3l/6zIhW2lXPF0FxtJL1RM4rkSksAC4qG3d8YjQM9epW1e2GiAbbAwOiZ4LKUiorN3G4 3bCK5qTITHTydA5IXiwxAZ42qdx3qP5qKT2P+hjxjNpPR84+mEqUqoBIJFnhthBX+IOT jkBz6F9IOimj+Tun1P1ew+ugeFeXTVEe3El/QYgn9I8YJ66i2QW2+5uKDTREN0YxuADw 0b4KiIF8xFmQPUsxHSu4JmZiQvMSk9BQdcl4gY8EwhSLoXimd2JRhHuqEqePqXUFXj8Z B2lw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=BsFg23nEm663+9fxFdlngMXgE0T1X/PUBHFSuSkivMY=; b=RAbZOHwpp3uqlhFndDc4bz+kCMpI+uorxrHCTxaSWxDef0C4jo3ITpZbrHlVJPVpLP JzdGbdNqLsB9Ma0BFO+Dj99U6gRHn8L1twMqy2HyjPbVqQsqKk7aQgbiwugZO98cnz/s ejIzjZ+H+M8GEtxnITZeUaNEDyebaVizqKx/rN/uzyB8fXckjZFF6IZZLcD/gUkobwqJ kj5QAzhkx0HxpjuLpcw2o7rwUobK2pBslEQ1DYqe1d3kETF5QxoiuCyWwmCRCS972bzd Fm1OOFS2txTLyg9XaCvXGAmTbax/PH0/LelpGDmDvIF911LzXCo6ZtHLMTpZNGGTu9iB gdxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GaA5NihX; 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 b13-v6si2632324qte.113.2018.06.18.11.51.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 18 Jun 2018 11:51:01 -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=GaA5NihX; 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]:36513 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUzEy-0002kh-Fb for patch@linaro.org; Mon, 18 Jun 2018 14:51:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57321) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUz5O-0003Oz-1D for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUz5N-0004fl-04 for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:06 -0400 Received: from mail-pl0-x231.google.com ([2607:f8b0:400e:c01::231]:46992) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUz5M-0004ez-Pw for qemu-devel@nongnu.org; Mon, 18 Jun 2018 14:41:04 -0400 Received: by mail-pl0-x231.google.com with SMTP id 30-v6so9485198pld.13 for ; Mon, 18 Jun 2018 11:41:04 -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 :mime-version:content-transfer-encoding; bh=BsFg23nEm663+9fxFdlngMXgE0T1X/PUBHFSuSkivMY=; b=GaA5NihXvLC5E3rq2dzJypP1ZZYVSLBKV7Yzzd61tXdraJ1K89VDVSo8ytEG3eMrND vy12+rNXdzXHHq9YI5/NVKnvdNj3bHt49b+EoyGKIvzfatrtwsZlaq1J2qZZ0wD9StQL A8c5S0OvCmh7VAo1WLFN3fQDCQz88/EZ6ONWk= 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=BsFg23nEm663+9fxFdlngMXgE0T1X/PUBHFSuSkivMY=; b=dt8klgVmYBQhRlbULpQ5ZNjwBeB8LHdqW/FHvY5ikzElxESkMYalUCB8PtxRKl4lOA mkdWvE2o2GoIhd7BSXzpao8LpFCG31wz983QYwy3g2uGKxRNYgTMEm4JNb/s8R/zqAxh EfX0PIfXXwsxU6EAN6bTtLb1qvfVMGqB2rq1ZLY93U3KuRmSTN+Znt6VxedwZeCVQJvg hzoAWMoICh8DffE5L7brVewYMeE5Kgzvzdh/OyMQYGps16pjIyEbGmnFYjKrDVyVEVb1 tOJYy9QdB8Mwhhebhh/lwJRgHE0R4JH8FAhvtEAII+wvfbi+6BgkfGJReyjqW+BR55+2 c8XQ== X-Gm-Message-State: APt69E0Ff+44F1a4ZIzFmQFPGmAjZ2hYI3LaMp3uMHmydoxDOGheQ3zO 4vY/FpoYHqWuAHAzaMeh3rCb4FGq0s8= X-Received: by 2002:a17:902:aa83:: with SMTP id d3-v6mr15212501plr.323.1529347263494; Mon, 18 Jun 2018 11:41:03 -0700 (PDT) Received: from cloudburst.twiddle.net (mta-98-147-121-51.hawaii.rr.com. [98.147.121.51]) by smtp.gmail.com with ESMTPSA id i65-v6sm49457254pfd.17.2018.06.18.11.41.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 11:41:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 08:40:31 -1000 Message-Id: <20180618184046.6270-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180618184046.6270-1-richard.henderson@linaro.org> References: <20180618184046.6270-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::231 Subject: [Qemu-devel] [PATCH v2 07/22] 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: shorne@gmail.com 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. Reviewed-by: Philippe Mathieu-Daudé 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.1 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 6a7eb4a3e8..f19f0d257b 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. */