From patchwork Tue Dec 3 21:51:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 22006 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9ADF4202DA for ; Tue, 3 Dec 2013 21:52:37 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id i4sf49600440oah.6 for ; Tue, 03 Dec 2013 13:52:37 -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=j37EELiLUzUeoohiAvTrJPuDjPee2a/+V7dDYqB2Us4=; b=Uphh9gbtgtFuQSekEHmLWUYQW7ogRaB+fx07jgYcMox26PTbB68W3tm7xtaqSgC8Xg v3jLOAHigRB+D3ebVOj4Jvepgg5ElF4Ds6P9ZUJRZmzIfzwU6Tvy++8vMDdXvBdcQ8gE 2rgLniE28zdkxBS5iWtkGat1Hj6QS+BRNXs1fRbF0+r6n52pt7LK2r/XnrqGHY55793T VMzgwqXe8WHkS1Uyg4QTWcvCzDgCA8LHkaAzNzlWnKX1LV44bLk8gJvzCo3DzU+LOdX4 OiA1vDwh3tooYd4nlcKsM/SamVrwrDozNcZ+K5C8oxU69TByu6Qqv76zQ6zfCbfIR6Xo Meaw== X-Gm-Message-State: ALoCoQnxUb4qYPFJB3Oo9X0q1MovN+1PKkcvgUDcbfx+E1pwWe/Gz7KukEHS+DXmQke46r0elYUK X-Received: by 10.42.98.81 with SMTP id r17mr19692791icn.8.1386107557252; Tue, 03 Dec 2013 13:52:37 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.88.68 with SMTP id be4ls3078qeb.46.gmail; Tue, 03 Dec 2013 13:52:37 -0800 (PST) X-Received: by 10.52.117.176 with SMTP id kf16mr8646694vdb.6.1386107557128; Tue, 03 Dec 2013 13:52:37 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id lw10si31911871vec.5.2013.12.03.13.52.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 03 Dec 2013 13:52:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id if17so10203420vcb.25 for ; Tue, 03 Dec 2013 13:52:37 -0800 (PST) X-Received: by 10.58.54.69 with SMTP id h5mr6429289vep.25.1386107556978; Tue, 03 Dec 2013 13:52:36 -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 u4csp243350vcz; Tue, 3 Dec 2013 13:52:36 -0800 (PST) X-Received: by 10.180.74.174 with SMTP id u14mr4402354wiv.45.1386107554649; Tue, 03 Dec 2013 13:52:34 -0800 (PST) Received: from mnementh.archaic.org.uk (1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id hi12si133360wib.1.2013.12.03.13.52.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 03 Dec 2013 13:52:34 -0800 (PST) Received-SPF: neutral (google.com: 2001:8b0:1d0::1 is neither permitted nor denied by best guess record for domain of pm215@archaic.org.uk) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1VnxsD-0006Iw-JG; Tue, 03 Dec 2013 21:51:17 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexander Graf , C Fontana , Dirk Mueller , Michael Matz , Laurent Desnogues , Richard Henderson , kvmarm@lists.cs.columbia.edu Subject: [PATCH 11/12] target-arm: A64: add support for 'test and branch' imm Date: Tue, 3 Dec 2013 21:51:16 +0000 Message-Id: <1386107477-24165-12-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1386107477-24165-1-git-send-email-peter.maydell@linaro.org> References: <1386107477-24165-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.220.180 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 | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/target-arm/translate-a64.c b/target-arm/translate-a64.c index 3c0748d..bcb59db 100644 --- a/target-arm/translate-a64.c +++ b/target-arm/translate-a64.c @@ -215,10 +215,36 @@ 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_nomatch; + TCGv_i64 tcg_cmp; + + bit_pos = (extract32(insn, 31, 1) << 5) | extract32(insn, 19, 5); + op = extract32(insn, 24, 1); + 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_nomatch = gen_new_label(); + if (op) { /* TBNZ */ + tcg_gen_brcondi_i64(TCG_COND_EQ, tcg_cmp, 0, label_nomatch); + } else { /* TBZ */ + tcg_gen_brcondi_i64(TCG_COND_NE, tcg_cmp, 0, label_nomatch); + } + tcg_temp_free_i64(tcg_cmp); + gen_goto_tb(s, 0, addr); + gen_set_label(label_nomatch); + gen_goto_tb(s, 1, s->pc); } /* C3.2.2 / C5.6.19 Conditional branch (immediate)