From patchwork Wed May 14 07:17:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 348625 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C8D671400E1 for ; Wed, 14 May 2014 17:22:31 +1000 (EST) Received: from localhost ([::1]:49650 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkTWH-0000Aj-KQ for incoming@patchwork.ozlabs.org; Wed, 14 May 2014 03:22:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59705) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkTS9-0000Js-C2 for qemu-devel@nongnu.org; Wed, 14 May 2014 03:18:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkTS3-0006eU-6y for qemu-devel@nongnu.org; Wed, 14 May 2014 03:18:13 -0400 Received: from mail-pa0-x22c.google.com ([2607:f8b0:400e:c03::22c]:46770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkTS3-0006dz-0Y for qemu-devel@nongnu.org; Wed, 14 May 2014 03:18:07 -0400 Received: by mail-pa0-f44.google.com with SMTP id ld10so1334741pab.3 for ; Wed, 14 May 2014 00:18:06 -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=80sciCbxPCuhzgDPdxxH2g6CqRH2NYFkLWHUdLmSi1E=; b=VTjeoAgcK9NlADhjRLe8iyKAtTFVFTZOHHGGyvFnf5lfjUzlMzApaPG6g1UxOky350 1l63b7udBF7jJc3qoxwhMrCcwrh7qsguiX5anwDjtiZFU2tcTdzcA0nJj8McnKhUWIGs o+NlMTNddNV9KF0BwU2IPx/roiNGx7YRBNbjgK/XUiJAgM5JFeEwvTfMlLavXkMbaqjm 4222V5GVK6lAITxdpf6eR3paV6WGQBVlqDnlmYu/Z3iU5PSICtH1LKeCHzq/FLY7vOw2 m4P+GrtFEX1HCsSQCPlOs3D9KxHSfXb+frKKg8wSaDcRvEiQUq7ur7u/o5UCp1UlphLY aOMw== X-Received: by 10.68.192.106 with SMTP id hf10mr2381465pbc.30.1400051886286; Wed, 14 May 2014 00:18:06 -0700 (PDT) Received: from anchor.twiddle.net (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id bq4sm1760614pbb.60.2014.05.14.00.18.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 May 2014 00:18:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 14 May 2014 00:17:31 -0700 Message-Id: <1400051861-5848-15-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1400051861-5848-1-git-send-email-rth@twiddle.net> References: <1400051861-5848-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::22c Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 14/24] tcg-mips: Fix subtract immediate range 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 Since we must use ADDUI, we would generate incorrect code for -32768. Leaving off subtract of +32768 makes things easier for a follow-on patch. Signed-off-by: Richard Henderson --- tcg/mips/tcg-target.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/tcg/mips/tcg-target.c b/tcg/mips/tcg-target.c index 920208a..5021dea 100644 --- a/tcg/mips/tcg-target.c +++ b/tcg/mips/tcg-target.c @@ -156,9 +156,10 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, } #define TCG_CT_CONST_ZERO 0x100 -#define TCG_CT_CONST_U16 0x200 -#define TCG_CT_CONST_S16 0x400 -#define TCG_CT_CONST_P2M1 0x800 +#define TCG_CT_CONST_U16 0x200 /* Unsigned 16-bit: 0 - 0xffff. */ +#define TCG_CT_CONST_S16 0x400 /* Signed 16-bit: -32768 - 32767 */ +#define TCG_CT_CONST_P2M1 0x800 /* Power of 2 minus 1. */ +#define TCG_CT_CONST_N16 0x1000 /* "Negatable" 16-bit: -32767 - 32767 */ static inline bool is_p2m1(tcg_target_long val) { @@ -213,6 +214,9 @@ static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str) case 'K': ct->ct |= TCG_CT_CONST_P2M1; break; + case 'N': + ct->ct |= TCG_CT_CONST_N16; + break; case 'Z': /* We are cheating a bit here, using the fact that the register ZERO is also the register number 0. Hence there is no need @@ -241,6 +245,8 @@ static inline int tcg_target_const_match(tcg_target_long val, TCGType type, return 1; } else if ((ct & TCG_CT_CONST_S16) && val == (int16_t)val) { return 1; + } else if ((ct & TCG_CT_CONST_N16) && val >= -32767 && val <= 32767) { + return 1; } else if ((ct & TCG_CT_CONST_P2M1) && use_mips32r2_instructions && is_p2m1(val)) { return 1; @@ -1642,7 +1648,7 @@ static const TCGTargetOpDef mips_op_defs[] = { { INDEX_op_divu_i32, { "r", "rZ", "rZ" } }, { INDEX_op_rem_i32, { "r", "rZ", "rZ" } }, { INDEX_op_remu_i32, { "r", "rZ", "rZ" } }, - { INDEX_op_sub_i32, { "r", "rZ", "rJ" } }, + { INDEX_op_sub_i32, { "r", "rZ", "rN" } }, { INDEX_op_and_i32, { "r", "rZ", "rIK" } }, { INDEX_op_nor_i32, { "r", "rZ", "rZ" } }, @@ -1670,7 +1676,7 @@ static const TCGTargetOpDef mips_op_defs[] = { { INDEX_op_setcond2_i32, { "r", "rZ", "rZ", "rZ", "rZ" } }, { INDEX_op_add2_i32, { "r", "r", "rZ", "rZ", "rJ", "rJ" } }, - { INDEX_op_sub2_i32, { "r", "r", "rZ", "rZ", "rJ", "rJ" } }, + { INDEX_op_sub2_i32, { "r", "r", "rZ", "rZ", "rN", "rN" } }, { INDEX_op_brcond2_i32, { "rZ", "rZ", "rZ", "rZ" } }, #if TARGET_LONG_BITS == 32