From patchwork Thu May 27 20:46:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 53822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0D504B7D1B for ; Fri, 28 May 2010 07:51:07 +1000 (EST) Received: from localhost ([127.0.0.1]:42291 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHkwu-0003Bd-Vj for incoming@patchwork.ozlabs.org; Thu, 27 May 2010 17:49:09 -0400 Received: from [140.186.70.92] (port=56445 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OHjzm-0002Sh-AJ for qemu-devel@nongnu.org; Thu, 27 May 2010 16:48:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OHjzl-0005Vl-3M for qemu-devel@nongnu.org; Thu, 27 May 2010 16:48:02 -0400 Received: from are.twiddle.net ([75.149.56.221]:51278) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OHjzk-0005Vb-Uf for qemu-devel@nongnu.org; Thu, 27 May 2010 16:48:01 -0400 Received: from anchor.twiddle.home (anchor.twiddle.home [172.31.0.4]) by are.twiddle.net (Postfix) with ESMTPS id 5A13347E; Thu, 27 May 2010 13:48:00 -0700 (PDT) Received: from anchor.twiddle.home (anchor.twiddle.home [127.0.0.1]) by anchor.twiddle.home (8.14.4/8.14.4) with ESMTP id o4RKlxbO031068; Thu, 27 May 2010 13:47:59 -0700 Received: (from rth@localhost) by anchor.twiddle.home (8.14.4/8.14.4/Submit) id o4RKlxtX031067; Thu, 27 May 2010 13:47:59 -0700 From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 27 May 2010 13:46:37 -0700 Message-Id: <1274993204-30766-56-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.0.1 In-Reply-To: <1274993204-30766-1-git-send-email-rth@twiddle.net> References: <1274993204-30766-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: agraf@suse.de, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 55/62] tcg-s390: Use 16-bit branches for forward jumps. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Translation blocks are never big enough to require 32-bit branches. Signed-off-by: Richard Henderson --- tcg/s390/tcg-target.c | 27 ++++++++++++++++++++++----- 1 files changed, 22 insertions(+), 5 deletions(-) diff --git a/tcg/s390/tcg-target.c b/tcg/s390/tcg-target.c index 0dc71e2..697c5e4 100644 --- a/tcg/s390/tcg-target.c +++ b/tcg/s390/tcg-target.c @@ -33,6 +33,11 @@ do { } while (0) #endif +/* ??? The translation blocks produced by TCG are generally small enough to + be entirely reachable with a 16-bit displacement. Leaving the option for + a 32-bit displacement here Just In Case. */ +#define USE_LONG_BRANCHES 0 + #define TCG_CT_CONST_32 0x0100 #define TCG_CT_CONST_NEG 0x0200 #define TCG_CT_CONST_ADDI 0x0400 @@ -295,14 +300,22 @@ static uint8_t *tb_ret_addr; static uint64_t facilities; static void patch_reloc(uint8_t *code_ptr, int type, - tcg_target_long value, tcg_target_long addend) + tcg_target_long value, tcg_target_long addend) { - uint32_t *code_ptr_32 = (uint32_t*)code_ptr; - tcg_target_long code_ptr_tlong = (tcg_target_long)code_ptr; + tcg_target_long code_ptr_tl = (tcg_target_long)code_ptr; + tcg_target_long pcrel2; + /* ??? Not the usual definition of "addend". */ + pcrel2 = (value - (code_ptr_tl + addend)) >> 1; + switch (type) { + case R_390_PC16DBL: + assert(pcrel2 == (int16_t)pcrel2); + *(int16_t *)code_ptr = pcrel2; + break; case R_390_PC32DBL: - *code_ptr_32 = (value - (code_ptr_tlong + addend)) >> 1; + assert(pcrel2 == (int32_t)pcrel2); + *(int32_t *)code_ptr = pcrel2; break; default: tcg_abort(); @@ -1081,10 +1094,14 @@ static void tgen_branch(TCGContext *s, int cc, int labelno) TCGLabel* l = &s->labels[labelno]; if (l->has_value) { tgen_gotoi(s, cc, l->u.value); - } else { + } else if (USE_LONG_BRANCHES) { tcg_out16(s, RIL_BRCL | (cc << 4)); tcg_out_reloc(s, s->code_ptr, R_390_PC32DBL, labelno, -2); s->code_ptr += 4; + } else { + tcg_out16(s, RI_BRC | (cc << 4)); + tcg_out_reloc(s, s->code_ptr, R_390_PC16DBL, labelno, -2); + s->code_ptr += 2; } }