From patchwork Mon Sep 2 17:54:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 272035 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB94A2C00A0 for ; Tue, 3 Sep 2013 04:07:42 +1000 (EST) Received: from localhost ([::1]:41469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGYXM-0003yp-Ja for incoming@patchwork.ozlabs.org; Mon, 02 Sep 2013 14:07:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56861) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGYM1-0006JN-DD for qemu-devel@nongnu.org; Mon, 02 Sep 2013 13:56:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGYLv-0001EQ-HI for qemu-devel@nongnu.org; Mon, 02 Sep 2013 13:55:57 -0400 Received: from mail-pd0-x22b.google.com ([2607:f8b0:400e:c02::22b]:57035) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGYLu-0001EE-SW for qemu-devel@nongnu.org; Mon, 02 Sep 2013 13:55:51 -0400 Received: by mail-pd0-f171.google.com with SMTP id g10so4989976pdj.16 for ; Mon, 02 Sep 2013 10:55:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=f18j6jZHyfZU4wCqzBoYhFwstD9PGmp8ormYwHdhjXU=; b=bcPinM726YuouAWeZj/JO6KaotpPJiyEzHMyy6zNgZv74uCXqf3DFa6EbKXCY1VJOq MuUjf2FMio04Pu2HHUc8kucdquqxMhUCPEZWeWhIwRDNoK23ZwCPYr7WuxtNxBClhBmX HbBRQFpdLsvHXS/CEerGcAI4wD6xwHoDvm+phtFvWrePRx3CnzM9dAM6S4VQJCGZjTqY FhRe152uqomv+8HpbI4bT7qS4AHgaj/EKo/+boB4p+kTy4Nj7GyfIRYvsmqWriWmrSBb xvDpg+qH3ZVY/jqe2trIqBw+U49SAJJaGuYpXrZ85PJy54aVF92TEQoQSK5MGfYu1KWI pMmw== X-Received: by 10.68.232.225 with SMTP id tr1mr4528108pbc.143.1378144549934; Mon, 02 Sep 2013 10:55:49 -0700 (PDT) Received: from pebble.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id tr10sm17218114pbc.22.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 02 Sep 2013 10:55:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 2 Sep 2013 10:54:59 -0700 Message-Id: <1378144503-15808-26-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1378144503-15808-1-git-send-email-rth@twiddle.net> References: <1378144503-15808-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400e:c02::22b Cc: claudio.fontana@huawei.com, Richard Henderson Subject: [Qemu-devel] [PATCH v3 25/29] tcg-aarch64: Use symbolic names for branches X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c index 42edf9e..385d97a 100644 --- a/tcg/aarch64/tcg-target.c +++ b/tcg/aarch64/tcg-target.c @@ -322,6 +322,14 @@ typedef enum { /* PC relative addressing instructions */ INSN_ADR = 0x10000000, INSN_ADRP = 0x90000000, + + /* Branch instructions */ + INSN_B = 0x14000000, + INSN_BL = 0x94000000, + INSN_BR = 0xd61f0000, + INSN_BLR = 0xd63f0000, + INSN_RET = 0xd65f0000, + INSN_B_C = 0x54000000, } AArch64Insn; static inline enum aarch64_ldst_op_data @@ -769,15 +777,14 @@ static void tcg_out_cmp(TCGContext *s, bool ext, TCGReg a, static inline void tcg_out_goto(TCGContext *s, tcg_target_long target) { - tcg_target_long offset; - offset = (target - (tcg_target_long)s->code_ptr) / 4; + tcg_target_long offset = (target - (tcg_target_long)s->code_ptr) / 4; if (offset < -0x02000000 || offset >= 0x02000000) { /* out of 26bit range */ tcg_abort(); } - tcg_out32(s, 0x14000000 | (offset & 0x03ffffff)); + tcg_out32(s, INSN_B | (offset & 0x03ffffff)); } static inline void tcg_out_goto_noaddr(TCGContext *s) @@ -787,25 +794,21 @@ static inline void tcg_out_goto_noaddr(TCGContext *s) kept coherent during retranslation. Mask away possible garbage in the high bits for the first translation, while keeping the offset bits for retranslation. */ - uint32_t insn; - insn = (tcg_in32(s) & 0x03ffffff) | 0x14000000; - tcg_out32(s, insn); + uint32_t old = tcg_in32(s) & 0x03ffffff; + tcg_out32(s, INSN_B | old); } static inline void tcg_out_goto_cond_noaddr(TCGContext *s, TCGCond c) { - /* see comments in tcg_out_goto_noaddr */ - uint32_t insn; - insn = tcg_in32(s) & (0x07ffff << 5); - insn |= 0x54000000 | tcg_cond_to_aarch64[c]; - tcg_out32(s, insn); + /* See comments in tcg_out_goto_noaddr. */ + uint32_t old = tcg_in32(s) & (0x07ffff << 5); + tcg_out32(s, INSN_B_C | tcg_cond_to_aarch64[c] | old); } static inline void tcg_out_goto_cond(TCGContext *s, TCGCond c, tcg_target_long target) { - tcg_target_long offset; - offset = (target - (tcg_target_long)s->code_ptr) / 4; + tcg_target_long offset = (target - (tcg_target_long)s->code_ptr) / 4; if (offset < -0x40000 || offset >= 0x40000) { /* out of 19bit range */ @@ -813,37 +816,34 @@ static inline void tcg_out_goto_cond(TCGContext *s, TCGCond c, } offset &= 0x7ffff; - tcg_out32(s, 0x54000000 | tcg_cond_to_aarch64[c] | offset << 5); + tcg_out32(s, INSN_B_C | tcg_cond_to_aarch64[c] | offset << 5); } static inline void tcg_out_callr(TCGContext *s, TCGReg reg) { - tcg_out32(s, 0xd63f0000 | reg << 5); + tcg_out32(s, INSN_BLR | reg << 5); } static inline void tcg_out_gotor(TCGContext *s, TCGReg reg) { - tcg_out32(s, 0xd61f0000 | reg << 5); + tcg_out32(s, INSN_BR | reg << 5); } static inline void tcg_out_call(TCGContext *s, tcg_target_long target) { - tcg_target_long offset; - - offset = (target - (tcg_target_long)s->code_ptr) / 4; + tcg_target_long offset = (target - (tcg_target_long)s->code_ptr) / 4; if (offset < -0x02000000 || offset >= 0x02000000) { /* out of 26bit rng */ tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP, target); tcg_out_callr(s, TCG_REG_TMP); } else { - tcg_out32(s, 0x94000000 | (offset & 0x03ffffff)); + tcg_out32(s, INSN_BL | (offset & 0x03ffffff)); } } -static inline void tcg_out_ret(TCGContext *s) +static inline void tcg_out_ret(TCGContext *s, TCGReg rn) { - /* emit RET { LR } */ - tcg_out32(s, 0xd65f03c0); + tcg_out32(s, INSN_RET | rn << 5); } void aarch64_tb_set_jmp_target(uintptr_t jmp_addr, uintptr_t addr) @@ -1923,5 +1923,5 @@ static void tcg_target_qemu_prologue(TCGContext *s) /* pop (FP, LR), restore SP to previous frame, return */ tcg_out_pop_pair(s, TCG_REG_SP, TCG_REG_FP, TCG_REG_LR, frame_size_callee_saved); - tcg_out_ret(s); + tcg_out_ret(s, TCG_REG_LR); }