From patchwork Mon Sep 2 17:54:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 272046 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 3BC9F2C00A0 for ; Tue, 3 Sep 2013 04:34:25 +1000 (EST) Received: from localhost ([::1]:41388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGYPU-0002uZ-Vs for incoming@patchwork.ozlabs.org; Mon, 02 Sep 2013 13:59:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56626) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGYLa-0005u7-1t for qemu-devel@nongnu.org; Mon, 02 Sep 2013 13:55:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VGYLT-00016r-Dx for qemu-devel@nongnu.org; Mon, 02 Sep 2013 13:55:29 -0400 Received: from mail-pa0-x230.google.com ([2607:f8b0:400e:c03::230]:56146) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VGYLT-00016f-1A for qemu-devel@nongnu.org; Mon, 02 Sep 2013 13:55:23 -0400 Received: by mail-pa0-f48.google.com with SMTP id kp13so5427011pab.35 for ; Mon, 02 Sep 2013 10:55:22 -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=oRnza1SuIEpAXNOCVdroh2IoPOYJ2VdW/TaJMTtNTLc=; b=sfzYjiaUU7QVCoy8+t40/fckpOrzrpGQxPpF1gOYZO/bR8d0EIU2uC3eWHpH1nCoh4 bfo8uq5yLiYnHAa8VTZ876MmViMzo+qzfb02KfN3l+L0hECp7X4KT+jPc9PqLWs9mtSo 0J2OcxX57W3FuL9/RaZysEsdy1IupTrnZQSq2eGo4Kt98Kv6AB5gNfCcLoRKWHROvow0 9aYbzDmqfxJglWwZ2mKD6/uNFt6BccT9aD1Leeei2nBYW/XGB8TQH3Vf/1Z0As0a3xoZ Sanw9ndMWAL+AJs+MMjHcf6u02hC7z+wthUPY8D34Rd/iDH7jb9nFpDAY547B8e3qAVa YWSA== X-Received: by 10.66.248.130 with SMTP id ym2mr3453405pac.177.1378144521954; Mon, 02 Sep 2013 10:55:21 -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:21 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 2 Sep 2013 10:54:42 -0700 Message-Id: <1378144503-15808-9-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:c03::230 Cc: claudio.fontana@huawei.com, Richard Henderson Subject: [Qemu-devel] [PATCH v3 08/29] tcg-aarch64: Introduce tcg_fmt_Rdn_aimm 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 This merges the implementation of tcg_out_addi and tcg_out_subi. Signed-off-by: Richard Henderson --- tcg/aarch64/tcg-target.c | 75 +++++++++++++++++------------------------------- 1 file changed, 27 insertions(+), 48 deletions(-) diff --git a/tcg/aarch64/tcg-target.c b/tcg/aarch64/tcg-target.c index e2f3d1c..bd6f823 100644 --- a/tcg/aarch64/tcg-target.c +++ b/tcg/aarch64/tcg-target.c @@ -206,6 +206,12 @@ typedef enum { INSN_EOR = 0x4a000000, INSN_ANDS = 0x6a000000, + /* Add/subtract immediate instructions */ + INSN_ADDI = 0x11000000, + INSN_ADDSI = 0x31000000, + INSN_SUBI = 0x51000000, + INSN_SUBSI = 0x71000000, + /* Add/subtract shifted register instructions */ INSN_ADD = 0x0b000000, INSN_ADDS = 0x2b000000, @@ -321,6 +327,18 @@ static inline void tcg_fmt_Rdnm_shift(TCGContext *s, AArch64Insn insn, tcg_out32(s, insn | ext << 31 | shift | rm << 16 | rn << 5 | rd); } +static inline void tcg_fmt_Rdn_aimm(TCGContext *s, AArch64Insn insn, bool ext, + TCGReg rd, TCGReg rn, unsigned int aimm) +{ + if (aimm > 0xfff) { + assert((aimm & 0xfff) == 0); + aimm >>= 12; + assert(aimm <= 0xfff); + aimm |= 1 << 12; /* apply LSL 12 */ + } + tcg_out32(s, insn | ext << 31 | aimm << 10 | rn << 5 | rd); +} + static inline void tcg_out_ldst_9(TCGContext *s, enum aarch64_ldst_op_data op_data, enum aarch64_ldst_op_type op_type, @@ -732,46 +750,6 @@ static inline void tcg_out_uxt(TCGContext *s, int s_bits, tcg_out_ubfm(s, 0, rd, rn, 0, bits); } -static inline void tcg_out_addi(TCGContext *s, bool ext, - TCGReg rd, TCGReg rn, unsigned int aimm) -{ - /* add immediate aimm unsigned 12bit value (with LSL 0 or 12) */ - /* using ADD 0x11000000 | (ext) | (aimm << 10) | (rn << 5) | rd */ - unsigned int base = ext ? 0x91000000 : 0x11000000; - - if (aimm <= 0xfff) { - aimm <<= 10; - } else { - /* we can only shift left by 12, on assert we cannot represent */ - assert(!(aimm & 0xfff)); - assert(aimm <= 0xfff000); - base |= 1 << 22; /* apply LSL 12 */ - aimm >>= 2; - } - - tcg_out32(s, base | aimm | (rn << 5) | rd); -} - -static inline void tcg_out_subi(TCGContext *s, bool ext, - TCGReg rd, TCGReg rn, unsigned int aimm) -{ - /* sub immediate aimm unsigned 12bit value (with LSL 0 or 12) */ - /* using SUB 0x51000000 | (ext) | (aimm << 10) | (rn << 5) | rd */ - unsigned int base = ext ? 0xd1000000 : 0x51000000; - - if (aimm <= 0xfff) { - aimm <<= 10; - } else { - /* we can only shift left by 12, on assert we cannot represent */ - assert(!(aimm & 0xfff)); - assert(aimm <= 0xfff000); - base |= 1 << 22; /* apply LSL 12 */ - aimm >>= 2; - } - - tcg_out32(s, base | aimm | (rn << 5) | rd); -} - static inline void tcg_out_nop(TCGContext *s) { tcg_out32(s, 0xd503201f); @@ -889,9 +867,9 @@ static void tcg_out_tlb_read(TCGContext *s, TCGReg addr_reg, (TARGET_LONG_BITS - TARGET_PAGE_BITS) + s_bits, (TARGET_LONG_BITS - TARGET_PAGE_BITS)); /* Add any "high bits" from the tlb offset to the env address into X2, - to take advantage of the LSL12 form of the addi instruction. + to take advantage of the LSL12 form of the ADDI instruction. X2 = env + (tlb_offset & 0xfff000) */ - tcg_out_addi(s, 1, TCG_REG_X2, base, tlb_offset & 0xfff000); + tcg_fmt_Rdn_aimm(s, INSN_ADDI, 1, TCG_REG_X2, base, tlb_offset & 0xfff000); /* Merge the tlb index contribution into X2. X2 = X2 + (X0 << CPU_TLB_ENTRY_BITS) */ tcg_fmt_Rdnm_shift(s, INSN_ADD, 1, TCG_REG_X2, TCG_REG_X2, @@ -1500,9 +1478,10 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_store_pair(s, TCG_REG_FP, r, r + 1, idx); } - /* make stack space for TCG locals */ - tcg_out_subi(s, 1, TCG_REG_SP, TCG_REG_SP, - frame_size_tcg_locals * TCG_TARGET_STACK_ALIGN); + /* Make stack space for TCG locals. */ + tcg_fmt_Rdn_aimm(s, INSN_SUBI, 1, TCG_REG_SP, TCG_REG_SP, + frame_size_tcg_locals * TCG_TARGET_STACK_ALIGN); + /* inform TCG about how to find TCG locals with register, offset, size */ tcg_set_frame(s, TCG_REG_SP, TCG_STATIC_CALL_ARGS_SIZE, CPU_TEMP_BUF_NLONGS * sizeof(long)); @@ -1519,9 +1498,9 @@ static void tcg_target_qemu_prologue(TCGContext *s) tb_ret_addr = s->code_ptr; - /* remove TCG locals stack space */ - tcg_out_addi(s, 1, TCG_REG_SP, TCG_REG_SP, - frame_size_tcg_locals * TCG_TARGET_STACK_ALIGN); + /* Remove TCG locals stack space. */ + tcg_fmt_Rdn_aimm(s, INSN_ADDI, 1, TCG_REG_SP, TCG_REG_SP, + frame_size_tcg_locals * TCG_TARGET_STACK_ALIGN); /* restore registers x19..x28. FP must be preserved, so it still points to callee_saved area */