From patchwork Tue Feb 7 10:45:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 725067 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vHgwj05QRz9ryZ for ; Tue, 7 Feb 2017 21:45:35 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sJQQ9YWz"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=SkO3tGbr5C+p7OL6TyeoLiRrQNYusZJeud2mn+1qH7X y7rjpmDOuR0YywYucYOkIptljfKKOtU1vD1ZFoPtO3WOQKeh0MFJz1/QNs7OTaKm v1Awkxj2e5+q+rMvDwCTBsNrnoN/R7ZmgNAj9FDqiV/6RmY20VwdMRmMjXg9cj38 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=JEXxmZe3dYQB+JNQzVyTt3FEVAY=; b=sJQQ9YWzvFkgAO0p6 x/lnVCdLIP5FQkTB21MTiv//FdaAYgbaqIRjuvXIsdt2fSaSTj6S5kb/OA+UFWYS hL7kccB1FzWnyee3DcNnkmNXTSSQTv1AJH4nss411CS4YhHnWI7VtqCqQzwhMxMM NyKUQx8tC+IzxaToKH4LgQOGnI= Received: (qmail 102823 invoked by alias); 7 Feb 2017 10:45:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 102795 invoked by uid 89); 7 Feb 2017 10:45:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.8 required=5.0 tests=BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=himode, HImode, INT16_MAX, kyrill X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Feb 2017 10:45:16 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BA46314F6; Tue, 7 Feb 2017 02:45:04 -0800 (PST) Received: from [10.2.207.77] (e100706-lin.cambridge.arm.com [10.2.207.77]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1ED2C3F477; Tue, 7 Feb 2017 02:45:03 -0800 (PST) Message-ID: <5899A52E.1000809@foss.arm.com> Date: Tue, 07 Feb 2017 10:45:02 +0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: palmer@dabbelt.com, andrew@sifive.com Subject: [PATCH][riscv] Fix build due to INT16_MAX issue Hi all, I tried building a cc1 for riscv-x-elf and I got a build error about INT16_MAX not being defined on my system. I think it's not a standard macro. This patch fixes that with what I think is the equivalent definition using GCC modes logic. With this my build proceeds to build a cc1 successfully. No testing beyond that. Is this ok for trunk? Thanks, Kyrill P.S. Palmer, Andrew, I didn't see your names and emails in the MAINTAINERS file, you should update that when you get the chance. 2016-02-07 Kyrylo Tkachov * config/riscv/riscv.c (riscv_build_integer_1): Avoid use of INT16_MAX. diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index 834651f..89567f7 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -356,7 +356,9 @@ riscv_build_integer_1 (struct riscv_integer_op codes[RISCV_MAX_INTEGER_OPS], /* End with ADDI. When constructing HImode constants, do not generate any intermediate value that is not itself a valid HImode constant. The XORI case below will handle those remaining HImode constants. */ - if (low_part != 0 && (mode != HImode || value - low_part <= INT16_MAX)) + if (low_part != 0 + && (mode != HImode + || value - low_part <= ((1 << (GET_MODE_BITSIZE (HImode) - 1)) - 1))) { alt_cost = 1 + riscv_build_integer_1 (alt_codes, value - low_part, mode); if (alt_cost < cost)