From patchwork Thu Dec 12 01:35:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kenneth Zadeck X-Patchwork-Id: 300487 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 57D7E2C0228 for ; Thu, 12 Dec 2013 12:35:50 +1100 (EST) 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:subject:content-type; q= dns; s=default; b=WYUbb0VJdq/p2PLwdxxJpmLVQVB/03PexPq0j8CfURm3yA kIfW//1HhLuT+X0xlJnz8MwzwpzKiuPlPqgOqO8facCs0L6BAEcSpA9ozbPJvWUi hK1jI44Xp/9ejXUmW8yeWxB0QXknx5vaCQBma44GZb+vNzV5riLNOUAGGjOg8= 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:subject:content-type; s= default; bh=qNIrrH+hiYe2Bm9IPBpBK3sPCDQ=; b=mIIAVerQslXY+AwTERYm 6QlY99ZXtBVHPqypowWB2q+e20aU68FHE7m+EJ4YPIFv4Anzick6QtEx8s3k2vnd 1rQUqaJkoLNx5UleUUjO1aqhhkA0rwYxVl581OR0Chx8Bkb/YGPypLas1hzkcylI Q7EVfv01uQBCKBFTSvMSZbk= Received: (qmail 6681 invoked by alias); 12 Dec 2013 01:35:43 -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 6671 invoked by uid 89); 12 Dec 2013 01:35:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-qe0-f47.google.com Received: from mail-qe0-f47.google.com (HELO mail-qe0-f47.google.com) (209.85.128.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 12 Dec 2013 01:35:14 +0000 Received: by mail-qe0-f47.google.com with SMTP id t7so6055399qeb.20 for ; Wed, 11 Dec 2013 17:35:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:content-type; bh=1tti1UE7JRTGMOafurcAPokSL7S3IrhS7rrW2D+38uY=; b=jaqOd41pYLX8ie4T08nYNiS4XUY+a6lPBFAJzZiroATHQx4f7pEn2VcQAfTfHQ93i8 lxUw2malf1TmTmofVY+43a3ft47AqQX4OwWIFEIF1Qx0nKhvAQfiKL6+qtN983zAvDMs +fuSfvq975RLhFu8jeheQ92z5ASIFQ3OuVDbO3Ot/FJNfksj8EEYV8gS29WExW8eMHeJ TsR1jqS6WIOrBJNCjVeEUU/8TfldO+/HaBl0rAdeq/e/RqgFmiC7WCIiI4+rKmgcsSS3 aWtvj8P+p14uK37qt92DrxIgl3wQrtshl9FJeRS6ElbsihqTa/fFgWQuFO2wknG/6Yte i6gg== X-Gm-Message-State: ALoCoQmQAjpZYk8xf7EBtZHtA0YnoEYkYqI4UYQBeZqUz/HUME+7HOYb4j+5+H5GDTyzfJm9eFG+ X-Received: by 10.224.103.71 with SMTP id j7mr1097179qao.71.1386812112040; Wed, 11 Dec 2013 17:35:12 -0800 (PST) Received: from moria.site (pool-98-113-157-168.nycmny.fios.verizon.net. [98.113.157.168]) by mx.google.com with ESMTPSA id hb2sm58530723qeb.6.2013.12.11.17.35.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 11 Dec 2013 17:35:11 -0800 (PST) Message-ID: <52A912CE.1090507@naturalbridge.com> Date: Wed, 11 Dec 2013 20:35:10 -0500 From: Kenneth Zadeck User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: Richard Sandiford , Richard Biener , Mike Stump , gcc-patches Subject: [trunk]: Patch to move BITS_PER_UNIT to be available for genmodes.c This patch is for the trunk, but it solves a problem that comes up for wide-int. For wide-int we need to have the BITS_PER_UNIT available earlier. So this patch sets the default value (8) in genmodes.c so that it is available by anyone who includes insn-modes.h. The generator for tm.h was modified to include insn-modes.h. The value for BITS_PER_UNIT can be overridden by any port by placing a define for it in their target modes file. This patch removes the definition of BITS_PER_UNIT from 7 platform .h files. All of those platforms initialized it to the default value so there was no need for additions to their target modes file. In addition, this target also changes the way that MAX_BITSIZE_MODE_ANY_INT is calculated. The value is heavily used on the wide-int branch to allocate buffers that are used to hold large integer values. The change in the way it is computed was motivated by the i386 port, but there may be other ports that have the same problem. The i386 port defines two very large integer modes that are only used as containers for large vectors. They are never used for large integers. The new way of computing this allows a port to say (very early) that some of these integer modes are never used to hold numbers and so smaller buffers can be used for integer calculations. Other ports that play the same game should follow suit. This patch has been bootstrapped and regression tested on x86-64. Ok to commit? Kenny Index: gcc/config/arc/arc.h =================================================================== --- gcc/config/arc/arc.h (revision 205895) +++ gcc/config/arc/arc.h (working copy) @@ -303,9 +303,6 @@ along with GCC; see the file COPYING3. numbered. */ #define WORDS_BIG_ENDIAN (TARGET_BIG_ENDIAN) -/* Number of bits in an addressable storage unit. */ -#define BITS_PER_UNIT 8 - /* Width in bits of a "word", which is the contents of a machine register. Note that this is not necessarily the width of data type `int'; if using 16-bit ints on a 68000, this would still be 32. Index: gcc/config/bfin/bfin.h =================================================================== --- gcc/config/bfin/bfin.h (revision 205895) +++ gcc/config/bfin/bfin.h (working copy) @@ -859,9 +859,6 @@ typedef struct { /* Define this if most significant word of a multiword number is numbered. */ #define WORDS_BIG_ENDIAN 0 -/* number of bits in an addressable storage unit */ -#define BITS_PER_UNIT 8 - /* Width in bits of a "word", which is the contents of a machine register. Note that this is not necessarily the width of data type `int'; if using 16-bit ints on a 68000, this would still be 32. Index: gcc/config/lm32/lm32.h =================================================================== --- gcc/config/lm32/lm32.h (revision 205895) +++ gcc/config/lm32/lm32.h (working copy) @@ -73,7 +73,6 @@ #define BYTES_BIG_ENDIAN 1 #define WORDS_BIG_ENDIAN 1 -#define BITS_PER_UNIT 8 #define BITS_PER_WORD 32 #define UNITS_PER_WORD 4 Index: gcc/config/m32c/m32c.h =================================================================== --- gcc/config/m32c/m32c.h (revision 205895) +++ gcc/config/m32c/m32c.h (working copy) @@ -140,7 +140,6 @@ machine_function; matches "int". Pointers are 16 bits for R8C/M16C (when TARGET_A16 is true) and 24 bits for M32CM/M32C (when TARGET_A24 is true), but 24-bit pointers are stored in 32-bit words. */ -#define BITS_PER_UNIT 8 #define UNITS_PER_WORD 2 #define POINTER_SIZE (TARGET_A16 ? 16 : 32) #define POINTERS_EXTEND_UNSIGNED 1 Index: gcc/config/microblaze/microblaze.h =================================================================== --- gcc/config/microblaze/microblaze.h (revision 205895) +++ gcc/config/microblaze/microblaze.h (working copy) @@ -193,7 +193,6 @@ extern enum pipeline_type microblaze_pip #define BITS_BIG_ENDIAN 0 #define BYTES_BIG_ENDIAN (TARGET_LITTLE_ENDIAN == 0) #define WORDS_BIG_ENDIAN (BYTES_BIG_ENDIAN) -#define BITS_PER_UNIT 8 #define BITS_PER_WORD 32 #define UNITS_PER_WORD 4 #define MIN_UNITS_PER_WORD 4 Index: gcc/config/picochip/picochip.h =================================================================== --- gcc/config/picochip/picochip.h (revision 205895) +++ gcc/config/picochip/picochip.h (working copy) @@ -92,8 +92,6 @@ extern enum picochip_dfa_type picochip_s #define BYTES_BIG_ENDIAN 0 #define WORDS_BIG_ENDIAN 0 -#define BITS_PER_UNIT 8 - #define BITS_PER_WORD 16 #define UNITS_PER_WORD (BITS_PER_WORD / BITS_PER_UNIT) Index: gcc/config/spu/spu.h =================================================================== --- gcc/config/spu/spu.h (revision 205895) +++ gcc/config/spu/spu.h (working copy) @@ -54,8 +54,6 @@ extern GTY(()) int spu_tune; #define WORDS_BIG_ENDIAN 1 -#define BITS_PER_UNIT 8 - /* GCC uses word_mode in many places, assuming that it is the fastest integer mode. That is not the case for SPU though. We can't use 32 here because (of some reason I can't remember.) */ Index: gcc/defaults.h =================================================================== --- gcc/defaults.h (revision 205895) +++ gcc/defaults.h (working copy) @@ -471,10 +471,6 @@ see the files COPYING3 and COPYING.RUNTI your target, you should override these values by defining the appropriate symbols in your tm.h file. */ -#ifndef BITS_PER_UNIT -#define BITS_PER_UNIT 8 -#endif - #ifndef BITS_PER_WORD #define BITS_PER_WORD (BITS_PER_UNIT * UNITS_PER_WORD) #endif Index: gcc/config/i386/i386-modes.def =================================================================== --- gcc/config/i386/i386-modes.def (revision 205895) +++ gcc/config/i386/i386-modes.def (working copy) @@ -90,5 +90,10 @@ VECTOR_MODE (INT, QI, 2); /* INT_MODE (OI, 32); INT_MODE (XI, 64); +/* Keep the OI and XI modes from confusing the compiler into thinking + that these modes could actually be used for computation. They are + only holders for vectors during data movement. */ +#define MAX_BITSIZE_MODE_ANY_INT (128) + /* The symbol Pmode stands for one of the above machine modes (usually SImode). The tm.h file specifies which one. It is not a distinct mode. */ Index: gcc/doc/rtl.texi =================================================================== --- gcc/doc/rtl.texi (revision 205895) +++ gcc/doc/rtl.texi (working copy) @@ -1462,14 +1462,24 @@ Returns the number of units contained in Returns the narrowest mode in mode class @var{c}. @end table -The following 4 variables are defined on every target. They can be +The following 3 variables are defined on every target. They can be used to allocate buffers that are guaranteed to be large enough to -hold any value that can be represented on the target. +hold any value that can be represented on the target. The first two +can be overridden by defining them in the target's mode.def file. +The third cannot. @table @code +@findex BITS_PER_UNIT +@item BITS_PER_UNIT +The number of bits in an addressable storage unit (byte). If you do +not define this, the default is 8. + @findex MAX_BITSIZE_MODE_ANY_INT @item MAX_BITSIZE_MODE_ANY_INT -The maximum of MAX_BITSIZE_MODE_INT and MAX_BITSIZE_MODE_PARTIAL_INT. +The maximum bitsize of any mode that is used in integer math. This +should be overridden by the target if it uses large integers as +containers for larger vectors but otherwise never uses the contents to +compute integer values. @findex MAX_BITSIZE_MODE_ANY_MODE @item MAX_BITSIZE_MODE_ANY_MODE Index: gcc/doc/tm.texi =================================================================== --- gcc/doc/tm.texi (revision 205895) +++ gcc/doc/tm.texi (working copy) @@ -879,11 +879,6 @@ You need not define this macro if the or multi-word integers. @end defmac -@defmac BITS_PER_UNIT -Define this macro to be the number of bits in an addressable storage -unit (byte). If you do not define this macro the default is 8. -@end defmac - @defmac BITS_PER_WORD Number of bits in a word. If you do not define this macro, the default is @code{BITS_PER_UNIT * UNITS_PER_WORD}. Index: gcc/doc/tm.texi.in =================================================================== --- gcc/doc/tm.texi.in (revision 205895) +++ gcc/doc/tm.texi.in (working copy) @@ -853,11 +853,6 @@ You need not define this macro if the or multi-word integers. @end defmac -@defmac BITS_PER_UNIT -Define this macro to be the number of bits in an addressable storage -unit (byte). If you do not define this macro the default is 8. -@end defmac - @defmac BITS_PER_WORD Number of bits in a word. If you do not define this macro, the default is @code{BITS_PER_UNIT * UNITS_PER_WORD}. Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c (revision 205895) +++ gcc/genmodes.c (working copy) @@ -711,10 +711,27 @@ make_vector_mode (enum mode_class bclass #define ADJUST_IBIT(M, X) _ADD_ADJUST (ibit, M, X, ACCUM, UACCUM) #define ADJUST_FBIT(M, X) _ADD_ADJUST (fbit, M, X, FRACT, UACCUM) +static int bits_per_unit; +static int max_bitsize_mode_any_int; + static void create_modes (void) { #include "machmode.def" + + /* So put the default value unless the target needs a non standard + value. */ +#ifdef BITS_PER_UNIT + bits_per_unit = BITS_PER_UNIT; +#else + bits_per_unit = 8; +#endif + +#ifdef MAX_BITSIZE_MODE_ANY_INT + max_bitsize_mode_any_int = MAX_BITSIZE_MODE_ANY_INT; +#else + max_bitsize_mode_any_int = 0; +#endif } /* Processing. */ @@ -860,16 +877,24 @@ emit_max_int (void) int j; puts (""); - for (max = 1, i = modes[MODE_INT]; i; i = i->next) - if (max < i->bytesize) - max = i->bytesize; - mmax = max; - for (max = 1, i = modes[MODE_PARTIAL_INT]; i; i = i->next) - if (max < i->bytesize) - max = i->bytesize; - if (max > mmax) - mmax = max; - printf ("#define MAX_BITSIZE_MODE_ANY_INT %d*BITS_PER_UNIT\n", mmax); + + printf ("#define BITS_PER_UNIT (%d)\n", bits_per_unit); + + if (max_bitsize_mode_any_int == 0) + { + for (max = 1, i = modes[MODE_INT]; i; i = i->next) + if (max < i->bytesize) + max = i->bytesize; + mmax = max; + for (max = 1, i = modes[MODE_PARTIAL_INT]; i; i = i->next) + if (max < i->bytesize) + max = i->bytesize; + if (max > mmax) + mmax = max; + printf ("#define MAX_BITSIZE_MODE_ANY_INT %d*BITS_PER_UNIT\n", mmax); + } + else + printf ("#define MAX_BITSIZE_MODE_ANY_INT %d\n", max_bitsize_mode_any_int); mmax = 0; for (j = 0; j < MAX_MODE_CLASS; j++) Index: gcc/mkconfig.sh =================================================================== --- gcc/mkconfig.sh (revision 205895) +++ gcc/mkconfig.sh (working copy) @@ -97,6 +97,9 @@ case $output in #if defined IN_GCC && !defined GENERATOR_FILE && !defined USED_FOR_TARGET # include "insn-flags.h" #endif +#if defined IN_GCC && !defined GENERATOR_FILE +# include "insn-modes.h" +#endif EOF ;; esac