From patchwork Fri Jun 4 19:14:39 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 54698 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 BE0DEB7E40 for ; Sat, 5 Jun 2010 06:05:05 +1000 (EST) Received: from localhost ([127.0.0.1]:33022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKd6u-0004VY-Lb for incoming@patchwork.ozlabs.org; Fri, 04 Jun 2010 16:03:20 -0400 Received: from [140.186.70.92] (port=59173 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKcOP-0006Bd-DP for qemu-devel@nongnu.org; Fri, 04 Jun 2010 15:17:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKcOO-0002dy-8g for qemu-devel@nongnu.org; Fri, 04 Jun 2010 15:17:21 -0400 Received: from are.twiddle.net ([75.149.56.221]:54819) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKcOO-0002dm-3c for qemu-devel@nongnu.org; Fri, 04 Jun 2010 15:17:20 -0400 Received: from anchor.twiddle.home (anchor.twiddle.home [172.31.0.4]) by are.twiddle.net (Postfix) with ESMTPS id 5886F10AD; Fri, 4 Jun 2010 12:17:19 -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 o54JHIuE007314; Fri, 4 Jun 2010 12:17:18 -0700 Received: (from rth@localhost) by anchor.twiddle.home (8.14.4/8.14.4/Submit) id o54JHGv9007312; Fri, 4 Jun 2010 12:17:16 -0700 From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 Jun 2010 12:14:39 -0700 Message-Id: <1275678883-7082-32-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.0.1 In-Reply-To: <1275678883-7082-1-git-send-email-rth@twiddle.net> References: <1275678883-7082-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 31/35] 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 13c4de6..81d5ad3 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 @@ -301,14 +306,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(); @@ -1091,10 +1104,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; } }