From patchwork Thu Jul 13 09:01:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107650 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1943600qge; Thu, 13 Jul 2017 02:03:28 -0700 (PDT) X-Received: by 10.84.167.230 with SMTP id i35mr9106146plg.181.1499936608497; Thu, 13 Jul 2017 02:03:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936608; cv=none; d=google.com; s=arc-20160816; b=Grt5J920RjRxu4bI6BreR6uYVxg0grjxt3CjvjQ2BZktTJMJX2X/6tQkCBPE40Ul87 F04rnIXLVc2tppxb9fTP269g/dzoKV2K5uOwZeZmMuf4OkXboRsOyymz5+sYL/hJ1B+V jtVD62iOv14lH/lP2QADrbvBRdwhj3WrazEr9aWFR+jA2LmqtJQTiBLZ18jLnX57zAks b6A/TADRecJ5VeYXWDGfdjhrdYCQZyyC0BaH0zNJB9RB28YUP1iIwmzLBSPP9/vkwiTx vyBw7ywISZ5iEJttYjqS/msbmQ/rSKlgOm455sFRbNNMAUqPSugfV+W6qmkJEfp2vd+q 3Omw== 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=RiQvM8XekMYghfpiGLosFTuPTC3FIRYFDu0piunucRA=; b=F/zL9TqxgtNLOZUGk75E1RskJ71B4Mlpwe6eBKEyHS5AFW0tp/I5oYnhJfMf4Xy9dR qAAE4TNvTQZ/BeMT4+iv9vckmwAZ2bzAbODa980+E8/TfaxXkxB2FQur8oZ3PoEl4s1V nQ09Zs6q+orCps0W/wUopq8ZxR83i9Fikt2SOasUKiseyILr5zkICeyrQJ9dhdQUf/BX PJYJeOnXqeVXxQjJCINxI7FbL6oXw9Nbs4PgihmrJculUwn1J45F7VnXogSsoTgbxlb4 T+8mUcFKhUp8BX7P8FjwxNTYkJEB/KJTFvcVM6soWTFzLHv8z4U8kFRU4g9HQMr1mbLp F3yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=uTCHSzY2; spf=pass (google.com: domain of gcc-patches-return-458055-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458055-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 1si3830277pgs.57.2017.07.13.02.03.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:03:28 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458055-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=uTCHSzY2; spf=pass (google.com: domain of gcc-patches-return-458055-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458055-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=cigewd3+DhKABEhs5hserazG5GS9p 5HGQ2nMUjj8Cdh75nHDWAqiPIlATwUqzYMkfnAlXw88OPbH1XD7Ycj0i6u9UM9gK JFX6mxQhsaKeS4E/+U4R9F5Y1vtkcB8H1j5VpBT/c/C1laXfFi8Iuyl7mGRhmBEM 4SuCUrI1whB3jw= 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=8Z83SqiUU2wQgpUXXYO5L3VWtME=; b=uTC HSzY2e22+XD7UcW8F8YLychy9HCEXoGp3p6MJCasaUCrUE64CoL6+k7BriXo4uus Behb6Xqu9aLb8wCOA3o/1zOpSJ9MpZ3uEvSKCe8Y3qyPuXsvGL5UWNkpK+YE3ZS5 BZ5kXSh3538z7LKoOCPN5iFAbUqHP6E4hUIyzZWs= Received: (qmail 53376 invoked by alias); 13 Jul 2017 09:01:41 -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 52078 invoked by uid 89); 13 Jul 2017 09:01:40 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f181.google.com Received: from mail-wr0-f181.google.com (HELO mail-wr0-f181.google.com) (209.85.128.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 09:01:35 +0000 Received: by mail-wr0-f181.google.com with SMTP id 77so49791978wrb.1 for ; Thu, 13 Jul 2017 02:01:34 -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=RiQvM8XekMYghfpiGLosFTuPTC3FIRYFDu0piunucRA=; b=ipYgfT6NkTGLF4ZAQa9X4/UPeAUFU6L/+uzvYdAeH3nuHyBRDziGMwDyD8TMWOFNum EeBfJjcOHa7ROAZTdRVnuY7SLbc4vjnOHIHf2YgZIvIbRsUe7ylBeXWd1Wd8etZF4QxM wEeJue4xuKcP5dERzLXNsve/ZAmcavr/1sKzHAhmZSNLQsl2bzlsUAZl81bRBO/cqu5H 09zwfP/Tfpu0GVyXPG123JjSKPSDI+H5Zpk1uebR9CI5dzE9S0FILYgh9xzWMSEgK0ve 2Ugqu9cy5JOZRoc7OfUXEzmXFWWe53Ba3uYnUyASwsYI1HIE4C7vlpmbrmwc+9faXaVJ ZaKQ== X-Gm-Message-State: AIVw113B/mzJufpzjHfuMAdyNR4ZH4FNT4G2+k6ubUHdh8bxbL8SXUt5 aaXIeR2hkePbqxGo9U6EMA== X-Received: by 10.223.139.70 with SMTP id v6mr898728wra.97.1499936492860; Thu, 13 Jul 2017 02:01:32 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id 35sm2911048wrp.63.2017.07.13.02.01.31 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 02:01:32 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [64/77] Add a scalar_mode class References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 10:01:30 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <87h8ygd82d.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch adds a scalar_mode class that can hold any scalar mode, specifically: - scalar integers - scalar floating-point values - scalar fractional modes - scalar accumulator modes - pointer bounds modes To start with this patch uses this type for GET_MODE_INNER. Later patches add more uses. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * coretypes.h (scalar_mode): New class. * machmode.h (scalar_mode): Likewise. (scalar_mode::includes_p): New function. (mode_to_inner): Return a scalar_mode rather than a machine_mode. * gdbhooks.py (build_pretty_printers): Handle scalar_mode. * genmodes.c (get_mode_class): Handle remaining scalar modes. * cfgexpand.c (expand_debug_expr): Use scalar_mode. * expmed.c (store_bit_field_1): Likewise. (extract_bit_field_1): Likewise. * expr.c (write_complex_part): Likewise. (read_complex_part): Likewise. (emit_move_complex_push): Likewise. (expand_expr_real_2): Likewise. * function.c (assign_parm_setup_reg): Likewise. (assign_parms_unsplit_complex): Likewise. * optabs.c (expand_binop): Likewise. * rtlanal.c (subreg_get_info): Likewise. * simplify-rtx.c (simplify_immed_subreg): Likewise. * varasm.c (output_constant_pool_2): Likewise. Index: gcc/coretypes.h =================================================================== --- gcc/coretypes.h 2017-07-13 09:18:28.587718194 +0100 +++ gcc/coretypes.h 2017-07-13 09:18:53.271650545 +0100 @@ -55,6 +55,7 @@ typedef const struct simple_bitmap_def * struct rtx_def; typedef struct rtx_def *rtx; typedef const struct rtx_def *const_rtx; +class scalar_mode; class scalar_int_mode; class scalar_float_mode; template class opt_mode; @@ -317,6 +318,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_mode scalar_mode; typedef struct scalar_int_mode scalar_int_mode; typedef struct scalar_float_mode scalar_float_mode; Index: gcc/machmode.h =================================================================== --- gcc/machmode.h 2017-07-13 09:18:41.680558844 +0100 +++ gcc/machmode.h 2017-07-13 09:18:53.274650323 +0100 @@ -410,6 +410,47 @@ scalar_float_mode::includes_p (machine_m return SCALAR_FLOAT_MODE_P (m); } +/* Represents a machine mode that is known to be scalar. */ +class scalar_mode +{ +public: + typedef mode_traits::from_int from_int; + + ALWAYS_INLINE scalar_mode () {} + ALWAYS_INLINE scalar_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE scalar_mode (const scalar_int_mode &m) : m_mode (m) {} + ALWAYS_INLINE scalar_mode (const scalar_float_mode &m) : m_mode (m) {} + ALWAYS_INLINE scalar_mode (const scalar_int_mode_pod &m) : m_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 represents some kind of scalar value. */ + +inline bool +scalar_mode::includes_p (machine_mode m) +{ + switch (GET_MODE_CLASS (m)) + { + case MODE_INT: + case MODE_PARTIAL_INT: + case MODE_FRACT: + case MODE_UFRACT: + case MODE_ACCUM: + case MODE_UACCUM: + case MODE_FLOAT: + case MODE_DECIMAL_FLOAT: + case MODE_POINTER_BOUNDS: + return true; + default: + return false; + } +} + /* Return the base GET_MODE_SIZE value for MODE. */ ALWAYS_INLINE unsigned short @@ -441,14 +482,15 @@ mode_to_precision (machine_mode mode) /* Return the base GET_MODE_INNER value for MODE. */ -ALWAYS_INLINE machine_mode +ALWAYS_INLINE scalar_mode mode_to_inner (machine_mode mode) { #if GCC_VERSION >= 4001 - return (machine_mode) (__builtin_constant_p (mode) - ? mode_inner_inline (mode) : mode_inner[mode]); + return scalar_mode::from_int (__builtin_constant_p (mode) + ? mode_inner_inline (mode) + : mode_inner[mode]); #else - return (machine_mode) mode_inner[mode]; + return scalar_mode::from_int (mode_inner[mode]); #endif } Index: gcc/gdbhooks.py =================================================================== --- gcc/gdbhooks.py 2017-07-13 09:18:28.587718194 +0100 +++ gcc/gdbhooks.py 2017-07-13 09:18:53.273650396 +0100 @@ -549,7 +549,7 @@ def build_pretty_printer(): 'pod_mode', MachineModePrinter) pp.add_printer_for_types(['scalar_int_mode_pod'], 'pod_mode', MachineModePrinter) - for mode in 'scalar_int_mode', 'scalar_float_mode': + for mode in 'scalar_mode', 'scalar_int_mode', 'scalar_float_mode': pp.add_printer_for_types([mode], mode, MachineModePrinter) return pp Index: gcc/genmodes.c =================================================================== --- gcc/genmodes.c 2017-07-13 09:18:28.587718194 +0100 +++ gcc/genmodes.c 2017-07-13 09:18:53.274650323 +0100 @@ -1141,6 +1141,13 @@ get_mode_class (struct mode_data *mode) case MODE_PARTIAL_INT: return "scalar_int_mode"; + case MODE_FRACT: + case MODE_UFRACT: + case MODE_ACCUM: + case MODE_UACCUM: + case MODE_POINTER_BOUNDS: + return "scalar_mode"; + case MODE_FLOAT: case MODE_DECIMAL_FLOAT: return "scalar_float_mode"; Index: gcc/cfgexpand.c =================================================================== --- gcc/cfgexpand.c 2017-07-13 09:18:51.574777404 +0100 +++ gcc/cfgexpand.c 2017-07-13 09:18:53.271650545 +0100 @@ -4821,7 +4821,7 @@ expand_debug_expr (tree exp) GET_MODE_INNER (mode))); else { - machine_mode imode = GET_MODE_INNER (mode); + scalar_mode imode = GET_MODE_INNER (mode); rtx re, im; if (MEM_P (op0)) Index: gcc/expmed.c =================================================================== --- gcc/expmed.c 2017-07-13 09:18:52.815684419 +0100 +++ gcc/expmed.c 2017-07-13 09:18:53.272650471 +0100 @@ -758,16 +758,16 @@ store_bit_field_1 (rtx str_rtx, unsigned /* Use vec_set patterns for inserting parts of vectors whenever available. */ - if (VECTOR_MODE_P (GET_MODE (op0)) + machine_mode outermode = GET_MODE (op0); + scalar_mode innermode = GET_MODE_INNER (outermode); + if (VECTOR_MODE_P (outermode) && !MEM_P (op0) - && optab_handler (vec_set_optab, GET_MODE (op0)) != CODE_FOR_nothing - && fieldmode == GET_MODE_INNER (GET_MODE (op0)) - && bitsize == GET_MODE_UNIT_BITSIZE (GET_MODE (op0)) - && !(bitnum % GET_MODE_UNIT_BITSIZE (GET_MODE (op0)))) + && optab_handler (vec_set_optab, outermode) != CODE_FOR_nothing + && fieldmode == innermode + && bitsize == GET_MODE_BITSIZE (innermode) + && !(bitnum % GET_MODE_BITSIZE (innermode))) { struct expand_operand ops[3]; - machine_mode outermode = GET_MODE (op0); - machine_mode innermode = GET_MODE_INNER (outermode); enum insn_code icode = optab_handler (vec_set_optab, outermode); int pos = bitnum / GET_MODE_BITSIZE (innermode); @@ -1616,15 +1616,15 @@ extract_bit_field_1 (rtx str_rtx, unsign /* Use vec_extract patterns for extracting parts of vectors whenever available. */ - if (VECTOR_MODE_P (GET_MODE (op0)) + machine_mode outermode = GET_MODE (op0); + scalar_mode innermode = GET_MODE_INNER (outermode); + if (VECTOR_MODE_P (outermode) && !MEM_P (op0) - && optab_handler (vec_extract_optab, GET_MODE (op0)) != CODE_FOR_nothing - && ((bitnum + bitsize - 1) / GET_MODE_UNIT_BITSIZE (GET_MODE (op0)) - == bitnum / GET_MODE_UNIT_BITSIZE (GET_MODE (op0)))) + && optab_handler (vec_extract_optab, outermode) != CODE_FOR_nothing + && ((bitnum + bitsize - 1) / GET_MODE_BITSIZE (innermode) + == bitnum / GET_MODE_BITSIZE (innermode))) { struct expand_operand ops[3]; - machine_mode outermode = GET_MODE (op0); - machine_mode innermode = GET_MODE_INNER (outermode); enum insn_code icode = optab_handler (vec_extract_optab, outermode); unsigned HOST_WIDE_INT pos = bitnum / GET_MODE_BITSIZE (innermode); Index: gcc/expr.c =================================================================== --- gcc/expr.c 2017-07-13 09:18:51.653771449 +0100 +++ gcc/expr.c 2017-07-13 09:18:53.273650396 +0100 @@ -3114,7 +3114,7 @@ set_storage_via_setmem (rtx object, rtx write_complex_part (rtx cplx, rtx val, bool imag_p) { machine_mode cmode; - machine_mode imode; + scalar_mode imode; unsigned ibitsize; if (GET_CODE (cplx) == CONCAT) @@ -3175,7 +3175,8 @@ write_complex_part (rtx cplx, rtx val, b rtx read_complex_part (rtx cplx, bool imag_p) { - machine_mode cmode, imode; + machine_mode cmode; + scalar_mode imode; unsigned ibitsize; if (GET_CODE (cplx) == CONCAT) @@ -3371,7 +3372,7 @@ emit_move_resolve_push (machine_mode mod rtx_insn * emit_move_complex_push (machine_mode mode, rtx x, rtx y) { - machine_mode submode = GET_MODE_INNER (mode); + scalar_mode submode = GET_MODE_INNER (mode); bool imag_first; #ifdef PUSH_ROUNDING @@ -9328,7 +9329,7 @@ #define REDUCE_BIT_FIELD(expr) (reduce_b GET_MODE_INNER (GET_MODE (target)), 0); if (reg_overlap_mentioned_p (temp, op1)) { - machine_mode imode = GET_MODE_INNER (GET_MODE (target)); + scalar_mode imode = GET_MODE_INNER (GET_MODE (target)); temp = adjust_address_nv (target, imode, GET_MODE_SIZE (imode)); if (reg_overlap_mentioned_p (temp, op0)) Index: gcc/function.c =================================================================== --- gcc/function.c 2017-07-13 09:18:39.589733813 +0100 +++ gcc/function.c 2017-07-13 09:18:53.273650396 +0100 @@ -3372,8 +3372,7 @@ assign_parm_setup_reg (struct assign_par /* Mark complex types separately. */ if (GET_CODE (parmreg) == CONCAT) { - machine_mode submode - = GET_MODE_INNER (GET_MODE (parmreg)); + scalar_mode submode = GET_MODE_INNER (GET_MODE (parmreg)); int regnor = REGNO (XEXP (parmreg, 0)); int regnoi = REGNO (XEXP (parmreg, 1)); rtx stackr = adjust_address_nv (data->stack_parm, submode, 0); @@ -3510,7 +3509,7 @@ assign_parms_unsplit_complex (struct ass && targetm.calls.split_complex_arg (TREE_TYPE (parm))) { rtx tmp, real, imag; - machine_mode inner = GET_MODE_INNER (DECL_MODE (parm)); + scalar_mode inner = GET_MODE_INNER (DECL_MODE (parm)); real = DECL_RTL (fnargs[i]); imag = DECL_RTL (fnargs[i + 1]); Index: gcc/optabs.c =================================================================== --- gcc/optabs.c 2017-07-13 09:18:51.661770846 +0100 +++ gcc/optabs.c 2017-07-13 09:18:53.274650323 +0100 @@ -1229,7 +1229,7 @@ expand_binop (machine_mode mode, optab b { /* The scalar may have been extended to be too wide. Truncate it back to the proper size to fit in the broadcast vector. */ - machine_mode inner_mode = GET_MODE_INNER (mode); + scalar_mode inner_mode = GET_MODE_INNER (mode); if (!CONST_INT_P (op1) && (GET_MODE_BITSIZE (as_a (GET_MODE (op1))) > GET_MODE_BITSIZE (inner_mode))) Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2017-07-13 09:18:51.664770620 +0100 +++ gcc/rtlanal.c 2017-07-13 09:18:53.275650248 +0100 @@ -3645,7 +3645,7 @@ subreg_get_info (unsigned int xregno, ma { nregs_xmode = HARD_REGNO_NREGS_WITH_PADDING (xregno, xmode); unsigned int nunits = GET_MODE_NUNITS (xmode); - machine_mode xmode_unit = GET_MODE_INNER (xmode); + scalar_mode xmode_unit = GET_MODE_INNER (xmode); gcc_assert (HARD_REGNO_NREGS_HAS_PADDING (xregno, xmode_unit)); gcc_assert (nregs_xmode == (nunits Index: gcc/simplify-rtx.c =================================================================== --- gcc/simplify-rtx.c 2017-07-13 09:18:48.356023575 +0100 +++ gcc/simplify-rtx.c 2017-07-13 09:18:53.276650175 +0100 @@ -5719,7 +5719,7 @@ simplify_immed_subreg (machine_mode oute rtx result_s = NULL; rtvec result_v = NULL; enum mode_class outer_class; - machine_mode outer_submode; + scalar_mode outer_submode; int max_bitsize; /* Some ports misuse CCmode. */ Index: gcc/varasm.c =================================================================== --- gcc/varasm.c 2017-07-13 09:18:38.669811945 +0100 +++ gcc/varasm.c 2017-07-13 09:18:53.276650175 +0100 @@ -3852,7 +3852,7 @@ output_constant_pool_2 (machine_mode mod case MODE_VECTOR_UACCUM: { int i, units; - machine_mode submode = GET_MODE_INNER (mode); + scalar_mode submode = GET_MODE_INNER (mode); unsigned int subalign = MIN (align, GET_MODE_BITSIZE (submode)); gcc_assert (GET_CODE (x) == CONST_VECTOR);