diff mbox

Add SET_DECL_MODE

Message ID 87zikzqsqx.fsf@e105548-lin.cambridge.arm.com
State New
Headers show

Commit Message

Richard Sandiford Nov. 16, 2016, 4:44 p.m. UTC
This may no longer be necessary with the current version
of the SVE patches, but it does at least make things consistent
with the TYPE_MODE/SET_TYPE_MODE split.

Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?

Thanks,
Richard


[ This patch is part of the SVE series posted here:
  https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]

gcc/ada/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
    	    Alan Hayward  <alan.hayward@arm.com>
    	    David Sherwood  <david.sherwood@arm.com>

	* gcc-interface/utils.c (create_label_decl): Use SET_DECL_MODE.

gcc/c/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
    	    Alan Hayward  <alan.hayward@arm.com>
    	    David Sherwood  <david.sherwood@arm.com>

	* c-decl.c (merge_decls): Use SET_DECL_MODE.
	(make_label, finish_struct): Likewise.

gcc/cp/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
    	    Alan Hayward  <alan.hayward@arm.com>
    	    David Sherwood  <david.sherwood@arm.com>

	* class.c (finish_struct_bits): Use SET_DECL_MODE.
	(build_base_field_1, layout_class_type, finish_struct_1): Likewise.
	* decl.c (make_label_decl): Likewise.
	* pt.c (tsubst_decl): Likewise.

gcc/fortran/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
    	    Alan Hayward  <alan.hayward@arm.com>
    	    David Sherwood  <david.sherwood@arm.com>

	* trans-common.c (build_common_decl): Use SET_DECL_MODE.
	* trans-decl.c (gfc_build_label_decl): Likewise.
	* trans-types.c (gfc_get_array_descr_info): Likewise.

gcc/lto/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
    	    Alan Hayward  <alan.hayward@arm.com>
    	    David Sherwood  <david.sherwood@arm.com>

	* lto.c (offload_handle_link_vars): Use SET_DECL_MODE.

gcc/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
    	    Alan Hayward  <alan.hayward@arm.com>
    	    David Sherwood  <david.sherwood@arm.com>

	* tree.h (SET_DECL_MODE): New macro.
	* cfgexpand.c (avoid_deep_ter_for_debug): Use SET_DECL_MODE.
	(expand_gimple_basic_block): Likewise.
	* function.c (split_complex_args): Likeise.
	* ipa-prop.c (ipa_modify_call_arguments): Likewise.
	* omp-simd-clone.c (ipa_simd_modify_stmt_ops): Likewise.
	* stor-layout.c (layout_decl, relayout_decl): Likewise.
	(finish_bitfield_representative): Likewise.
	* tree.c (make_node_stat): Likewise.
	* tree-inline.c (remap_ssa_name): Likewise.
	(tree_function_versioning): Likewise.
	* tree-into-ssa.c (rewrite_debug_stmt_uses): Likewise.
	* tree-sra.c (sra_ipa_reset_debug_stmts): Likewise.
	* tree-ssa-ccp.c (optimize_atomic_bit_test_and): Likewise.
	* tree-ssa-loop-ivopts.c (remove_unused_ivs): Likewise.
	* tree-ssa.c (insert_debug_temp_for_var_def): Likewise.
	* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Likewise.
	* varasm.c (make_debug_expr_from_rtl): Likewise.

libcc1/
2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
    	    Alan Hayward  <alan.hayward@arm.com>
    	    David Sherwood  <david.sherwood@arm.com>

	* plugin.cc (plugin_build_add_field): Use SET_DECL_MODE.

Comments

