From patchwork Thu Jul 13 08:43:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107601 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1928034qge; Thu, 13 Jul 2017 01:44:34 -0700 (PDT) X-Received: by 10.84.232.197 with SMTP id x5mr8901290plm.159.1499935474194; Thu, 13 Jul 2017 01:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499935474; cv=none; d=google.com; s=arc-20160816; b=BJUutjm+H68hciO+YqbbDKU1B+uWCacS5NrTA5SROKzUbBA0WJww8S7TyApNup4xBB 8uKJy5rR7XvL3A7LzosM3hkxCU1ND53+XruofPASiq1URnPebkXgyTYUKJUqxEv3blKq rcNiE3kw5eq4F1XhvLczKu1+AmpkRNhepJZvVT8dr+Qsm0pEh+C3HsYuWBGQ4EWIcfnC 7zI6syKVbZ2haWrlneYbNd/9BpkHlmuHKlk+GK8MjlMF8GybqNfcIcOfP5LQ03T2UNNM EnSFegk+2KDWx7goCFXAYawPUWxxDkeLkMM+Ofn9kTsrdaBHLJedntwS8hrKssVtusSE sbLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=Qk0/qm4bSbjU0bUzlfQvPakH6AgYcq5a7vapBZmODNA=; b=FtDuKH61P5wI7vvk8qLSJpYuvgGLf/B1vs/XrmlVpTApwbG2M4t9sV63RclIuK7VdW 7zrieFp3y2QkqFt94F1Fn6aZsqPhdpqR4MnN3CI7T8i1lpc8IenpcQxBcb9BIdnOhQgZ Wvy+XmbdvffOLeAl8yMYmXQI9mGsX6p7UYbE4UBzqA7J6BwLQqL8YN6IPhsOJEx0hUev 9/tH1RRNmyQPDBAg6yTl55VrxkecOyKfoyUZSSW+UhOSd3lKA688w1whm85WmlyPsTuq LGf62lFGtPHjOgqEIcZ4tengacS29yAH/TfPL/i1ET3RZ0q2Axvk3ZZPjgpZO0fhnpo5 ytyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=jnHB/kEl; spf=pass (google.com: domain of gcc-patches-return-458005-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458005-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g193si3785115pfb.20.2017.07.13.01.44.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 01:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458005-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=jnHB/kEl; spf=pass (google.com: domain of gcc-patches-return-458005-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458005-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=dvcGuPKGtxpM6GljjCaRqQtTBT6CV ifhmnv+ZhqC5A0sj0ngv10ph/mqNVnJ7f7HOHvB2D5U93ZQXxlCvzX/R7qP8O1w4 5/9Lp3NMa0QTtlo1Vc+qU14/3kswqQptoO5zxF7yH2JmKARZIifyYdMmkP4PDAux khnMBYn0Fdk0Cs= 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=7vkYSmcC0Vr31uaHZhtcXbgYaZg=; b=jnH B/kEldXBBkPZhMnrf7MFM4EX1Poto4VQQpnMPO1mjvfmi3AmOhgaAF3V5zyaAF+9 uiVwUOc108vjI4wJx99QJHIfK61brkYzDgfz5n46GM4BupyMKYT5dTBGHqRsZf+y 546gjjky4JtMkL2GqA8RIl+7o0KiFGEdHSp4I92U= Received: (qmail 46575 invoked by alias); 13 Jul 2017 08:44:07 -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 45917 invoked by uid 89); 13 Jul 2017 08:44:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f171.google.com Received: from mail-wr0-f171.google.com (HELO mail-wr0-f171.google.com) (209.85.128.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:44:03 +0000 Received: by mail-wr0-f171.google.com with SMTP id 77so49565660wrb.1 for ; Thu, 13 Jul 2017 01:44:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=Qk0/qm4bSbjU0bUzlfQvPakH6AgYcq5a7vapBZmODNA=; b=Ex3A/cQiCIr3j2+kO0+brMFvkiRx0Vervp/H3bGTDuP9F1wD4Z1WzQy3b9XriTbWvX 7SupUHQkuxVin7DIpj12cjtxsDK5xDxKKyF2G93V/TrGhZI5Fomu/b4964llgmI3c2eb /ETRmGAxd59ry9rhmziJRwu5dgo04X7oBClLQXVMmqjriVMb2b1hiistRgmt7j0utolR 9R4Wr8s4naHPwsYXO8DtTkacuHENSGQjsyRJJT7TIaFspDDr/MqE3R7FnIaZu3s2BEq+ +sqGxzTnarQ2B7CeMfDLFNvu7suTIpijGPhbYOrrLr7C8+V2fqzt0VILHT1uT+HDRtqq 5I7g== X-Gm-Message-State: AIVw1125X2zEIFzR+BmW1H8O/nFyYCAHZ0H2sYEG92sKwen9tTWXFcOn MR8E5R4EWiJKnYzwpss7Lg== X-Received: by 10.223.180.67 with SMTP id v3mr1089686wrd.0.1499935441251; Thu, 13 Jul 2017 01:44:01 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id o6sm4824709wrc.48.2017.07.13.01.44.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:44:00 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [15/77] Add scalar_int_mode References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:43:59 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87d194loa8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (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 a token change to the types of byte_mode, word_mode, ptr_mode and rs6000_pmode. The next patches in the series gradually replace more uses. The patch also removes and adds casts to some target-specific code due to the new types of SImode, DImode and Pmode. The as_a goes away in a later patch. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * config/powerpcspe/powerpcspe.h (rs6000_pmode): Change type from machine_mode to scalar_int_mode. * config/powerpcspe/powerpcspe.c (rs6000_pmode): Likewise. (rs6000_option_override_internal): Remove cast to int. * config/rs6000/rs6000.h (rs6000_pmode): Change type from machine_mode to scalar_int_mode. * config/rs6000/rs6000.c (rs6000_pmode): Likewise. (rs6000_option_override_internal): Remove cast to int. * config/s390/s390.h (Pmode): Remove cast to machine_mode. * config/epiphany/epiphany.h (RTX_OK_FOR_OFFSET_P): Add cast to machine_mode. * config/s390/s390.c (s390_expand_builtin): Likewise. * 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. (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. * gdbhooks.py (build_pretty_printer): Handle scalar_int_mode and opt_scalar_int_mode. Index: gcc/config/powerpcspe/powerpcspe.h =================================================================== --- gcc/config/powerpcspe/powerpcspe.h 2017-05-31 10:02:30.662209641 +0100 +++ gcc/config/powerpcspe/powerpcspe.h 2017-07-13 09:18:28.018772114 +0100 @@ -2220,8 +2220,8 @@ #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects of this machine mode. */ -extern unsigned rs6000_pmode; -#define Pmode ((machine_mode)rs6000_pmode) +extern scalar_int_mode rs6000_pmode; +#define Pmode rs6000_pmode /* Supply definition of STACK_SIZE_MODE for allocate_dynamic_stack_space. */ #define STACK_SIZE_MODE (TARGET_32BIT ? SImode : DImode) Index: gcc/config/powerpcspe/powerpcspe.c =================================================================== --- gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:26.902879083 +0100 +++ gcc/config/powerpcspe/powerpcspe.c 2017-07-13 09:18:28.017772208 +0100 @@ -185,9 +185,8 @@ int fixuplabelno = 0; /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects - of this machine mode. The type is unsigned since not all things that - include powerpcspe.h also include machmode.h. */ -unsigned rs6000_pmode; + of this machine mode. */ +scalar_int_mode rs6000_pmode; /* Width in bits of a pointer. */ unsigned rs6000_pointer_size; @@ -4037,12 +4036,12 @@ rs6000_option_override_internal (bool gl /* Set the pointer size. */ if (TARGET_64BIT) { - rs6000_pmode = (int)DImode; + rs6000_pmode = DImode; rs6000_pointer_size = 64; } else { - rs6000_pmode = (int)SImode; + rs6000_pmode = SImode; rs6000_pointer_size = 32; } Index: gcc/config/rs6000/rs6000.h =================================================================== --- gcc/config/rs6000/rs6000.h 2017-06-16 07:49:01.468066725 +0100 +++ gcc/config/rs6000/rs6000.h 2017-07-13 09:18:28.021771829 +0100 @@ -2130,8 +2130,8 @@ #define CTZ_DEFINED_VALUE_AT_ZERO(MODE, /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects of this machine mode. */ -extern unsigned rs6000_pmode; -#define Pmode ((machine_mode)rs6000_pmode) +extern scalar_int_mode rs6000_pmode; +#define Pmode rs6000_pmode /* Supply definition of STACK_SIZE_MODE for allocate_dynamic_stack_space. */ #define STACK_SIZE_MODE (TARGET_32BIT ? SImode : DImode) Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c 2017-07-13 09:18:26.909878405 +0100 +++ gcc/config/rs6000/rs6000.c 2017-07-13 09:18:28.021771829 +0100 @@ -181,9 +181,8 @@ int fixuplabelno = 0; /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects - of this machine mode. The type is unsigned since not all things that - include rs6000.h also include machmode.h. */ -unsigned rs6000_pmode; + of this machine mode. */ +scalar_int_mode rs6000_pmode; /* Width in bits of a pointer. */ unsigned rs6000_pointer_size; @@ -3987,12 +3986,12 @@ rs6000_option_override_internal (bool gl /* Set the pointer size. */ if (TARGET_64BIT) { - rs6000_pmode = (int)DImode; + rs6000_pmode = DImode; rs6000_pointer_size = 64; } else { - rs6000_pmode = (int)SImode; + rs6000_pmode = SImode; rs6000_pointer_size = 32; } Index: gcc/config/s390/s390.h =================================================================== --- gcc/config/s390/s390.h 2017-06-30 12:50:38.649643966 +0100 +++ gcc/config/s390/s390.h 2017-07-13 09:18:28.023771640 +0100 @@ -1053,7 +1053,7 @@ #define TRULY_NOOP_TRUNCATION(OUTPREC, I /* Specify the machine mode that pointers have. After generation of rtl, the compiler makes no further distinction between pointers and any other objects of this machine mode. */ -#define Pmode ((machine_mode) (TARGET_64BIT ? DImode : SImode)) +#define Pmode (TARGET_64BIT ? DImode : SImode) /* This is -1 for "pointer mode" extend. See ptr_extend in s390.md. */ #define POINTERS_EXTEND_UNSIGNED -1 Index: gcc/config/epiphany/epiphany.h =================================================================== --- gcc/config/epiphany/epiphany.h 2017-02-23 19:54:23.000000000 +0000 +++ gcc/config/epiphany/epiphany.h 2017-07-13 09:18:28.013772588 +0100 @@ -641,7 +641,8 @@ #define CONSTANT_ADDRESS_P(X) \ #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)) \ Index: gcc/config/s390/s390.c =================================================================== --- gcc/config/s390/s390.c 2017-07-13 09:18:25.330032056 +0100 +++ gcc/config/s390/s390.c 2017-07-13 09:18:28.023771640 +0100 @@ -995,7 +995,7 @@ #define MAX_ARGS 6 so we cannot use this. */ machine_mode target_mode = (insn_op->predicate == address_operand - ? Pmode : insn_op->mode); + ? (machine_mode) Pmode : insn_op->mode); op[arity] = copy_to_mode_reg (target_mode, op[arity]); } Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:25.915974717 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:28.023771640 +0100 @@ -55,8 +55,10 @@ typedef const struct simple_bitmap_def * struct rtx_def; typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; +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 @@ -313,6 +315,7 @@ #define rtx_insn struct _dont_use_rtx_in #define tree union _dont_use_tree_here_ * #define const_tree union _dont_use_tree_here_ * +typedef struct scalar_int_mode scalar_int_mode; typedef struct scalar_float_mode scalar_float_mode; #endif Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:26.363931259 +0100 +++ gcc/machmode.h 2017-07-13 09:18:28.024771545 +0100 @@ -339,6 +339,30 @@ is_a (machine_mode m, U *result) return false; } +/* Represents a machine mode that is known to be a SCALAR_INT_MODE_P. */ +class scalar_int_mode +{ +public: + typedef mode_traits::from_int from_int; + + ALWAYS_INLINE scalar_int_mode () {} + ALWAYS_INLINE scalar_int_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + static bool includes_p (machine_mode); + +protected: + machine_mode m_mode; +}; + +/* Return true if M is a scalar_int_mode. */ + +inline bool +scalar_int_mode::includes_p (machine_mode m) +{ + return SCALAR_INT_MODE_P (m); +} + /* Represents a machine mode that is known to be a SCALAR_FLOAT_MODE_P. */ class scalar_float_mode { @@ -606,9 +630,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); Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2017-07-13 09:18:25.916974620 +0100 +++ gcc/emit-rtl.c 2017-07-13 09:18:28.024771545 +0100 @@ -69,9 +69,9 @@ #define initial_regno_reg_rtx (this_targ /* 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. */ @@ -5869,22 +5869,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. */ Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:23.798185961 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:28.024771545 +0100 @@ -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"; Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:25.916974620 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:28.024771545 +0100 @@ -542,10 +542,11 @@ def build_pretty_printer(): pp.add_printer_for_regex(r'opt_mode<(\S+)>', 'opt_mode', OptMachineModePrinter) - pp.add_printer_for_types(['opt_scalar_float_mode'], + pp.add_printer_for_types(['opt_scalar_int_mode', + 'opt_scalar_float_mode'], 'opt_mode', OptMachineModePrinter) - pp.add_printer_for_types(['scalar_float_mode'], - 'scalar_float_mode', MachineModePrinter) + for mode in 'scalar_int_mode', 'scalar_float_mode': + pp.add_printer_for_types([mode], mode, MachineModePrinter) return pp