From patchwork Fri Dec 9 13:02:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 704486 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 3tZsq03gw9z9vFT for ; Sat, 10 Dec 2016 00:03:08 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="eoGTfWdA"; 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:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=XSsPITTIiCq6DA6vI6mQHHTzv1xuO x6H+bcsH9CPdfFnsAAF6A4UvE5p/54lyu1+/GoDJ4EtWxYYeqzlAZT9AqHwSvA1a B+36YWZMHD8UNr34wm6F6w0gc5NlVrDb7bz17ZwIv2Wrxj5tIMiBplg0KAzDCw9T JNZpzNFBa4riKc= 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:from :to:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=eNiFq/TzHXQu3X6shEC6G4Tf6fo=; b=eoG TfWdAmlSKAyOKYsz95yGe//n9hR78JP0rOtfFNIzeAIqlZQlKND1XA+2nw7xjSRt c0OdK//dLxKEv5BUYSyzYAxxP1tNvHKki2zaO0Fv9G5Ez0SpLg++3JSVqEGykP0r L4IulhJU1+bQrjAdO5D6eHGKKJsCau58hHMpW7GU= Received: (qmail 46651 invoked by alias); 9 Dec 2016 13:03:00 -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 46618 invoked by uid 89); 9 Dec 2016 13:02:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= 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; Fri, 09 Dec 2016 13:02:52 +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 42306707; Fri, 9 Dec 2016 05:02:51 -0800 (PST) Received: from localhost (e105548-lin.manchester.arm.com [10.45.32.67]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4E3673F477 for ; Fri, 9 Dec 2016 05:02:49 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: [15/67] Add scalar_int_mode References: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> Date: Fri, 09 Dec 2016 13:02:48 +0000 In-Reply-To: <87h96dp8u6.fsf@e105548-lin.cambridge.arm.com> (Richard Sandiford's message of "Fri, 09 Dec 2016 12:48:01 +0000") Message-ID: <87oa0lmf0n.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Similar to the previous scalar_float_mode patch, but for modes that satisfy SCALAR_INT_MODE_P. There are very many uses of scalar integers, so this patch only makes one token change to the types of byte_mode, word_mode and ptr_mode. The next patches in the series gradually replace more uses. gcc/ 2016-11-24 Richard Sandiford Alan Hayward David Sherwood * config/epiphany/epiphany.h (RTX_OK_FOR_OFFSET_P): Add casts to machine_mode. * coretypes.h (scalar_int_mode): New type. (opt_scalar_int_mode): New typedef. * machmode.h (scalar_int_mode): New class. (scalar_int_mode::includes_p): New function. (scalar_int_mode::from_int): New function. (byte_mode): Change type to scalar_int_mode. (word_mode): Likewise. (ptr_mode): Likewise. * emit-rtl.c (byte_mode): Likewise. (word_mode): Likewise. (ptr_mode): Likewise. (init_derived_machine_modes): Update accordingly. * genmodes.c (get_mode_class): Return scalar_int_mode for MODE_INT and MODE_PARTIAL_INT. diff --git a/gcc/config/epiphany/epiphany.h b/gcc/config/epiphany/epiphany.h index 9e7ee50..3818af3 100644 --- a/gcc/config/epiphany/epiphany.h +++ b/gcc/config/epiphany/epiphany.h @@ -641,7 +641,8 @@ typedef struct GTY (()) machine_function #define RTX_OK_FOR_OFFSET_P(MODE, X) \ RTX_OK_FOR_OFFSET_1 (GET_MODE_CLASS (MODE) == MODE_VECTOR_INT \ - && epiphany_vect_align == 4 ? SImode : (MODE), X) + && epiphany_vect_align == 4 \ + ? (machine_mode) SImode : (machine_mode) (MODE), X) #define RTX_OK_FOR_OFFSET_1(MODE, X) \ (GET_CODE (X) == CONST_INT \ && !(INTVAL (X) & (GET_MODE_SIZE (MODE) - 1)) \ diff --git a/gcc/coretypes.h b/gcc/coretypes.h index 8341cab..6dc3e88 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -56,8 +56,10 @@ struct rtx_def; typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; class machine_mode; +class scalar_int_mode; class scalar_float_mode; template class opt_mode; +typedef opt_mode opt_scalar_int_mode; typedef opt_mode opt_scalar_float_mode; /* Subclasses of rtx_def, using indentation to show the class diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index efddad4..b9d87d3 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -69,9 +69,9 @@ struct target_rtl *this_target_rtl = &default_target_rtl; /* Commonly used modes. */ -machine_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */ -machine_mode word_mode; /* Mode whose width is BITS_PER_WORD. */ -machine_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */ +scalar_int_mode byte_mode; /* Mode whose width is BITS_PER_UNIT. */ +scalar_int_mode word_mode; /* Mode whose width is BITS_PER_WORD. */ +scalar_int_mode ptr_mode; /* Mode whose width is POINTER_SIZE. */ /* Datastructures maintained for currently processed function in RTL form. */ @@ -5838,22 +5838,24 @@ init_emit_regs (void) void init_derived_machine_modes (void) { - byte_mode = VOIDmode; - word_mode = VOIDmode; - - machine_mode mode; - FOR_EACH_MODE_IN_CLASS (mode, MODE_INT) + opt_scalar_int_mode mode_iter, opt_byte_mode, opt_word_mode; + FOR_EACH_MODE_IN_CLASS (mode_iter, MODE_INT) { + scalar_int_mode mode = *mode_iter; + if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT - && byte_mode == VOIDmode) - byte_mode = mode; + && !opt_byte_mode.exists ()) + opt_byte_mode = mode; if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD - && word_mode == VOIDmode) - word_mode = mode; + && !opt_word_mode.exists ()) + opt_word_mode = mode; } - ptr_mode = mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0); + byte_mode = *opt_byte_mode; + word_mode = *opt_word_mode; + ptr_mode = as_a (mode_for_size (POINTER_SIZE, + MODE_INT, 0)); } /* Create some permanent unique rtl objects shared between all functions. */ diff --git a/gcc/genmodes.c b/gcc/genmodes.c index 3cc426e..eddbff7 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -1137,6 +1137,10 @@ get_mode_class (struct mode_data *mode) { switch (mode->cl) { + case MODE_INT: + case MODE_PARTIAL_INT: + return "scalar_int_mode"; + case MODE_FLOAT: case MODE_DECIMAL_FLOAT: return "scalar_float_mode"; diff --git a/gcc/machmode.h b/gcc/machmode.h index 2f4b076..8c8dd54 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -292,6 +292,40 @@ is_a (machine_mode_enum m, U *result) return false; } +/* Represents a machine mode that is known to be a SCALAR_INT_MODE_P. */ +class scalar_int_mode +{ +public: + ALWAYS_INLINE scalar_int_mode () {} + ALWAYS_INLINE operator machine_mode_enum () const { return m_mode; } + + static bool includes_p (machine_mode_enum); + static scalar_int_mode from_int (int); + +PROTECT_ENUM_CONVERSION: + ALWAYS_INLINE scalar_int_mode (machine_mode_enum m) : m_mode (m) {} + +protected: + machine_mode_enum m_mode; +}; + +/* Return true if M is a scalar_int_mode. */ + +inline bool +scalar_int_mode::includes_p (machine_mode_enum m) +{ + return SCALAR_INT_MODE_P (m); +} + +/* Return M as a scalar_int_mode. This function should only be used by + utility functions; general code should use as_a instead. */ + +ALWAYS_INLINE scalar_int_mode +scalar_int_mode::from_int (int i) +{ + return machine_mode_enum (i); +} + /* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */ class scalar_float_mode { @@ -597,9 +631,9 @@ get_narrowest_mode (T mode) /* Define the integer modes whose sizes are BITS_PER_UNIT and BITS_PER_WORD and the mode whose class is Pmode and whose size is POINTER_SIZE. */ -extern machine_mode byte_mode; -extern machine_mode word_mode; -extern machine_mode ptr_mode; +extern scalar_int_mode byte_mode; +extern scalar_int_mode word_mode; +extern scalar_int_mode ptr_mode; /* Target-dependent machine mode initialization - in insn-modes.c. */ extern void init_adjust_machine_modes (void);