Jeff Law Nov. 16, 2016, 5:47 p.m. UTC | #1
On 11/16/2016 09:44 AM, Richard Sandiford wrote:
> This may no longer be necessary with the current version
> of the SVE patches, but it does at least make things consistent
> with the TYPE_MODE/SET_TYPE_MODE split.
>
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
>
> [ This patch is part of the SVE series posted here:
>   https://gcc.gnu.org/ml/gcc/2016-11/msg00030.html ]
>
> gcc/ada/
> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
>     	    Alan Hayward  <alan.hayward@arm.com>
>     	    David Sherwood  <david.sherwood@arm.com>
>
> 	* gcc-interface/utils.c (create_label_decl): Use SET_DECL_MODE.
>
> gcc/c/
> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
>     	    Alan Hayward  <alan.hayward@arm.com>
>     	    David Sherwood  <david.sherwood@arm.com>
>
> 	* c-decl.c (merge_decls): Use SET_DECL_MODE.
> 	(make_label, finish_struct): Likewise.
>
> gcc/cp/
> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
>     	    Alan Hayward  <alan.hayward@arm.com>
>     	    David Sherwood  <david.sherwood@arm.com>
>
> 	* class.c (finish_struct_bits): Use SET_DECL_MODE.
> 	(build_base_field_1, layout_class_type, finish_struct_1): Likewise.
> 	* decl.c (make_label_decl): Likewise.
> 	* pt.c (tsubst_decl): Likewise.
>
> gcc/fortran/
> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
>     	    Alan Hayward  <alan.hayward@arm.com>
>     	    David Sherwood  <david.sherwood@arm.com>
>
> 	* trans-common.c (build_common_decl): Use SET_DECL_MODE.
> 	* trans-decl.c (gfc_build_label_decl): Likewise.
> 	* trans-types.c (gfc_get_array_descr_info): Likewise.
>
> gcc/lto/
> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
>     	    Alan Hayward  <alan.hayward@arm.com>
>     	    David Sherwood  <david.sherwood@arm.com>
>
> 	* lto.c (offload_handle_link_vars): Use SET_DECL_MODE.
>
> gcc/
> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
>     	    Alan Hayward  <alan.hayward@arm.com>
>     	    David Sherwood  <david.sherwood@arm.com>
>
> 	* tree.h (SET_DECL_MODE): New macro.
> 	* cfgexpand.c (avoid_deep_ter_for_debug): Use SET_DECL_MODE.
> 	(expand_gimple_basic_block): Likewise.
> 	* function.c (split_complex_args): Likeise.
> 	* ipa-prop.c (ipa_modify_call_arguments): Likewise.
> 	* omp-simd-clone.c (ipa_simd_modify_stmt_ops): Likewise.
> 	* stor-layout.c (layout_decl, relayout_decl): Likewise.
> 	(finish_bitfield_representative): Likewise.
> 	* tree.c (make_node_stat): Likewise.
> 	* tree-inline.c (remap_ssa_name): Likewise.
> 	(tree_function_versioning): Likewise.
> 	* tree-into-ssa.c (rewrite_debug_stmt_uses): Likewise.
> 	* tree-sra.c (sra_ipa_reset_debug_stmts): Likewise.
> 	* tree-ssa-ccp.c (optimize_atomic_bit_test_and): Likewise.
> 	* tree-ssa-loop-ivopts.c (remove_unused_ivs): Likewise.
> 	* tree-ssa.c (insert_debug_temp_for_var_def): Likewise.
> 	* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Likewise.
> 	* varasm.c (make_debug_expr_from_rtl): Likewise.
>
> libcc1/
> 2016-11-16  Richard Sandiford  <richard.sandiford@arm.com>
>     	    Alan Hayward  <alan.hayward@arm.com>
>     	    David Sherwood  <david.sherwood@arm.com>
>
> 	* plugin.cc (plugin_build_add_field): Use SET_DECL_MODE.
I just lightly spot-checked this.  Seems like it should fit under hte 
obvious rule.  Ok for the trunk.

jeff
diff mbox

Patch

diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index c06721f..fd6c202 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -3111,7 +3111,7 @@  create_label_decl (tree name, Node_Id gnat_node)
   tree label_decl
     = build_decl (input_location, LABEL_DECL, name, void_type_node);
 
-  DECL_MODE (label_decl) = VOIDmode;
+  SET_DECL_MODE (label_decl, VOIDmode);
 
   /* Add this decl to the current binding level.  */
   gnat_pushdecl (label_decl, gnat_node);
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
index 3e1b7a4..2358144 100644
--- a/gcc/c/c-decl.c
+++ b/gcc/c/c-decl.c
@@ -2373,7 +2373,7 @@  merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype)
       /* Since the type is OLDDECL's, make OLDDECL's size go with.  */
       DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
       DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl);
