From patchwork Thu Dec 5 12:39:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22061 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f71.google.com (mail-pb0-f71.google.com [209.85.160.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0CD5623FD0 for ; Thu, 5 Dec 2013 12:39:50 +0000 (UTC) Received: by mail-pb0-f71.google.com with SMTP id uo5sf49896278pbc.6 for ; Thu, 05 Dec 2013 04:39:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Uu5bJNoB5P0bvQ6IQ4Rmt56ra0LdH7ZV3Iov5IDxblQ=; b=ONxULv6rbeDDxr1da/AJ4nzeXqUHp3oFen7rRtu8cuCdX2tJRn0OO+jT2Pzwe4DK3M bpFe573cDMRcDSLOW8LPfTKKbjQkkUsMjOHSdtY3MdWJWCNVZcgggkJXNaYZh85vOi/9 4D+KtnaHJGm79Ye9+4AW3+qCPEX4OTBe5Kaa50fdJCyaV9ioR3mvlNa4FMKDO47HE7qQ bvj+pm48kpgahHEbyDgnOHnh5yGEeRjtqTiyYcH66DIOJ8+m7BsjJcmwPINB3lCSzVZO QCuwM2I0qbBY7Gr/UQvW8xFSnRfg6GaWl37HjmafeugydiA8g94Vg2psO1OTqp78bfYA jpog== X-Gm-Message-State: ALoCoQmHXyH65qCMv8p0o5Z+xjHrDtw07PmbBZGNh/drCysiFPKXWHAOMlD0liDzG1foKkYJeghB X-Received: by 10.66.227.193 with SMTP id sc1mr29224061pac.25.1386247190239; Thu, 05 Dec 2013 04:39:50 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.41.66 with SMTP id d2ls816072qel.10.gmail; Thu, 05 Dec 2013 04:39:50 -0800 (PST) X-Received: by 10.52.230.102 with SMTP id sx6mr52723002vdc.15.1386247190079; Thu, 05 Dec 2013 04:39:50 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id gq10si34318112vdc.134.2013.12.05.04.39.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 05 Dec 2013 04:39:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so13864438veb.30 for ; Thu, 05 Dec 2013 04:39:50 -0800 (PST) X-Received: by 10.221.39.195 with SMTP id tn3mr62661400vcb.2.1386247189903; Thu, 05 Dec 2013 04:39:49 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp11818vcz; Thu, 5 Dec 2013 04:39:49 -0800 (PST) X-Received: by 10.194.143.100 with SMTP id sd4mr12318140wjb.69.1386247188147; Thu, 05 Dec 2013 04:39:48 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id dt8si1011494wib.9.2013.12.05.04.39.47 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Dec 2013 04:39:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VoYDV-00072Z-7z; Thu, 05 Dec 2013 12:39:41 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Michael Matz , C Fontana , Dirk Mueller , Laurent Desnogues , kvmarm@lists.cs.columbia.edu, Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= Subject: [PATCH v3 11/12] target-arm: A64: add support for 'test and branch' imm Date: Thu, 5 Dec 2013 12:39:39 +0000 Message-Id: <1386247180-26994-12-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386247180-26994-1-git-send-email-peter.maydell@linaro.org> References: <1386247180-26994-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Alexander Graf This patch adds emulation for the test and branch insns, TBZ and TBNZ. Signed-off-by: Alexander Graf [claudio: adapted for new decoder always compare with 0 remove a TCG temporary ] Signed-off-by: Claudio Fontana Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target-arm/translate-a64.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index a6a1973..213a98a 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -233,10 +233,33 @@ static void disas_comp_b_imm(DisasContext *s, uint32_t insn) unsupported_encoding(s, insn); } -/* Test & branch (immediate) */ +/* C3.2.5 Test & branch (immediate) + * 31 30 25 24 23 19 18 5 4 0 + * +----+-------------+----+-------+-------------+------+ + * | b5 | 0 1 1 0 1 1 | op | b40 | imm14 | Rt | + * +----+-------------+----+-------+-------------+------+ + */ static void disas_test_b_imm(DisasContext *s, uint32_t insn) { - unsupported_encoding(s, insn); + unsigned int bit_pos, op, rt; + uint64_t addr; + int label_match; + TCGv_i64 tcg_cmp; + + bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); + op = extract32(insn, 24, 1); /* 0: TBZ; 1: TBNZ */ + addr = s->pc + sextract32(insn, 5, 14) * 4 - 4; + rt = extract32(insn, 0, 5); + + tcg_cmp = tcg_temp_new_i64(); + tcg_gen_andi_i64(tcg_cmp, cpu_reg(s, rt), (1ULL << bit_pos)); + label_match = gen_new_label(); + tcg_gen_brcondi_i64(op ? TCG_COND_NE : TCG_COND_EQ, + tcg_cmp, 0, label_match); + tcg_temp_free_i64(tcg_cmp); + gen_goto_tb(s, 0, s->pc); + gen_set_label(label_match); + gen_goto_tb(s, 1, addr); } /* C3.2.2 / C5.6.19 Conditional branch (immediate)