From patchwork Sat Sep 22 02:05:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186069 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F14262C0094 for ; Sat, 22 Sep 2012 13:04:55 +1000 (EST) Received: from localhost ([::1]:43515 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TFF6v-0007LN-Uk for incoming@patchwork.ozlabs.org; Fri, 21 Sep 2012 22:06:25 -0400 Received: from eggs.gnu.org ([208.118.235.92]:57606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TFF60-0005Zm-Nx for qemu-devel@nongnu.org; Fri, 21 Sep 2012 22:05:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TFF5z-0000uH-Ld for qemu-devel@nongnu.org; Fri, 21 Sep 2012 22:05:28 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:56041) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TFF5z-0000d6-Ex for qemu-devel@nongnu.org; Fri, 21 Sep 2012 22:05:27 -0400 Received: by mail-pb0-f45.google.com with SMTP id rp12so8850154pbb.4 for ; Fri, 21 Sep 2012 19:05:27 -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:x-mailer:in-reply-to :references; bh=GaqGlgHC2cvCARMP5x6PmsqfqFC1m/v3D9ODeUwJVCU=; b=sIlRNXO87HAblw+wSn/DNRFdqk39DNMcxQWcGfhrYy+b3eB708T6ZtNSsZIM5Yo/RB 7AhEvdmjiBvbrxWWmu1fzbdhU3edyz22azeiD22dLkibzN9o3tWrcDulVB1CYh2c0mdf msavyKgUwYz99fc0FrRAXXPR1D5iS+6aIPVlWk6qcmu6QsI8D+3MC5Ngo6G49WPPQkJq vsCZdsZ/VDQ6ubAKqlbQNvfeNW8euvp9+mYJ2tA56eUMIIX6748barHHEwuaXHzkQB8o n7g5AzJJvvAAUKw4CKIefLTsu6a/rXwjtDi8l3Ua04VpfAHx4BpU854qgwPKlNQMTQEp LNTQ== Received: by 10.66.90.4 with SMTP id bs4mr17465760pab.3.1348279527159; Fri, 21 Sep 2012 19:05:27 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id s4sm4956298paw.35.2012.09.21.19.05.26 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Sep 2012 19:05:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2012 19:05:07 -0700 Message-Id: <1348279507-3617-15-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348279507-3617-1-git-send-email-rth@twiddle.net> References: <1348279507-3617-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.160.45 Cc: Blue Swirl Subject: [Qemu-devel] [PATCH 14/14] tcg-sparc: Preserve branch destinations during retranslation 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/sparc/tcg-target.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c index 1db0c9d..876da4f 100644 --- a/tcg/sparc/tcg-target.c +++ b/tcg/sparc/tcg-target.c @@ -488,30 +488,33 @@ static inline void tcg_out_nop(TCGContext *s) static void tcg_out_branch_i32(TCGContext *s, int opc, int label_index) { TCGLabel *l = &s->labels[label_index]; + uint32_t off22; if (l->has_value) { - tcg_out32(s, (INSN_OP(0) | INSN_COND(opc, 0) | INSN_OP2(0x2) - | INSN_OFF22(l->u.value - (unsigned long)s->code_ptr))); + off22 = INSN_OFF22(l->u.value - (unsigned long)s->code_ptr); } else { + /* Make sure to preserve destinations during retranslation. */ + off22 = *(uint32_t *)s->code_ptr & INSN_OFF22(-1); tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP22, label_index, 0); - tcg_out32(s, (INSN_OP(0) | INSN_COND(opc, 0) | INSN_OP2(0x2) | 0)); } + tcg_out32(s, INSN_OP(0) | INSN_COND(opc, 0) | INSN_OP2(0x2) | off22); } #if TCG_TARGET_REG_BITS == 64 static void tcg_out_branch_i64(TCGContext *s, int opc, int label_index) { TCGLabel *l = &s->labels[label_index]; + uint32_t off19; if (l->has_value) { - tcg_out32(s, (INSN_OP(0) | INSN_COND(opc, 0) | INSN_OP2(0x1) | - (0x5 << 19) | - INSN_OFF19(l->u.value - (unsigned long)s->code_ptr))); + off19 = INSN_OFF19(l->u.value - (unsigned long)s->code_ptr); } else { + /* Make sure to preserve destinations during retranslation. */ + off19 = *(uint32_t *)s->code_ptr & INSN_OFF19(-1); tcg_out_reloc(s, s->code_ptr, R_SPARC_WDISP19, label_index, 0); - tcg_out32(s, (INSN_OP(0) | INSN_COND(opc, 0) | INSN_OP2(0x1) | - (0x5 << 19) | 0)); } + tcg_out32(s, (INSN_OP(0) | INSN_COND(opc, 0) | INSN_OP2(0x1) | + (0x5 << 19) | off19)); } #endif