-      DECL_MODE (newdecl) = DECL_MODE (olddecl);
+      SET_DECL_MODE (newdecl, DECL_MODE (olddecl));
       if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
 	{
 	  SET_DECL_ALIGN (newdecl, DECL_ALIGN (olddecl));
@@ -3521,7 +3521,7 @@  make_label (location_t location, tree name, bool defining,
 {
   tree label = build_decl (location, LABEL_DECL, name, void_type_node);
   DECL_CONTEXT (label) = current_function_decl;
-  DECL_MODE (label) = VOIDmode;
+  SET_DECL_MODE (label, VOIDmode);
 
   c_label_vars *label_vars = ggc_alloc<c_label_vars> ();
   label_vars->shadowed = NULL;
@@ -7995,7 +7995,7 @@  finish_struct (location_t loc, tree t, tree fieldlist, tree attributes,
 	    {
 	      TREE_TYPE (field)
 		= c_build_bitfield_integer_type (width, TYPE_UNSIGNED (type));
-	      DECL_MODE (field) = TYPE_MODE (TREE_TYPE (field));
+	      SET_DECL_MODE (field, TYPE_MODE (TREE_TYPE (field)));
 	    }
 	  DECL_INITIAL (field) = 0;
 	}
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 7ffb558..9cca611 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -4053,7 +4053,7 @@  avoid_deep_ter_for_debug (gimple *stmt, int depth)
 	  gimple *def_temp = gimple_build_debug_bind (vexpr, use, g);
 	  DECL_ARTIFICIAL (vexpr) = 1;
 	  TREE_TYPE (vexpr) = TREE_TYPE (use);
-	  DECL_MODE (vexpr) = TYPE_MODE (TREE_TYPE (use));
+	  SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (use)));
 	  gimple_stmt_iterator gsi = gsi_for_stmt (g);
 	  gsi_insert_after (&gsi, def_temp, GSI_NEW_STMT);
 	  avoid_deep_ter_for_debug (def_temp, 0);
@@ -5581,7 +5581,7 @@  expand_gimple_basic_block (basic_block bb, bool disable_tail_calls)
 		      mode = DECL_MODE (value);
 		    else
 		      mode = TYPE_MODE (TREE_TYPE (value));
-		    DECL_MODE (vexpr) = mode;
+		    SET_DECL_MODE (vexpr, mode);
 
 		    val = gen_rtx_VAR_LOCATION
 			(mode, vexpr, (rtx)value, VAR_INIT_STATUS_INITIALIZED);
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 5460ae5..df4d73c 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2129,7 +2129,7 @@  finish_struct_bits (tree t)
       || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t))
     {
       tree variants;
-      DECL_MODE (TYPE_MAIN_DECL (t)) = BLKmode;
+      SET_DECL_MODE (TYPE_MAIN_DECL (t), BLKmode);
       for (variants = t; variants; variants = TYPE_NEXT_VARIANT (variants))
 	{
 	  SET_TYPE_MODE (variants, BLKmode);
@@ -4525,7 +4525,7 @@  build_base_field_1 (tree t, tree basetype, tree *&next_field)
   DECL_SIZE_UNIT (decl) = CLASSTYPE_SIZE_UNIT (basetype);
   SET_DECL_ALIGN (decl, CLASSTYPE_ALIGN (basetype));
   DECL_USER_ALIGN (decl) = CLASSTYPE_USER_ALIGN (basetype);
-  DECL_MODE (decl) = TYPE_MODE (basetype);
+  SET_DECL_MODE (decl, TYPE_MODE (basetype));
   DECL_FIELD_IS_BASE (decl) = 1;
 
   /* Add the new FIELD_DECL to the list of fields for T.  */
@@ -6502,7 +6502,7 @@  layout_class_type (tree t, tree *virtuals_p)
 	     field is effectively invisible.  */
 	  DECL_SIZE (field) = TYPE_SIZE (type);
 	  /* We must also reset the DECL_MODE of the field.  */
-	  DECL_MODE (field) = TYPE_MODE (type);
+	  SET_DECL_MODE (field, TYPE_MODE (type));
 	}
       else
 	layout_nonempty_base_or_field (rli, field, NULL_TREE,
@@ -7285,7 +7285,7 @@  finish_struct_1 (tree t)
     if (VAR_P (x) && TREE_STATIC (x)
         && TREE_TYPE (x) != error_mark_node
 	&& same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (x)), t))
