From patchwork Tue May 8 17:31:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 10386799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A5E9F60236 for ; Tue, 8 May 2018 17:52:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 99E77290B6 for ; Tue, 8 May 2018 17:52:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E719290BA; Tue, 8 May 2018 17:52:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FSL_HELO_FAKE, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DE8BA290B6 for ; Tue, 8 May 2018 17:52:48 +0000 (UTC) Received: from localhost ([::1]:52673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG6nA-0005Az-4Y for patchwork-qemu-devel@patchwork.kernel.org; Tue, 08 May 2018 13:52:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44313) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG6Tp-0000K0-DJ for qemu-devel@nongnu.org; Tue, 08 May 2018 13:32:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG6To-0005cR-6b for qemu-devel@nongnu.org; Tue, 08 May 2018 13:32:49 -0400 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:35739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG6Tn-0005c8-RS for qemu-devel@nongnu.org; Tue, 08 May 2018 13:32:48 -0400 Received: by mail-lf0-x241.google.com with SMTP id y72-v6so33291605lfd.2 for ; Tue, 08 May 2018 10:32:47 -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; bh=1fbq1A6QUoJmQZ7CYMyPMQpecV0Zb7QXkt6Szn5w4tw=; b=mkZbqcuUFQBAZH+YXEn02mFVuSu2MCVNlb+LZ1xzgSGokUXRsMm9iVISfU2t7CwZsU n2NuNUUJkzQTYGX0ENBTawVag1oX+kK/4eSoY2SxVLw5FUPxMN/bx6i0uWAV/A8Upbae g3UQ2LuCkrV2V6ooIlOPNUQ+nDYklmZeZXkpFfuqYNt7nca94I8QvJJ+xOvLk796t5dK Kd6c8mdVQRvIJC/tFIXfPpnNCoapb4otKV44NKR+4K3XWqrVYrfUyVebsKCmYyLHrnV4 UucWUw1R7DJxdKGQ+RYn0Unku2i5Su6/k7jjyMwbab1kQUtPEal4QF2o5vAoj+Jz80LM sSQQ== 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=1fbq1A6QUoJmQZ7CYMyPMQpecV0Zb7QXkt6Szn5w4tw=; b=aTP63LSRRg7xvL8BS+YzL+IM0/0WXZpPq7UaQ/qcvXKTh593smavNWQOtLtY27sQAG 5xAiqM36IP6mnuYLt9A/3oAtnJMKvo+H1Y5u4gcJdxq7wALL/heiUlXyQHF6kTi6yZ7Z xwEO7w7BO/vNz4hvqWqbtzQRNrS80MyuuFkT27lb+PWYDawOSqx5f2IHj91S9UUSEakZ y/qDAXmwAJafbl874/InREzflHcL7qI2OEQ/LqMAMj8ovajqn7a47Qg2keHQjCm1aLbp cbESq26WMSCR1oJuUox+8NagobrPd5eqQpyLDQ6D07vOXWtq/niZVuiKEgJr9zNgxqGr ns3Q== X-Gm-Message-State: ALKqPwd5Dw0UcDQT8Q38NLtxeexRiG+yC6gDC/S1i+nZdGkjzDWPVCby OxueEyUMPhE5qexyy478DgihIA== X-Google-Smtp-Source: AB8JxZpn6L/HW3bpnBCB7LbvRGcEW/IDuZyQdZbu0MMx/YyaVmcJTpESbkj5ucSPov//71blFctxBw== X-Received: by 2002:a19:1498:: with SMTP id 24-v6mr8648048lfu.128.1525800766257; Tue, 08 May 2018 10:32:46 -0700 (PDT) Received: from gmail.com (81-231-232-130-no39.tbcn.telia.com. [81.231.232.130]) by smtp.gmail.com with ESMTPSA id g71-v6sm604851lfh.85.2018.05.08.10.32.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 10:32:45 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 19:31:50 +0200 Message-Id: <20180508173152.29327-35-edgar.iglesias@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180508173152.29327-1-edgar.iglesias@gmail.com> References: <20180508173152.29327-1-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::241 Subject: [Qemu-devel] [PATCH v2 34/36] target-microblaze: Convert env_btaken to i64 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: edgar.iglesias@xilinx.com, peter.maydell@linaro.org, sai.pavan.boddu@xilinx.com, frasse.iglesias@gmail.com, alistair@alistair23.me, richard.henderson@linaro.org, frederic.konrad@adacore.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "Edgar E. Iglesias" Convert env_btaken to i64. No functional change. Signed-off-by: Edgar E. Iglesias --- target/microblaze/cpu.h | 2 +- target/microblaze/op_helper.c | 2 +- target/microblaze/translate.c | 32 ++++++++++++++++++++------------ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index e62c456ccf..4198e98095 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -238,7 +238,7 @@ typedef struct CPUMBState CPUMBState; struct CPUMBState { uint32_t debug; - uint32_t btaken; + uint64_t btaken; uint32_t btarget; uint32_t bimm; diff --git a/target/microblaze/op_helper.c b/target/microblaze/op_helper.c index ddc1f71d62..4f45a2f3e2 100644 --- a/target/microblaze/op_helper.c +++ b/target/microblaze/op_helper.c @@ -99,7 +99,7 @@ void helper_debug(CPUMBState *env) "debug[%x] imm=%x iflags=%x\n", env->sregs[SR_MSR], env->sregs[SR_ESR], env->sregs[SR_EAR], env->debug, env->imm, env->iflags); - qemu_log("btaken=%d btarget=%x mode=%s(saved=%s) eip=%d ie=%d\n", + qemu_log("btaken=%" PRId64 " btarget=%x mode=%s(saved=%s) eip=%d ie=%d\n", env->btaken, env->btarget, (env->sregs[SR_MSR] & MSR_UM) ? "user" : "kernel", (env->sregs[SR_MSR] & MSR_UMS) ? "user" : "kernel", diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 77ef21a708..20cc257b39 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -56,7 +56,7 @@ static TCGv_i32 env_debug; static TCGv_i32 cpu_R[32]; static TCGv_i64 cpu_SR[14]; static TCGv_i32 env_imm; -static TCGv_i32 env_btaken; +static TCGv_i64 env_btaken; static TCGv_i32 env_btarget; static TCGv_i32 env_iflags; static TCGv env_res_addr; @@ -824,7 +824,7 @@ static inline void sync_jmpstate(DisasContext *dc) { if (dc->jmp == JMP_DIRECT || dc->jmp == JMP_DIRECT_CC) { if (dc->jmp == JMP_DIRECT) { - tcg_gen_movi_i32(env_btaken, 1); + tcg_gen_movi_i64(env_btaken, 1); } dc->jmp = JMP_INDIRECT; tcg_gen_movi_i32(env_btarget, dc->jmp_pc); @@ -1139,7 +1139,7 @@ static void dec_store(DisasContext *dc) } static inline void eval_cc(DisasContext *dc, unsigned int cc, - TCGv_i32 d, TCGv_i32 a) + TCGv_i64 d, TCGv_i64 a) { static const int mb_to_tcg_cc[] = { [CC_EQ] = TCG_COND_EQ, @@ -1157,7 +1157,7 @@ static inline void eval_cc(DisasContext *dc, unsigned int cc, case CC_LE: case CC_GE: case CC_GT: - tcg_gen_setcondi_i32(mb_to_tcg_cc[cc], d, a, 0); + tcg_gen_setcondi_i64(mb_to_tcg_cc[cc], d, a, 0); break; default: cpu_abort(CPU(dc->cpu), "Unknown condition code %x.\n", cc); @@ -1170,7 +1170,7 @@ static void eval_cond_jmp(DisasContext *dc, TCGv_i32 pc_true, TCGv_i64 pc_false) TCGLabel *l1 = gen_new_label(); /* Conditional jmp. */ tcg_gen_mov_i64(cpu_SR[SR_PC], pc_false); - tcg_gen_brcondi_i32(TCG_COND_EQ, env_btaken, 0, l1); + tcg_gen_brcondi_i64(TCG_COND_EQ, env_btaken, 0, l1); tcg_gen_extu_i32_i64(cpu_SR[SR_PC], pc_true); gen_set_label(l1); } @@ -1179,6 +1179,7 @@ static void dec_bcc(DisasContext *dc) { unsigned int cc; unsigned int dslot; + TCGv_i64 tmp64; cc = EXTRACT_FIELD(dc->ir, 21, 23); dslot = dc->ir & (1 << 25); @@ -1203,7 +1204,12 @@ static void dec_bcc(DisasContext *dc) tcg_gen_movi_i32(env_btarget, dc->pc); tcg_gen_add_i32(env_btarget, env_btarget, *(dec_alu_op_b(dc))); } - eval_cc(dc, cc, env_btaken, cpu_R[dc->ra]); + + tmp64 = tcg_temp_new_i64(); + /* Signed arithmetics. */ + tcg_gen_ext_i32_i64(tmp64, cpu_R[dc->ra]); + eval_cc(dc, cc, env_btaken, tmp64); + tcg_temp_free_i64(tmp64); } static void dec_br(DisasContext *dc) @@ -1257,7 +1263,7 @@ static void dec_br(DisasContext *dc) dc->jmp = JMP_INDIRECT; if (abs) { - tcg_gen_movi_i32(env_btaken, 1); + tcg_gen_movi_i64(env_btaken, 1); tcg_gen_mov_i32(env_btarget, *(dec_alu_op_b(dc))); if (link && !dslot) { if (!(dc->tb_flags & IMM_FLAG) && (dc->imm == 8 || dc->imm == 0x18)) @@ -1275,7 +1281,7 @@ static void dec_br(DisasContext *dc) dc->jmp = JMP_DIRECT; dc->jmp_pc = dc->pc + (int32_t)((int16_t)dc->imm); } else { - tcg_gen_movi_i32(env_btaken, 1); + tcg_gen_movi_i64(env_btaken, 1); tcg_gen_movi_i32(env_btarget, dc->pc); tcg_gen_add_i32(env_btarget, env_btarget, *(dec_alu_op_b(dc))); } @@ -1368,7 +1374,7 @@ static void dec_rts(DisasContext *dc) LOG_DIS("rts ir=%x\n", dc->ir); dc->jmp = JMP_INDIRECT; - tcg_gen_movi_i32(env_btaken, 1); + tcg_gen_movi_i64(env_btaken, 1); tcg_gen_add_i32(env_btarget, cpu_R[dc->ra], *(dec_alu_op_b(dc))); } @@ -1692,7 +1698,7 @@ void gen_intermediate_code(CPUState *cs, struct TranslationBlock *tb) TCGLabel *l1 = gen_new_label(); t_sync_flags(dc); /* Conditional jmp. */ - tcg_gen_brcondi_i32(TCG_COND_NE, env_btaken, 0, l1); + tcg_gen_brcondi_i64(TCG_COND_NE, env_btaken, 0, l1); gen_goto_tb(dc, 1, dc->pc); gen_set_label(l1); gen_goto_tb(dc, 0, dc->jmp_pc); @@ -1791,7 +1797,8 @@ void mb_cpu_dump_state(CPUState *cs, FILE *f, fprintf_function cpu_fprintf, "debug=%x imm=%x iflags=%x fsr=%" PRIx64 "\n", env->sregs[SR_MSR], env->sregs[SR_ESR], env->sregs[SR_EAR], env->debug, env->imm, env->iflags, env->sregs[SR_FSR]); - cpu_fprintf(f, "btaken=%d btarget=%x mode=%s(saved=%s) eip=%d ie=%d\n", + cpu_fprintf(f, "btaken=%" PRId64" btarget=%x mode=%s(saved=%s) " + "eip=%d ie=%d\n", env->btaken, env->btarget, (env->sregs[SR_MSR] & MSR_UM) ? "user" : "kernel", (env->sregs[SR_MSR] & MSR_UMS) ? "user" : "kernel", @@ -1810,6 +1817,7 @@ void mb_tcg_init(void) { int i; + env_debug = tcg_global_mem_new_i32(cpu_env, offsetof(CPUMBState, debug), "debug0"); @@ -1822,7 +1830,7 @@ void mb_tcg_init(void) env_btarget = tcg_global_mem_new_i32(cpu_env, offsetof(CPUMBState, btarget), "btarget"); - env_btaken = tcg_global_mem_new_i32(cpu_env, + env_btaken = tcg_global_mem_new_i64(cpu_env, offsetof(CPUMBState, btaken), "btaken"); env_res_addr = tcg_global_mem_new(cpu_env,