From patchwork Sat Feb 17 20:31:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 128770 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1907419ljc; Sat, 17 Feb 2018 12:50:15 -0800 (PST) X-Google-Smtp-Source: AH8x226sPJCEgLa78QAwhrE/CUByxLHCJRpEG7XrGoXd59SwPJvXE2mshLrZGFbbiX1/LLXmzyqv X-Received: by 10.129.49.11 with SMTP id x11mr4350128ywx.249.1518900615213; Sat, 17 Feb 2018 12:50:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518900615; cv=none; d=google.com; s=arc-20160816; b=tBeQ7lpFVdwA1eCTudV9IrQSDxooImwwqgHyRg0DCBx5D4lZ0YYao2c7gqrcArTVUU V0faFdybnPBIiZp/oHhSuGVK1kFUQLfcJtVBIAJI5lK1nzN0ozNcLFNavgjT4HAfnIJL aepSXD6RNyPoUsm/XDEfEGsOe0/urUWx2qyDLu8Orp9vfcapA9b62d+RAcf+w7w3emW+ OoHFxpyKJtzFURqOkiyvKnj2BLBB1hk8jc81RMzJfn8iafLsRcHOfLPdRQf6yV5FP4Mh UgzcvLjBbKMQQQTc1EivrrcfXfy66YpCnwS/Z1rSkhKpFzs0C3r36kn5BLNBMxThfGnl 1peQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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=qZ3mqkl2iC1iVxY1/lABOPfh1KF+sJCy7gVMNXvDtJE=; b=EitmwmJD6Y8OSvnd3pyYQ51Uj1EPe8KfPOn4Tv69yUWzjmx7ovdPH2rwbz4vcVm48X TYfkEZFhLj3jtiBvDPr48WpcE1sX/XFZZt26jrrbC2DmCDoqslw19CXUpDv2b8a0f6Yu CeK8+JrLQqoRenZf5LlbvgM+cBJqFQrITdP/0Rx5QpIGKODc+eo7NpNpdPUWiDUgNy6A C369iw1xlJLq/maeHRezn0eMtKIML74AgRhluWzDNa2/rqjbJ54GCH0iRyGnb7TZnvzF 2rFkWQzaAWaw1AWyTTLHgv8muu7bmDbXGvJ61jxW4i9/4aMLsdORhKqQ9n+m/OONJ1Xf CGHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=YO6ahnBv; 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 n204si558939ybg.624.2018.02.17.12.50.14 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 17 Feb 2018 12:50:15 -0800 (PST) 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=YO6ahnBv; 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]:33281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1en9R0-0007wS-IY for patch@linaro.org; Sat, 17 Feb 2018 15:50:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1en99L-0000GB-4I for qemu-devel@nongnu.org; Sat, 17 Feb 2018 15:32:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1en99J-0000op-Gs for qemu-devel@nongnu.org; Sat, 17 Feb 2018 15:31:59 -0500 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:45792) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1en99J-0000oi-8n for qemu-devel@nongnu.org; Sat, 17 Feb 2018 15:31:57 -0500 Received: by mail-pl0-x241.google.com with SMTP id p5so3525982plo.12 for ; Sat, 17 Feb 2018 12:31:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=qZ3mqkl2iC1iVxY1/lABOPfh1KF+sJCy7gVMNXvDtJE=; b=YO6ahnBvUB8JR6jn0K2CwxVWH2fL/66Tq8EcKuZoyZyXM8pjrLXhWuUF+j2smbH/5B L/N+/McZhYAy+1SCCXY1G+h9XDF81nqYdFqmEM8DYnJgB8GhVf62vRjtsWG4+XXu8KHX o5s1c0z2FNZGZpmo6gTYov4HtY/49AVNxsYbc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=qZ3mqkl2iC1iVxY1/lABOPfh1KF+sJCy7gVMNXvDtJE=; b=LbVPheHiV3gZ8K9/iTYAZNW2ozT9JFclx/LJq/6jS25/8VhNUxZwbg++Q/Ej+AR6i+ Sgl0m1THYQoeSgYE0D8JMH9GmqZ6xy0vSljVjIgi4jz9y764xW/B8Za2vh5N9xLh0eIN OG2gGQdy+041SkbFJ6okqD88HqphiqJ2B6MABL2YRkCMuQUWq8KcxEOP4fHNkVnJV8YE Cx4BpCM/QIXjhuxQs3w5MwcVIMJjZ4kVioTRxOhVJfLW1PwfgrMUmWezBI7nS57fK8rL wViGhKp5vdqmXZhMeG18K2bGxlBAn+wXkx+fJuUr9AOCxgM+T0Fx9FZ46h4ujuY+EaRQ eoAg== X-Gm-Message-State: APf1xPC656qzOvas0OKcV24vUTVZY07Zm8x1U2auIshN4qQfZ9Hx3myk Cs6ePT1IcZZhQ2l3MEtxQd1JP48rtVc= X-Received: by 2002:a17:902:67c5:: with SMTP id g5-v6mr9736272pln.106.1518899515804; Sat, 17 Feb 2018 12:31:55 -0800 (PST) Received: from cloudburst.twiddle.net ([50.0.192.64]) by smtp.gmail.com with ESMTPSA id y7sm48203797pfe.26.2018.02.17.12.31.54 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 17 Feb 2018 12:31:54 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 17 Feb 2018 12:31:25 -0800 Message-Id: <20180217203132.31780-13-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180217203132.31780-1-richard.henderson@linaro.org> References: <20180217203132.31780-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:c01::241 Subject: [Qemu-devel] [PATCH 12/19] target/hppa: Convert direct and indirect branches 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/hppa/translate.c | 125 ++++++++++++----------------------------------- target/hppa/insns.decode | 34 ++++++++++++- 2 files changed, 63 insertions(+), 96 deletions(-) -- 2.14.3 diff --git a/target/hppa/translate.c b/target/hppa/translate.c index e01a28c70c..5df5b8dba4 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -901,15 +901,6 @@ static target_sreg assemble_16a(uint32_t insn) return x << 2; } -static target_sreg assemble_17(uint32_t insn) -{ - target_ureg x = -(target_ureg)(insn & 1); - x = (x << 5) | extract32(insn, 16, 5); - x = (x << 1) | extract32(insn, 2, 1); - x = (x << 10) | extract32(insn, 3, 10); - return x << 2; -} - static target_sreg assemble_21(uint32_t insn) { target_ureg x = -(target_ureg)(insn & 1); @@ -920,15 +911,6 @@ static target_sreg assemble_21(uint32_t insn) return x << 11; } -static target_sreg assemble_22(uint32_t insn) -{ - target_ureg x = -(target_ureg)(insn & 1); - x = (x << 10) | extract32(insn, 16, 10); - x = (x << 1) | extract32(insn, 2, 1); - x = (x << 10) | extract32(insn, 3, 10); - return x << 2; -} - /* The parisc documentation describes only the general interpretation of the conditions, without describing their exact implementation. The interpretations do not stand up well when considering ADD,C and SUB,B. @@ -3549,11 +3531,8 @@ static void trans_depwi_sar(DisasContext *ctx, arg_depwi_sar *a, uint32_t insn) tcg_temp_free(i); } -static void trans_be(DisasContext *ctx, uint32_t insn, bool is_l) +static void trans_be(DisasContext *ctx, arg_be *a, uint32_t insn) { - unsigned n = extract32(insn, 1, 1); - unsigned b = extract32(insn, 21, 5); - target_sreg disp = assemble_17(insn); TCGv_reg tmp; #ifdef CONFIG_USER_ONLY @@ -3565,29 +3544,28 @@ static void trans_be(DisasContext *ctx, uint32_t insn, bool is_l) /* Since we don't implement spaces, just branch. Do notice the special case of "be disp(*,r0)" using a direct branch to disp, so that we can goto_tb to the TB containing the syscall. */ - if (b == 0) { - return do_dbranch(ctx, disp, is_l ? 31 : 0, n); + if (a->b == 0) { + return do_dbranch(ctx, a->disp, a->l, a->n); } #else - int sp = assemble_sr3(insn); nullify_over(ctx); #endif tmp = get_temp(ctx); - tcg_gen_addi_reg(tmp, load_gpr(ctx, b), disp); + tcg_gen_addi_reg(tmp, load_gpr(ctx, a->b), a->disp); tmp = do_ibranch_priv(ctx, tmp); #ifdef CONFIG_USER_ONLY - do_ibranch(ctx, tmp, is_l ? 31 : 0, n); + do_ibranch(ctx, tmp, a->l, a->n); #else TCGv_i64 new_spc = tcg_temp_new_i64(); - load_spr(ctx, new_spc, sp); - if (is_l) { + load_spr(ctx, new_spc, a->sp); + if (a->l) { copy_iaoq_entry(cpu_gr[31], ctx->iaoq_n, ctx->iaoq_n_var); tcg_gen_mov_i64(cpu_sr[0], cpu_iasq_f); } - if (n && use_nullify_skip(ctx)) { + if (a->n && use_nullify_skip(ctx)) { tcg_gen_mov_reg(cpu_iaoq_f, tmp); tcg_gen_addi_reg(cpu_iaoq_b, cpu_iaoq_f, 4); tcg_gen_mov_i64(cpu_iasq_f, new_spc); @@ -3599,7 +3577,7 @@ static void trans_be(DisasContext *ctx, uint32_t insn, bool is_l) } tcg_gen_mov_reg(cpu_iaoq_b, tmp); tcg_gen_mov_i64(cpu_iasq_b, new_spc); - nullify_set(ctx, n); + nullify_set(ctx, a->n); } tcg_temp_free_i64(new_spc); tcg_gen_lookup_and_goto_ptr(); @@ -3608,21 +3586,14 @@ static void trans_be(DisasContext *ctx, uint32_t insn, bool is_l) #endif } -static void trans_bl(DisasContext *ctx, uint32_t insn, const DisasInsn *di) +static void trans_bl(DisasContext *ctx, arg_bl *a, uint32_t insn) { - unsigned n = extract32(insn, 1, 1); - unsigned link = extract32(insn, 21, 5); - target_sreg disp = assemble_17(insn); - - do_dbranch(ctx, iaoq_dest(ctx, disp), link, n); + do_dbranch(ctx, iaoq_dest(ctx, a->disp), a->l, a->n); } -static void trans_b_gate(DisasContext *ctx, uint32_t insn, const DisasInsn *di) +static void trans_b_gate(DisasContext *ctx, arg_b_gate *a, uint32_t insn) { - unsigned n = extract32(insn, 1, 1); - unsigned link = extract32(insn, 21, 5); - target_sreg disp = assemble_17(insn); - target_ureg dest = iaoq_dest(ctx, disp); + target_ureg dest = iaoq_dest(ctx, a->disp); /* Make sure the caller hasn't done something weird with the queue. * ??? This is not quite the same as the PSW[B] bit, which would be @@ -3661,61 +3632,44 @@ static void trans_b_gate(DisasContext *ctx, uint32_t insn, const DisasInsn *di) } #endif - do_dbranch(ctx, dest, link, n); + do_dbranch(ctx, dest, a->l, a->n); } -static void trans_bl_long(DisasContext *ctx, uint32_t insn, const DisasInsn *di) +static void trans_blr(DisasContext *ctx, arg_blr *a, uint32_t insn) { - unsigned n = extract32(insn, 1, 1); - target_sreg disp = assemble_22(insn); - - do_dbranch(ctx, iaoq_dest(ctx, disp), 2, n); -} - -static void trans_blr(DisasContext *ctx, uint32_t insn, const DisasInsn *di) -{ - unsigned n = extract32(insn, 1, 1); - unsigned rx = extract32(insn, 16, 5); - unsigned link = extract32(insn, 21, 5); TCGv_reg tmp = get_temp(ctx); - tcg_gen_shli_reg(tmp, load_gpr(ctx, rx), 3); + tcg_gen_shli_reg(tmp, load_gpr(ctx, a->x), 3); tcg_gen_addi_reg(tmp, tmp, ctx->iaoq_f + 8); /* The computation here never changes privilege level. */ - do_ibranch(ctx, tmp, link, n); + do_ibranch(ctx, tmp, a->l, a->n); } -static void trans_bv(DisasContext *ctx, uint32_t insn, const DisasInsn *di) +static void trans_bv(DisasContext *ctx, arg_bv *a, uint32_t insn) { - unsigned n = extract32(insn, 1, 1); - unsigned rx = extract32(insn, 16, 5); - unsigned rb = extract32(insn, 21, 5); TCGv_reg dest; - if (rx == 0) { - dest = load_gpr(ctx, rb); + if (a->x == 0) { + dest = load_gpr(ctx, a->b); } else { dest = get_temp(ctx); - tcg_gen_shli_reg(dest, load_gpr(ctx, rx), 3); - tcg_gen_add_reg(dest, dest, load_gpr(ctx, rb)); + tcg_gen_shli_reg(dest, load_gpr(ctx, a->x), 3); + tcg_gen_add_reg(dest, dest, load_gpr(ctx, a->b)); } dest = do_ibranch_priv(ctx, dest); - do_ibranch(ctx, dest, 0, n); + do_ibranch(ctx, dest, 0, a->n); } -static void trans_bve(DisasContext *ctx, uint32_t insn, const DisasInsn *di) +static void trans_bve(DisasContext *ctx, arg_bve *a, uint32_t insn) { - unsigned n = extract32(insn, 1, 1); - unsigned rb = extract32(insn, 21, 5); - unsigned link = extract32(insn, 13, 1) ? 2 : 0; TCGv_reg dest; #ifdef CONFIG_USER_ONLY - dest = do_ibranch_priv(ctx, load_gpr(ctx, rb)); - do_ibranch(ctx, dest, link, n); + dest = do_ibranch_priv(ctx, load_gpr(ctx, a->b)); + do_ibranch(ctx, dest, a->l, a->n); #else nullify_over(ctx); - dest = do_ibranch_priv(ctx, load_gpr(ctx, rb)); + dest = do_ibranch_priv(ctx, load_gpr(ctx, a->b)); copy_iaoq_entry(cpu_iaoq_f, ctx->iaoq_b, cpu_iaoq_b); if (ctx->iaoq_b == -1) { @@ -3723,25 +3677,16 @@ static void trans_bve(DisasContext *ctx, uint32_t insn, const DisasInsn *di) } copy_iaoq_entry(cpu_iaoq_b, -1, dest); tcg_gen_mov_i64(cpu_iasq_b, space_select(ctx, 0, dest)); - if (link) { - copy_iaoq_entry(cpu_gr[link], ctx->iaoq_n, ctx->iaoq_n_var); + if (a->l) { + copy_iaoq_entry(cpu_gr[a->l], ctx->iaoq_n, ctx->iaoq_n_var); } - nullify_set(ctx, n); + nullify_set(ctx, a->n); tcg_gen_lookup_and_goto_ptr(); ctx->base.is_jmp = DISAS_NORETURN; nullify_end(ctx); #endif } -static const DisasInsn table_branch[] = { - { 0xe8000000u, 0xfc006000u, trans_bl }, /* B,L and B,L,PUSH */ - { 0xe800a000u, 0xfc00e000u, trans_bl_long }, - { 0xe8004000u, 0xfc00fffdu, trans_blr }, - { 0xe800c000u, 0xfc00fffdu, trans_bv }, - { 0xe800d000u, 0xfc00dffcu, trans_bve }, - { 0xe8002000u, 0xfc00e000u, trans_b_gate }, -}; - static void trans_fop_wew_0c(DisasContext *ctx, uint32_t insn, const DisasInsn *di) { @@ -4408,16 +4353,6 @@ static void translate_one(DisasContext *ctx, uint32_t insn) translate_table(ctx, insn, table_fp_fused); return; - case 0x38: - trans_be(ctx, insn, false); - return; - case 0x39: - trans_be(ctx, insn, true); - return; - case 0x3A: - translate_table(ctx, insn, table_branch); - return; - case 0x04: /* spopn */ case 0x05: /* diag */ case 0x0F: /* product specific */ diff --git a/target/hppa/insns.decode b/target/hppa/insns.decode index ed0b5fe9d7..3bd19f8a28 100644 --- a/target/hppa/insns.decode +++ b/target/hppa/insns.decode @@ -24,7 +24,9 @@ %assemble_sr3 13:1 14:2 %assemble_sr3x 13:1 14:2 !function=expand_sr3x -%assemble_12 0:s1 2:1 3:10 !function=expand_shl2 +%assemble_12 0:s1 2:1 3:10 !function=expand_shl2 +%assemble_17 0:s1 16:5 2:1 3:10 !function=expand_shl2 +%assemble_22 0:s1 16:10 2:1 3:10 !function=expand_shl2 %sm_imm 16:10 !function=expand_sm_imm @@ -208,3 +210,33 @@ depw_sar 110101 t:5 r:5 c:3 00 nz:1 00000 clen:5 depw_imm 110101 t:5 r:5 c:3 01 nz:1 cpos:5 clen:5 depwi_sar 110101 t:5 ..... c:3 10 nz:1 00000 clen:5 i=%im5_16 depwi_imm 110101 t:5 ..... c:3 11 nz:1 cpos:5 clen:5 i=%im5_16 + +#### +# Branch External +#### + +&be b l n disp sp +@be ...... b:5 ..... ... ........... n:1 . \ + &be disp=%assemble_17 sp=%assemble_sr3 + +be 111000 ..... ..... ... ........... . . @be l=0 +be 111001 ..... ..... ... ........... . . @be l=31 + +#### +# Branch +#### + +&bl l n disp +@bl ...... l:5 ..... ... ........... n:1 . &bl disp=%assemble_17 + +# B,L and B,L,PUSH +bl 111010 ..... ..... 000 ........... . . @bl +bl 111010 ..... ..... 100 ........... . . @bl +# B,L (long displacement) +bl 111010 ..... ..... 101 ........... n:1 . &bl l=2 \ + disp=%assemble_22 +b_gate 111010 ..... ..... 001 ........... . . @bl +blr 111010 l:5 x:5 010 00000000000 n:1 0 +bv 111010 b:5 x:5 110 00000000000 n:1 0 +bve 111010 b:5 00000 110 10000000000 n:1 - l=0 +bve 111010 b:5 00000 111 10000000000 n:1 - l=2