-      DECL_MODE (x) = TYPE_MODE (t);
+      SET_DECL_MODE (x, TYPE_MODE (t));
 
   /* Done with FIELDS...now decide whether to sort these for
      faster lookups later.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 23ba087..5b09bc3 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2967,7 +2967,7 @@  make_label_decl (tree id, int local_p)
   decl = build_decl (input_location, LABEL_DECL, id, void_type_node);
 
   DECL_CONTEXT (decl) = current_function_decl;
-  DECL_MODE (decl) = VOIDmode;
+  SET_DECL_MODE (decl, VOIDmode);
   C_DECLARED_LABEL_FLAG (decl) = local_p;
 
   /* Say where one reference is to the label, for the sake of the
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7eeb27d..6a68de2 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12570,7 +12570,7 @@  tsubst_decl (tree t, tree args, tsubst_flags_t complain)
 	   see [temp.inst].  */
 	DECL_INITIAL (r) = NULL_TREE;
 	if (VAR_P (r))
-	  DECL_MODE (r) = VOIDmode;
+	  SET_DECL_MODE (r, VOIDmode);
 	if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_DECL_WRTL))
 	  SET_DECL_RTL (r, NULL);
 	DECL_SIZE (r) = DECL_SIZE_UNIT (r) = 0;
diff --git a/gcc/fortran/trans-common.c b/gcc/fortran/trans-common.c
index cd06e15..3207105 100644
--- a/gcc/fortran/trans-common.c
+++ b/gcc/fortran/trans-common.c
@@ -408,7 +408,7 @@  build_common_decl (gfc_common_head *com, tree union_type, bool is_init)
 	{
 	  DECL_SIZE (decl) = TYPE_SIZE (union_type);
 	  DECL_SIZE_UNIT (decl) = size;
-	  DECL_MODE (decl) = TYPE_MODE (union_type);
+	  SET_DECL_MODE (decl, TYPE_MODE (union_type));
 	  TREE_TYPE (decl) = union_type;
 	  layout_decl (decl, 0);
 	}
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 7c9730c..ba71a21 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -274,7 +274,7 @@  gfc_build_label_decl (tree label_id)
   label_decl = build_decl (input_location,
 			   LABEL_DECL, label_id, void_type_node);
   DECL_CONTEXT (label_decl) = current_function_decl;
