From patchwork Sat Sep 14 21:54:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 274977 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 982F12C014B for ; Sun, 15 Sep 2013 08:11:01 +1000 (EST) Received: from localhost ([::1]:54782 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKy3P-0006yJ-Gl for incoming@patchwork.ozlabs.org; Sat, 14 Sep 2013 18:10:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKxoe-0001yE-Jd for qemu-devel@nongnu.org; Sat, 14 Sep 2013 17:55:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VKxoY-0004BJ-Pd for qemu-devel@nongnu.org; Sat, 14 Sep 2013 17:55:44 -0400 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]:44878) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VKxoY-0004BD-Ea for qemu-devel@nongnu.org; Sat, 14 Sep 2013 17:55:38 -0400 Received: by mail-pa0-f41.google.com with SMTP id bj1so3901293pad.14 for ; Sat, 14 Sep 2013 14:55:37 -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=30e1h1gVykSjSKM7ie9jesvNyh4beMiTx93lA7+Q+6M=; b=EpYOUhoyrnuqZaW5BQdn71kWgq4x+ved8EQ+faXQSfuPQXO8A9Io2KoEJXPSjZ8ylX dABtRWtdw2SsolCcJHlJWBCa93ZUqILoxffeokFKVu78nIxSIm1/kzjw9lIbjrFlAB5m /nJ6ZIYtrg24GZoiFKW+epH0mz+BP3e7rTdsZ9CJyB3DX4d/qMcCBpyE/uizkf9ceXnX 3JNW/wCyxrDjl39kCEoBxoCS/+T1MHweu2nDtSF24tzm2Ole3xP8GtA8F1kR6Y1Ktv99 7iU/tvJ/J46ga7QO7ux7Gx+iTvYNQVUnKxF6kpoU6PWXYMQ+P1elnd53PLq97P4AW36u COlA== X-Received: by 10.68.244.168 with SMTP id xh8mr20418945pbc.3.1379195737482; Sat, 14 Sep 2013 14:55:37 -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 gg10sm20458962pbc.46.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 14 Sep 2013 14:55:36 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 14 Sep 2013 14:54:46 -0700 Message-Id: <1379195690-6509-30-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1379195690-6509-1-git-send-email-rth@twiddle.net> References: <1379195690-6509-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:c03::229 Cc: peter.maydell@linaro.org, claudio.fontana@gmail.com Subject: [Qemu-devel] [PATCH v4 29/33] 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 3d1108c..335a5d0 100644 --- a/tcg/aarch64/tcg-target.c +++ b/tcg/aarch64/tcg-target.c @@ -327,6 +327,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 @@ -837,15 +845,14 @@ static void tcg_out_cmp(TCGContext *s, TCGType 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) @@ -855,25 +862,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 */ @@ -881,37 +884,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) @@ -1993,5 +1993,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); }