From patchwork Tue May 16 15:35:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 94758 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp519333vqo; Tue, 16 May 2023 08:36:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5UQHYt2p1Ds1yzR3ysqUmyQCIJY6NU/i/unD1+kyHVwznt8PcMWBKdoTflSkEGx5sn6CxW X-Received: by 2002:a05:6402:1a27:b0:50b:d5e5:519d with SMTP id be7-20020a0564021a2700b0050bd5e5519dmr31325907edb.4.1684251393820; Tue, 16 May 2023 08:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684251393; cv=none; d=google.com; s=arc-20160816; b=hPbdODuhoiIFKOCkP2ATI0dBTxYRGf2L2LSfQYML1Mh78fvjpGeff8h/LnZErGctfn pgA6UFsPaLiblq/XxyFjtpMeTKx8rrdzL0xpsnpubOqPFxD0sML+setsMSrgmupvjhJS I2IP6I/PgIRxw+FVv9sIPEbbjUm99acTjk25XmB3CpqdcD9FZB4eB/0hoq5vgVgdFb0Y c9Id9NlV83DgWLktRLO5t7/MNfG4RqDvti1eyD93t6few4begRrmRzQJNRZp3yh2Cvxp Q1FPTHCKMnx+Flzclo4QBmmsuQECiRCOzxMpyU7fiYi/qUKLCpFhfxIxHy2db2T/6DlD SOJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=WrQRZPMFf2PZC1NsAWmrjXnhEDXVvMNgcutLEGgJJI0=; b=Tql0JSZ0/XE6BlBS/TYMua4vG748Bk0LFLt7PJBiQbQ4dfu5OJGWBmMnOM5FA9HJyz 9M6F8FubLzRpr7AAdnfCFC0HIltnw9gQO6xgsgnICsCux+eDBk09hrCa/vrIhJd2rTRs sCVxQRAUwkwhkJPRyPv0ILcBO+Nhgi2vMMsp3HraO5UacH8yrWUS1sEOOG7uOxx+uu0M jaZndyHv3qdvCTmSl4erdh0qgjyzcQEzG2OSr5Cg89hdBVaMPRuBR+8jm3qfK4vgKevq 3Kdt7sPgPhiH3wMRuRMBMA/RXE0Stgu85gepO7PWemdo+D4OWnLMtj1AfP+8pdOjECoJ KJuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xp8hNLPz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id q23-20020aa7da97000000b0050c0550651csi13743675eds.120.2023.05.16.08.36.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 08:36:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xp8hNLPz; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 55F2C3857005 for ; Tue, 16 May 2023 15:36:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 55F2C3857005 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684251392; bh=WrQRZPMFf2PZC1NsAWmrjXnhEDXVvMNgcutLEGgJJI0=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=xp8hNLPzsyxIPBKeFRPnXbloIT4QboE2HcFyu8TJElk7rjnsrLcLkl0CDbwJ0TeFh WquTXRwQXxSQPK8bjc7fN7lY6KFonNp0FfdMTHxJKrWqS3W1K7KOCcoK7jGT4jVw3S VOcmOFi1/++DNmmVgUZrNqaV/pEb/Qn3hjwg/KiE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by sourceware.org (Postfix) with ESMTPS id 247543858C83 for ; Tue, 16 May 2023 15:35:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 247543858C83 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="379691510" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="379691510" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 16 May 2023 08:35:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10712"; a="701389607" X-IronPort-AV: E=Sophos;i="5.99,278,1677571200"; d="scan'208";a="701389607" Received: from shvmail03.sh.intel.com ([10.239.245.20]) by orsmga002.jf.intel.com with ESMTP; 16 May 2023 08:35:38 -0700 Received: from pli-ubuntu.sh.intel.com (pli-ubuntu.sh.intel.com [10.239.159.47]) by shvmail03.sh.intel.com (Postfix) with ESMTP id C2A301007BA0; Tue, 16 May 2023 23:35:37 +0800 (CST) To: gcc-patches@gcc.gnu.org Cc: juzhe.zhong@rivai.ai, kito.cheng@sifive.com, pan2.li@intel.com, yanzhang.wang@intel.com, jeffreyalaw@gmail.com, rguenther@suse.de, richard.sandiford@arm.com Subject: [PATCH] Machine_Mode: Extend machine_mode from 8 to 16 bits Date: Tue, 16 May 2023 23:35:24 +0800 Message-Id: <20230516153524.3302940-1-pan2.li@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230512050016.476110-1-pan2.li@intel.com> References: <20230512050016.476110-1-pan2.li@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_ASCII_DIVIDERS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Pan Li via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: pan2.li@intel.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765663230047271727?= X-GMAIL-MSGID: =?utf-8?q?1766065589705231189?= From: Pan Li We are running out of the machine_mode(8 bits) in RISC-V backend. Thus we would like to extend the machine_mode bit size from 8 to 16 bits. However, it is sensitive to extend the memory size in common structure like tree or rtx. This patch would like to extend the machine_mode bits to 16 bits by shrinking, like: * Swap the bit size of code and machine code in rtx_def. * Adjust the machine_mode location and spare in tree. The memory impact of this patch for correlated structure looks like below: +-------------------+----------+---------+------+ | struct/bytes | upstream | patched | diff | +-------------------+----------+---------+------+ | rtx_obj_reference | 8 | 12 | +4 | | ext_modified | 2 | 4 | +2 | | ira_allocno | 192 | 184 | -8 | | qty_table_elem | 40 | 40 | 0 | | reg_stat_type | 64 | 64 | 0 | | rtx_def | 40 | 40 | 0 | | table_elt | 80 | 80 | 0 | | tree_decl_common | 112 | 112 | 0 | | tree_type_common | 128 | 128 | 0 | | access_info | 8 | 8 | 0 | +-------------------+----------+---------+------+ The tree and rtx related struct has no memory changes after this patch, and the machine_mode changes to 16 bits already. Signed-off-by: Pan Li Co-authored-by: Ju-Zhe Zhong Co-authored-by: Kito Cheng Co-Authored-By: Richard Biener Co-Authored-By: Richard Sandiford gcc/ChangeLog: * combine.cc (struct reg_stat_type): Extend machine_mode to 16 bits. * cse.cc (struct qty_table_elem): Extend machine_mode to 16 bits (struct table_elt): Extend machine_mode to 16 bits. (struct set): Ditto. * genmodes.cc (emit_mode_wider): Extend type from char to short. (emit_mode_complex): Ditto. (emit_mode_inner): Ditto. (emit_class_narrowest_mode): Ditto. * genopinit.cc (main): Extend the machine_mode limit. * ira-int.h (struct ira_allocno): Extend machine_mode to 16 bits and re-ordered the struct fields for padding. * machmode.h (MACHINE_MODE_BITSIZE): New macro. (GET_MODE_2XWIDER_MODE): Extend type from char to short. (get_mode_alignment): Extend type from char to short. * ree.cc (struct ext_modified): Extend machine_mode to 16 bits and removed the ATTRIBUTE_PACKED. * rtl-ssa/accesses.h: Extend machine_mode to 16 bits, narrow m_kind to 2 bits and remove m_spare. * rtl.h (RTX_CODE_BITSIZE): New macro. (struct rtx_def): Swap both the bit size and location between the rtx_code and the machine_mode. (subreg_shape::unique_id): Extend the machine_mode limit. * rtlanal.h: Extend machine_mode to 16 bits. * tree-core.h (struct tree_type_common): Extend machine_mode to 16 bits and re-ordered the struct fields for padding. (struct tree_decl_common): Extend machine_mode to 16 bits. * internals.inl (rtl_ssa::access_info): Adjust the assignment. --- gcc/combine.cc | 4 +-- gcc/cse.cc | 16 ++++------- gcc/genmodes.cc | 16 +++++------ gcc/genopinit.cc | 3 ++- gcc/ira-int.h | 56 +++++++++++++++++++-------------------- gcc/machmode.h | 27 ++++++++++++++----- gcc/ree.cc | 4 +-- gcc/rtl-ssa/accesses.h | 12 ++++----- gcc/rtl-ssa/internals.inl | 5 ++-- gcc/rtl.h | 12 +++++---- gcc/rtlanal.h | 2 +- gcc/tree-core.h | 9 ++++--- 12 files changed, 88 insertions(+), 78 deletions(-) diff --git a/gcc/combine.cc b/gcc/combine.cc index 5aa0ec5c45a..a23caeed96f 100644 --- a/gcc/combine.cc +++ b/gcc/combine.cc @@ -200,7 +200,7 @@ struct reg_stat_type { unsigned HOST_WIDE_INT last_set_nonzero_bits; char last_set_sign_bit_copies; - ENUM_BITFIELD(machine_mode) last_set_mode : 8; + ENUM_BITFIELD(machine_mode) last_set_mode : MACHINE_MODE_BITSIZE; /* Set nonzero if references to register n in expressions should not be used. last_set_invalid is set nonzero when this register is being @@ -235,7 +235,7 @@ struct reg_stat_type { truncation if we know that value already contains a truncated value. */ - ENUM_BITFIELD(machine_mode) truncated_to_mode : 8; + ENUM_BITFIELD(machine_mode) truncated_to_mode : MACHINE_MODE_BITSIZE; }; diff --git a/gcc/cse.cc b/gcc/cse.cc index b10c9b0c94d..86403b95938 100644 --- a/gcc/cse.cc +++ b/gcc/cse.cc @@ -248,10 +248,8 @@ struct qty_table_elem rtx comparison_const; int comparison_qty; unsigned int first_reg, last_reg; - /* The sizes of these fields should match the sizes of the - code and mode fields of struct rtx_def (see rtl.h). */ - ENUM_BITFIELD(rtx_code) comparison_code : 16; - ENUM_BITFIELD(machine_mode) mode : 8; + ENUM_BITFIELD(machine_mode) mode : MACHINE_MODE_BITSIZE; + ENUM_BITFIELD(rtx_code) comparison_code : RTX_CODE_BITSIZE; }; /* The table of all qtys, indexed by qty number. */ @@ -404,9 +402,7 @@ struct table_elt struct table_elt *related_value; int cost; int regcost; - /* The size of this field should match the size - of the mode field of struct rtx_def (see rtl.h). */ - ENUM_BITFIELD(machine_mode) mode : 8; + ENUM_BITFIELD(machine_mode) mode : MACHINE_MODE_BITSIZE; char in_memory; char is_const; char flag; @@ -4152,10 +4148,8 @@ struct set /* Nonzero if the SET_SRC contains something whose value cannot be predicted and understood. */ char src_volatile; - /* Original machine mode, in case it becomes a CONST_INT. - The size of this field should match the size of the mode - field of struct rtx_def (see rtl.h). */ - ENUM_BITFIELD(machine_mode) mode : 8; + /* Original machine mode, in case it becomes a CONST_INT. */ + ENUM_BITFIELD(machine_mode) mode : MACHINE_MODE_BITSIZE; /* Hash value of constant equivalent for SET_SRC. */ unsigned src_const_hash; /* A constant equivalent for SET_SRC, if any. */ diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc index 715787b8f48..55ac2adb559 100644 --- a/gcc/genmodes.cc +++ b/gcc/genmodes.cc @@ -1141,10 +1141,10 @@ inline __attribute__((__always_inline__))\n\ #else\n\ extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ #endif\n\ -unsigned char\n\ +unsigned short\n\ mode_inner_inline (machine_mode mode)\n\ {\n\ - extern const unsigned char mode_inner[NUM_MACHINE_MODES];\n\ + extern const unsigned short mode_inner[NUM_MACHINE_MODES];\n\ gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\ switch (mode)\n\ {"); @@ -1529,7 +1529,7 @@ emit_mode_wider (void) int c; struct mode_data *m; - print_decl ("unsigned char", "mode_next", "NUM_MACHINE_MODES"); + print_decl ("unsigned short", "mode_next", "NUM_MACHINE_MODES"); for_all_modes (c, m) tagged_printf ("E_%smode", @@ -1537,7 +1537,7 @@ emit_mode_wider (void) m->name); print_closer (); - print_decl ("unsigned char", "mode_wider", "NUM_MACHINE_MODES"); + print_decl ("unsigned short", "mode_wider", "NUM_MACHINE_MODES"); for_all_modes (c, m) { @@ -1568,7 +1568,7 @@ emit_mode_wider (void) } print_closer (); - print_decl ("unsigned char", "mode_2xwider", "NUM_MACHINE_MODES"); + print_decl ("unsigned short", "mode_2xwider", "NUM_MACHINE_MODES"); for_all_modes (c, m) { @@ -1625,7 +1625,7 @@ emit_mode_complex (void) int c; struct mode_data *m; - print_decl ("unsigned char", "mode_complex", "NUM_MACHINE_MODES"); + print_decl ("unsigned short", "mode_complex", "NUM_MACHINE_MODES"); for_all_modes (c, m) tagged_printf ("E_%smode", @@ -1665,7 +1665,7 @@ emit_mode_inner (void) int c; struct mode_data *m; - print_decl ("unsigned char", "mode_inner", "NUM_MACHINE_MODES"); + print_decl ("unsigned short", "mode_inner", "NUM_MACHINE_MODES"); for_all_modes (c, m) tagged_printf ("E_%smode", @@ -1738,7 +1738,7 @@ emit_class_narrowest_mode (void) { int c; - print_decl ("unsigned char", "class_narrowest_mode", "MAX_MODE_CLASS"); + print_decl ("unsigned short", "class_narrowest_mode", "MAX_MODE_CLASS"); for (c = 0; c < MAX_MODE_CLASS; c++) { diff --git a/gcc/genopinit.cc b/gcc/genopinit.cc index 83cb7504fa1..0c1b6859ca0 100644 --- a/gcc/genopinit.cc +++ b/gcc/genopinit.cc @@ -182,7 +182,8 @@ main (int argc, const char **argv) progname = "genopinit"; - if (NUM_OPTABS > 0xffff || MAX_MACHINE_MODE >= 0xff) + if (NUM_OPTABS > 0xffff + || MAX_MACHINE_MODE >= ((1 << MACHINE_MODE_BITSIZE) - 1)) fatal ("genopinit range assumptions invalid"); if (!init_rtx_reader_args_cb (argc, argv, handle_arg)) diff --git a/gcc/ira-int.h b/gcc/ira-int.h index e2de47213b4..e7460cfd906 100644 --- a/gcc/ira-int.h +++ b/gcc/ira-int.h @@ -281,13 +281,20 @@ struct ira_allocno int regno; /* Mode of the allocno which is the mode of the corresponding pseudo-register. */ - ENUM_BITFIELD (machine_mode) mode : 8; + ENUM_BITFIELD (machine_mode) mode : MACHINE_MODE_BITSIZE; /* Widest mode of the allocno which in at least one case could be for paradoxical subregs where wmode > mode. */ - ENUM_BITFIELD (machine_mode) wmode : 8; + ENUM_BITFIELD (machine_mode) wmode : MACHINE_MODE_BITSIZE; /* Register class which should be used for allocation for given allocno. NO_REGS means that we should use memory. */ ENUM_BITFIELD (reg_class) aclass : 16; + /* Hard register assigned to given allocno. Negative value means + that memory was allocated to the allocno. During the reload, + spilled allocno has value equal to the corresponding stack slot + number (0, ...) - 2. Value -1 is used for allocnos spilled by the + reload (at this point pseudo-register has only one allocno) which + did not get stack slot yet. */ + signed int hard_regno : 16; /* A bitmask of the ABIs used by calls that occur while the allocno is live. */ unsigned int crossed_calls_abis : NUM_ABI_IDS; @@ -321,22 +328,6 @@ struct ira_allocno This is only ever true for non-cap allocnos. */ unsigned int might_conflict_with_parent_p : 1; - /* Hard register assigned to given allocno. Negative value means - that memory was allocated to the allocno. During the reload, - spilled allocno has value equal to the corresponding stack slot - number (0, ...) - 2. Value -1 is used for allocnos spilled by the - reload (at this point pseudo-register has only one allocno) which - did not get stack slot yet. */ - signed int hard_regno : 16; - /* Allocnos with the same regno are linked by the following member. - Allocnos corresponding to inner loops are first in the list (it - corresponds to depth-first traverse of the loops). */ - ira_allocno_t next_regno_allocno; - /* There may be different allocnos with the same regno in different - regions. Allocnos are bound to the corresponding loop tree node. - Pseudo-register may have only one regular allocno with given loop - tree node but more than one cap (see comments above). */ - ira_loop_tree_node_t loop_tree_node; /* Accumulated usage references of the allocno. Here and below, word 'accumulated' means info for given region and all nested subregions. In this case, 'accumulated' means sum of references @@ -362,6 +353,25 @@ struct ira_allocno register class living at the point than number of hard-registers of the class available for the allocation. */ int excess_pressure_points_num; + /* The number of objects tracked in the following array. */ + int num_objects; + /* Accumulated frequency of calls which given allocno + intersects. */ + int call_freq; + /* Accumulated number of the intersected calls. */ + int calls_crossed_num; + /* The number of calls across which it is live, but which should not + affect register preferences. */ + int cheap_calls_crossed_num; + /* Allocnos with the same regno are linked by the following member. + Allocnos corresponding to inner loops are first in the list (it + corresponds to depth-first traverse of the loops). */ + ira_allocno_t next_regno_allocno; + /* There may be different allocnos with the same regno in different + regions. Allocnos are bound to the corresponding loop tree node. + Pseudo-register may have only one regular allocno with given loop + tree node but more than one cap (see comments above). */ + ira_loop_tree_node_t loop_tree_node; /* Allocno hard reg preferences. */ ira_pref_t allocno_prefs; /* Copies to other non-conflicting allocnos. The copies can @@ -374,21 +384,11 @@ struct ira_allocno /* It is a link to allocno (cap) on lower loop level represented by given cap. Null if given allocno is not a cap. */ ira_allocno_t cap_member; - /* The number of objects tracked in the following array. */ - int num_objects; /* An array of structures describing conflict information and live ranges for each object associated with the allocno. There may be more than one such object in cases where the allocno represents a multi-word register. */ ira_object_t objects[2]; - /* Accumulated frequency of calls which given allocno - intersects. */ - int call_freq; - /* Accumulated number of the intersected calls. */ - int calls_crossed_num; - /* The number of calls across which it is live, but which should not - affect register preferences. */ - int cheap_calls_crossed_num; /* Registers clobbered by intersected calls. */ HARD_REG_SET crossed_calls_clobbered_regs; /* Array of usage costs (accumulated and the one updated during diff --git a/gcc/machmode.h b/gcc/machmode.h index f1865c1ef42..a22df60dc20 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -24,13 +24,13 @@ typedef opt_mode opt_machine_mode; extern CONST_MODE_SIZE poly_uint16_pod mode_size[NUM_MACHINE_MODES]; extern CONST_MODE_PRECISION poly_uint16_pod mode_precision[NUM_MACHINE_MODES]; -extern const unsigned char mode_inner[NUM_MACHINE_MODES]; +extern const unsigned short mode_inner[NUM_MACHINE_MODES]; extern CONST_MODE_NUNITS poly_uint16_pod mode_nunits[NUM_MACHINE_MODES]; extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES]; extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES]; -extern const unsigned char mode_next[NUM_MACHINE_MODES]; -extern const unsigned char mode_wider[NUM_MACHINE_MODES]; -extern const unsigned char mode_2xwider[NUM_MACHINE_MODES]; +extern const unsigned short mode_next[NUM_MACHINE_MODES]; +extern const unsigned short mode_wider[NUM_MACHINE_MODES]; +extern const unsigned short mode_2xwider[NUM_MACHINE_MODES]; template struct mode_traits @@ -242,6 +242,21 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES]; || CLASS == MODE_ACCUM \ || CLASS == MODE_UACCUM) +/* The MACHINE_MODE_BITSIZE should be exactly aligned with the type of the + machine_mode array in the machmode.h and genmodes.cc. For example as below. + +------------------------+-------+ + | MACHINE_MODE_BITSIZE | 16 | + +------------------------+-------+ + | mode_inter[] | short | + | mode_next[] | short | + | mode_wider[] | short | + | mode_2xwider[] | short | + | mode_complex[] | short | + | class_narrowest_mode[] | short | + +------------------------+-------+ + */ +#define MACHINE_MODE_BITSIZE 16 + /* An optional T (i.e. a T or nothing), where T is some form of mode class. */ template class opt_mode @@ -797,7 +812,7 @@ GET_MODE_2XWIDER_MODE (const T &m) } /* Get the complex mode from the component mode. */ -extern const unsigned char mode_complex[NUM_MACHINE_MODES]; +extern const unsigned short mode_complex[NUM_MACHINE_MODES]; #define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE]) /* Represents a machine mode that must have a fixed size. The main @@ -946,7 +961,7 @@ extern unsigned get_mode_alignment (machine_mode); /* For each class, get the narrowest mode in that class. */ -extern const unsigned char class_narrowest_mode[MAX_MODE_CLASS]; +extern const unsigned short class_narrowest_mode[MAX_MODE_CLASS]; #define GET_CLASS_NARROWEST_MODE(CLASS) \ ((machine_mode) class_narrowest_mode[CLASS]) diff --git a/gcc/ree.cc b/gcc/ree.cc index 413aec7c8eb..fc04249fa84 100644 --- a/gcc/ree.cc +++ b/gcc/ree.cc @@ -564,10 +564,10 @@ enum ext_modified_kind EXT_MODIFIED_SEXT }; -struct ATTRIBUTE_PACKED ext_modified +struct ext_modified { /* Mode from which ree has zero or sign extended the destination. */ - ENUM_BITFIELD(machine_mode) mode : 8; + ENUM_BITFIELD(machine_mode) mode : MACHINE_MODE_BITSIZE; /* Kind of modification of the insn. */ ENUM_BITFIELD(ext_modified_kind) kind : 2; diff --git a/gcc/rtl-ssa/accesses.h b/gcc/rtl-ssa/accesses.h index c5180b9308a..c2103a5cb5c 100644 --- a/gcc/rtl-ssa/accesses.h +++ b/gcc/rtl-ssa/accesses.h @@ -215,7 +215,11 @@ private: // The values returned by the accessors above. unsigned int m_regno; - access_kind m_kind : 8; + + // The value returned by the accessor above. + machine_mode m_mode : MACHINE_MODE_BITSIZE; + + access_kind m_kind : 2; protected: // The value returned by the accessors above. @@ -249,12 +253,6 @@ private: // Indicates that this access has been allocated on the function_info's // temporary obstack and so is not (yet) part of the proper SSA form. unsigned int m_is_temp : 1; - - // Bits for future expansion. - unsigned int m_spare : 2; - - // The value returned by the accessor above. - machine_mode m_mode : 8; }; // A contiguous array of access_info pointers. Used to represent a diff --git a/gcc/rtl-ssa/internals.inl b/gcc/rtl-ssa/internals.inl index 16e92e8308b..0a61811289d 100644 --- a/gcc/rtl-ssa/internals.inl +++ b/gcc/rtl-ssa/internals.inl @@ -22,6 +22,7 @@ namespace rtl_ssa { // Construct a new access with the given resource () and kind () values. inline access_info::access_info (resource_info resource, access_kind kind) : m_regno (resource.regno), + m_mode (resource.mode), m_kind (kind), m_is_artificial (false), m_is_set_with_nondebug_insn_uses (false), @@ -36,9 +37,7 @@ inline access_info::access_info (resource_info resource, access_kind kind) m_is_last_nondebug_insn_use (false), m_is_in_debug_insn_or_phi (false), m_has_been_superceded (false), - m_is_temp (false), - m_spare (0), - m_mode (resource.mode) + m_is_temp (false) { } diff --git a/gcc/rtl.h b/gcc/rtl.h index f634cab730b..364782b6060 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -63,6 +63,8 @@ enum rtx_code { # define NON_GENERATOR_NUM_RTX_CODE ((int) MATCH_OPERAND) #endif +#define RTX_CODE_BITSIZE 8 + /* Register Transfer Language EXPRESSIONS CODE CLASSES */ enum rtx_class { @@ -309,11 +311,11 @@ struct GTY((variable_size)) const_poly_int_def { struct GTY((desc("0"), tag("0"), chain_next ("RTX_NEXT (&%h)"), chain_prev ("RTX_PREV (&%h)"))) rtx_def { - /* The kind of expression this is. */ - ENUM_BITFIELD(rtx_code) code: 16; - /* The kind of value the expression has. */ - ENUM_BITFIELD(machine_mode) mode : 8; + ENUM_BITFIELD(machine_mode) mode : MACHINE_MODE_BITSIZE; + + /* The kind of expression this is. */ + ENUM_BITFIELD(rtx_code) code: RTX_CODE_BITSIZE; /* 1 in a MEM if we should keep the alias set for this mem unchanged when we access a component. @@ -2164,7 +2166,7 @@ subreg_shape::operator != (const subreg_shape &other) const inline unsigned HOST_WIDE_INT subreg_shape::unique_id () const { - { STATIC_ASSERT (MAX_MACHINE_MODE <= 256); } + { STATIC_ASSERT (MAX_MACHINE_MODE <= (1 << MACHINE_MODE_BITSIZE)); } { STATIC_ASSERT (NUM_POLY_INT_COEFFS <= 3); } { STATIC_ASSERT (sizeof (offset.coeffs[0]) <= 2); } int res = (int) inner_mode + ((int) outer_mode << 8); diff --git a/gcc/rtlanal.h b/gcc/rtlanal.h index 5fbed816e20..9013e75c04b 100644 --- a/gcc/rtlanal.h +++ b/gcc/rtlanal.h @@ -100,7 +100,7 @@ public: /* The mode of the reference. If IS_MULTIREG, this is the mode of REGNO - MULTIREG_OFFSET. */ - machine_mode mode : 8; + machine_mode mode : MACHINE_MODE_BITSIZE; /* If IS_MULTIREG, the offset of REGNO from the start of the register. */ unsigned int multireg_offset : 8; diff --git a/gcc/tree-core.h b/gcc/tree-core.h index a1aea136e75..9d44c04bf03 100644 --- a/gcc/tree-core.h +++ b/gcc/tree-core.h @@ -1680,8 +1680,9 @@ struct GTY(()) tree_type_common { tree attributes; unsigned int uid; + ENUM_BITFIELD(machine_mode) mode : MACHINE_MODE_BITSIZE; + unsigned int precision : 16; - ENUM_BITFIELD(machine_mode) mode : 8; unsigned lang_flag_0 : 1; unsigned lang_flag_1 : 1; unsigned lang_flag_2 : 1; @@ -1712,7 +1713,7 @@ struct GTY(()) tree_type_common { unsigned empty_flag : 1; unsigned indivisible_p : 1; unsigned no_named_args_stdarg_p : 1; - unsigned spare : 9; + unsigned spare : 1; alias_set_type alias_set; tree pointer_to; @@ -1770,7 +1771,7 @@ struct GTY(()) tree_decl_common { struct tree_decl_minimal common; tree size; - ENUM_BITFIELD(machine_mode) mode : 8; + ENUM_BITFIELD(machine_mode) mode : MACHINE_MODE_BITSIZE; unsigned nonlocal_flag : 1; unsigned virtual_flag : 1; @@ -1828,7 +1829,7 @@ struct GTY(()) tree_decl_common { /* In FIELD_DECL, this is DECL_NOT_FLEXARRAY. */ unsigned int decl_not_flexarray : 1; - /* 13 bits unused. */ + /* 5 bits unused. */ /* UID for points-to sets, stable over copying from inlining. */ unsigned int pt_uid;