-  DECL_MODE (label_decl) = VOIDmode;
+  SET_DECL_MODE (label_decl, VOIDmode);
 
   /* We always define the label as used, even if the original source
      file never references the label.  We don't want all kinds of
diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index 6f9bc38..354308f 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -3188,7 +3188,7 @@  gfc_get_array_descr_info (const_tree type, struct array_descr_info *info)
       base_decl = make_node (DEBUG_EXPR_DECL);
       DECL_ARTIFICIAL (base_decl) = 1;
       TREE_TYPE (base_decl) = indirect ? build_pointer_type (ptype) : ptype;
-      DECL_MODE (base_decl) = TYPE_MODE (TREE_TYPE (base_decl));
+      SET_DECL_MODE (base_decl, TYPE_MODE (TREE_TYPE (base_decl)));
       GFC_TYPE_ARRAY_BASE_DECL (type, indirect) = base_decl;
     }
   info->base_decl = base_decl;
diff --git a/gcc/function.c b/gcc/function.c
index b009a0d..a677c83 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -2330,7 +2330,7 @@  split_complex_args (vec<tree> *args)
 	  p = copy_node (p);
 	  TREE_TYPE (p) = subtype;
 	  DECL_ARG_TYPE (p) = TREE_TYPE (DECL_ARG_TYPE (p));
-	  DECL_MODE (p) = VOIDmode;
+	  SET_DECL_MODE (p, VOIDmode);
 	  DECL_SIZE (p) = NULL;
 	  DECL_SIZE_UNIT (p) = NULL;
 	  /* If this arg must go in memory, put it in a pseudo here.
diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c
index 6321fdd..90c19fc 100644
--- a/gcc/ipa-prop.c
+++ b/gcc/ipa-prop.c
@@ -4344,7 +4344,7 @@  ipa_modify_call_arguments (struct cgraph_edge *cs, gcall *stmt,
 	      ddecl = make_node (DEBUG_EXPR_DECL);
 	      DECL_ARTIFICIAL (ddecl) = 1;
 	      TREE_TYPE (ddecl) = TREE_TYPE (origin);
-	      DECL_MODE (ddecl) = DECL_MODE (origin);
+	      SET_DECL_MODE (ddecl, DECL_MODE (origin));
 
 	      vec_safe_push (*debug_args, origin);
 	      vec_safe_push (*debug_args, ddecl);
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index c1567ca..a01b481 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -3242,7 +3242,7 @@  offload_handle_link_vars (void)
 	TREE_TYPE (link_ptr_var) = type;
 	TREE_USED (link_ptr_var) = 1;
 	TREE_STATIC (link_ptr_var) = 1;
-	DECL_MODE (link_ptr_var) = TYPE_MODE (type);
+	SET_DECL_MODE (link_ptr_var, TYPE_MODE (type));
 	DECL_SIZE (link_ptr_var) = TYPE_SIZE (type);
 	DECL_SIZE_UNIT (link_ptr_var) = TYPE_SIZE_UNIT (type);
 	DECL_ARTIFICIAL (link_ptr_var) = 1;
diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
index 50bce67..15f80ab 100644
--- a/gcc/omp-simd-clone.c
+++ b/gcc/omp-simd-clone.c
@@ -868,7 +868,7 @@  ipa_simd_modify_stmt_ops (tree *tp, int *walk_subtrees, void *data)
 	  stmt = gimple_build_debug_source_bind (vexpr, repl, NULL);
 	  DECL_ARTIFICIAL (vexpr) = 1;
 	  TREE_TYPE (vexpr) = TREE_TYPE (repl);
-	  DECL_MODE (vexpr) = TYPE_MODE (TREE_TYPE (repl));
+	  SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (repl)));
 	  repl = vexpr;
 	}
       else
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index f904d75..9f8efcb 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -616,7 +616,7 @@  layout_decl (tree decl, unsigned int known_align)
 
   DECL_UNSIGNED (decl) = TYPE_UNSIGNED (type);
   if (DECL_MODE (decl) == VOIDmode)
-    DECL_MODE (decl) = TYPE_MODE (type);
+    SET_DECL_MODE (decl, TYPE_MODE (type));
 
   if (DECL_SIZE (decl) == 0)
     {
@@ -682,7 +682,7 @@  layout_decl (tree decl, unsigned int known_align)
 		  && (known_align == 0 || known_align >= xalign))
 		{
 		  SET_DECL_ALIGN (decl, MAX (xalign, DECL_ALIGN (decl)));
-		  DECL_MODE (decl) = xmode;
+		  SET_DECL_MODE (decl, xmode);
 		  DECL_BIT_FIELD (decl) = 0;
 		}
 	    }
@@ -776,7 +776,7 @@  void
 relayout_decl (tree decl)
 {
   DECL_SIZE (decl) = DECL_SIZE_UNIT (decl) = 0;
-  DECL_MODE (decl) = VOIDmode;
+  SET_DECL_MODE (decl, VOIDmode);
   if (!DECL_USER_ALIGN (decl))
     SET_DECL_ALIGN (decl, 0);
   if (DECL_RTL_SET_P (decl))
@@ -1906,7 +1906,7 @@  finish_bitfield_representative (tree repr, tree field)
 	 [0, 15] HImode for a and b, [8, 23] HImode for c.  */
       DECL_SIZE (repr) = bitsize_int (bitsize);
       DECL_SIZE_UNIT (repr) = size_int (bitsize / BITS_PER_UNIT);
-      DECL_MODE (repr) = BLKmode;
+      SET_DECL_MODE (repr, BLKmode);
       TREE_TYPE (repr) = build_array_type_nelts (unsigned_char_type_node,
 						 bitsize / BITS_PER_UNIT);
     }
@@ -1915,7 +1915,7 @@  finish_bitfield_representative (tree repr, tree field)
       unsigned HOST_WIDE_INT modesize = GET_MODE_BITSIZE (mode);
       DECL_SIZE (repr) = bitsize_int (modesize);
       DECL_SIZE_UNIT (repr) = size_int (modesize / BITS_PER_UNIT);
-      DECL_MODE (repr) = mode;
+      SET_DECL_MODE (repr, mode);
       TREE_TYPE (repr) = lang_hooks.types.type_for_mode (mode, 1);
     }
 
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 6899d2a..0de0b89 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -214,7 +214,7 @@  remap_ssa_name (tree name, copy_body_data *id)
 	  def_temp = gimple_build_debug_source_bind (vexpr, val, NULL);
 	  DECL_ARTIFICIAL (vexpr) = 1;
 	  TREE_TYPE (vexpr) = TREE_TYPE (name);
-	  DECL_MODE (vexpr) = DECL_MODE (SSA_NAME_VAR (name));
+	  SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (name)));
 	  gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
 	  gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT);
 	  return vexpr;
@@ -6070,7 +6070,7 @@  tree_function_versioning (tree old_decl, tree new_decl,
 	    ddecl = make_node (DEBUG_EXPR_DECL);
 	    DECL_ARTIFICIAL (ddecl) = 1;
 	    TREE_TYPE (ddecl) = TREE_TYPE (parm);
-	    DECL_MODE (ddecl) = DECL_MODE (parm);
+	    SET_DECL_MODE (ddecl, DECL_MODE (parm));
 	    vec_safe_push (*debug_args, DECL_ORIGIN (parm));
 	    vec_safe_push (*debug_args, ddecl);
 	  }
@@ -6102,7 +6102,7 @@  tree_function_versioning (tree old_decl, tree new_decl,
 	      parm = (**debug_args)[i];
 	      DECL_ARTIFICIAL (vexpr) = 1;
 	      TREE_TYPE (vexpr) = TREE_TYPE (parm);
-	      DECL_MODE (vexpr) = DECL_MODE (parm);
+	      SET_DECL_MODE (vexpr, DECL_MODE (parm));
 	      def_temp = gimple_build_debug_bind (var, vexpr, NULL);
 	      gsi_insert_before (&cgsi, def_temp, GSI_NEW_STMT);
 	      def_temp = gimple_build_debug_source_bind (vexpr, parm, NULL);
diff --git a/gcc/tree-into-ssa.c b/gcc/tree-into-ssa.c
index 0e78845..cf9c2a0 100644
--- a/gcc/tree-into-ssa.c
+++ b/gcc/tree-into-ssa.c
@@ -1229,7 +1229,7 @@  rewrite_debug_stmt_uses (gimple *stmt)
 		  def_temp = gimple_build_debug_source_bind (def, var, NULL);
 		  DECL_ARTIFICIAL (def) = 1;
 		  TREE_TYPE (def) = TREE_TYPE (var);
-		  DECL_MODE (def) = DECL_MODE (var);
+		  SET_DECL_MODE (def, DECL_MODE (var));
 		  gsi =
 		 gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
 		  gsi_insert_before (&gsi, def_temp, GSI_SAME_STMT);
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index d4ccd91..12dae4a 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -5000,7 +5000,7 @@  sra_ipa_reset_debug_stmts (ipa_parm_adjustment_vec adjustments)
 							   NULL);
 		DECL_ARTIFICIAL (vexpr) = 1;
 		TREE_TYPE (vexpr) = TREE_TYPE (name);
-		DECL_MODE (vexpr) = DECL_MODE (adj->base);
+		SET_DECL_MODE (vexpr, DECL_MODE (adj->base));
 		gsi_insert_before (gsip, def_temp, GSI_SAME_STMT);
 	      }
 	    if (vexpr)
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 167598f..f89da70 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2905,7 +2905,7 @@  optimize_atomic_bit_test_and (gimple_stmt_iterator *gsip,
       tree temp = make_node (DEBUG_EXPR_DECL);
       DECL_ARTIFICIAL (temp) = 1;
       TREE_TYPE (temp) = TREE_TYPE (lhs);
-      DECL_MODE (temp) = TYPE_MODE (TREE_TYPE (lhs));
+      SET_DECL_MODE (temp, TYPE_MODE (TREE_TYPE (lhs)));
       tree t = build2 (LSHIFT_EXPR, TREE_TYPE (lhs), new_lhs, bit);
       g = gimple_build_debug_bind (temp, t, g);
       gsi_insert_after (&gsi, g, GSI_NEW_STMT);
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index f9211ad..2655c23 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -7589,9 +7589,9 @@  remove_unused_ivs (struct ivopts_data *data)
 		  DECL_ARTIFICIAL (vexpr) = 1;
 		  TREE_TYPE (vexpr) = TREE_TYPE (comp);
 		  if (SSA_NAME_VAR (def))
-		    DECL_MODE (vexpr) = DECL_MODE (SSA_NAME_VAR (def));
+		    SET_DECL_MODE (vexpr, DECL_MODE (SSA_NAME_VAR (def)));
 		  else
-		    DECL_MODE (vexpr) = TYPE_MODE (TREE_TYPE (vexpr));
+		    SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (vexpr)));
 		  gdebug *def_temp
 		    = gimple_build_debug_bind (vexpr, comp, NULL);
 		  gimple_stmt_iterator gsi;
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 135952b..62eea8b 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -432,9 +432,9 @@  insert_debug_temp_for_var_def (gimple_stmt_iterator *gsi, tree var)
 	  DECL_ARTIFICIAL (vexpr) = 1;
 	  TREE_TYPE (vexpr) = TREE_TYPE (value);
 	  if (DECL_P (value))
-	    DECL_MODE (vexpr) = DECL_MODE (value);
+	    SET_DECL_MODE (vexpr, DECL_MODE (value));
 	  else
-	    DECL_MODE (vexpr) = TYPE_MODE (TREE_TYPE (value));
+	    SET_DECL_MODE (vexpr, TYPE_MODE (TREE_TYPE (value)));
 
 	  if (gsi)
 	    gsi_insert_before (gsi, def_temp, GSI_SAME_STMT);
diff --git a/gcc/tree-streamer-in.c b/gcc/tree-streamer-in.c
index e5cc5a0..3d8a7bb 100644
--- a/gcc/tree-streamer-in.c
+++ b/gcc/tree-streamer-in.c
@@ -220,7 +220,7 @@  unpack_ts_fixed_cst_value_fields (struct bitpack_d *bp, tree expr)
 static void
 unpack_ts_decl_common_value_fields (struct bitpack_d *bp, tree expr)
 {
-  DECL_MODE (expr) = bp_unpack_machine_mode (bp);
+  SET_DECL_MODE (expr, bp_unpack_machine_mode (bp));
   DECL_NONLOCAL (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_VIRTUAL_P (expr) = (unsigned) bp_unpack_value (bp, 1);
   DECL_IGNORED_P (expr) = (unsigned) bp_unpack_value (bp, 1);
diff --git a/gcc/tree.c b/gcc/tree.c
index c155d56..adf140f 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1020,7 +1020,7 @@  make_node_stat (enum tree_code code MEM_STAT_DECL)
 	  if (code == FUNCTION_DECL)
 	    {
 	      SET_DECL_ALIGN (t, FUNCTION_ALIGNMENT (FUNCTION_BOUNDARY));
-	      DECL_MODE (t) = FUNCTION_MODE;
+	      SET_DECL_MODE (t, FUNCTION_MODE);
 	    }
 	  else
 	    SET_DECL_ALIGN (t, 1);
diff --git a/gcc/tree.h b/gcc/tree.h
index 6a98b6e..570f0f4 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2350,6 +2350,8 @@  extern machine_mode element_mode (const_tree t);
    field.  Always equal to TYPE_MODE (TREE_TYPE (decl)) except for a
    FIELD_DECL.  */
 #define DECL_MODE(NODE) (DECL_COMMON_CHECK (NODE)->decl_common.mode)
+#define SET_DECL_MODE(NODE, MODE) \
+  (DECL_COMMON_CHECK (NODE)->decl_common.mode = (MODE))
 
 /* For FUNCTION_DECL, if it is built-in, this identifies which built-in
    operation it is.  Note, however, that this field is overloaded, with
diff --git a/gcc/varasm.c b/gcc/varasm.c
index 6a7ffc2..b43d78f 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -7627,7 +7627,7 @@  make_debug_expr_from_rtl (const_rtx exp)
     TREE_TYPE (ddecl) = type;
   else
     TREE_TYPE (ddecl) = lang_hooks.types.type_for_mode (mode, 1);
-  DECL_MODE (ddecl) = mode;
+  SET_DECL_MODE (ddecl, mode);
   dval = gen_rtx_DEBUG_EXPR (mode);
   DEBUG_EXPR_TREE_DECL (dval) = ddecl;
   SET_DECL_RTL (ddecl, dval);
diff --git a/libcc1/plugin.cc b/libcc1/plugin.cc
index 0ea912f..5980b8b 100644
--- a/libcc1/plugin.cc
+++ b/libcc1/plugin.cc
@@ -511,7 +511,7 @@  plugin_build_add_field (cc1_plugin::connection *,
 	= c_build_bitfield_integer_type (bitsize, TYPE_UNSIGNED (field_type));
     }
 
-  DECL_MODE (decl) = TYPE_MODE (TREE_TYPE (decl));
+  SET_DECL_MODE (decl, TYPE_MODE (TREE_TYPE (decl)));
 
   // There's no way to recover this from DWARF.
   SET_DECL_OFFSET_ALIGN (decl, TYPE_PRECISION (pointer_sized_int_node));