Patchwork RFA: PR44566: accessor macros (3/3): CRTL_ASM_CLOBBERS

login
register
mail settings
Submitter Joern Rennecke
Date June 24, 2010, 7:19 p.m.
Message ID <20100624151954.gl9owlc26o8w0wss-nzlynne@webmail.spamcop.net>
Download mbox | patch
Permalink /patch/56823/
State New
Headers show

Comments

Joern Rennecke - June 24, 2010, 7:19 p.m.
Bootstrapped and regression tested on i686-pc-linux-gnu in revision 161310.
2010-06-24  Joern Rennecke  <joern.rennecke@embecosm.com>

	PR other/44566
	* function.h (target-gtypes.h): Include.
	(struct function): New member target_arch.
	* Makefile.in (TARGET_NUM): New Makefile variable.
	(cs-tm.h): Add TARGET_NUM to DEFINES.
	(GTFILES): Add target-gtypes.h.

	* function.h (CRTL_ASM_CLOBBERS): Define.
	(struct rtl_data): Use type hard_reg_set_u for member asm_clobbers.
	* Makefile.in (target-gtypes.h, s-target-gtypes): New rules.

	* expr.c (expand_expr_real_1): Use CRTL_ASM_CLOBBERS.
	* ira.c (compute_regs_asm_clobbered): Likewise.
	(ira_setup_eliminable_regset): Likewise.

Patch

Index: gcc/expr.c
===================================================================
--- gcc/expr.c	(revision 161310)
+++ gcc/expr.c	(working copy)
@@ -8463,7 +8463,7 @@  expand_expr_real_1 (tree exp, rtx target
 	    int nregs = hard_regno_nregs[i][GET_MODE (decl_rtl)];
 	    while (nregs)
 	      {
-		SET_HARD_REG_BIT (crtl->asm_clobbers, i);
+		SET_HARD_REG_BIT (CRTL_ASM_CLOBBERS, i);
 		i++;
 		nregs--;
 	      }
Index: gcc/function.h
===================================================================
--- gcc/function.h	(revision 161310)
+++ gcc/function.h	(working copy)
@@ -27,6 +27,7 @@  along with GCC; see the file COPYING3.  
 #include "vecprim.h"
 #include "tm.h"		/* For CUMULATIVE_ARGS.  */
 #include "hard-reg-set.h"
+#include "target-gtypes.h"
 
 /* Stack of pending (incomplete) sequences saved by `start_sequence'.
    Each element describes one pending sequence.
@@ -216,6 +217,8 @@  struct GTY(()) incoming_args {
   rtx internal_arg_pointer;
 };
 
+#define CRTL_ASM_CLOBBERS (crtl->asm_clobbers._hrs)
+
 /* Data for function partitioning.  */
 struct GTY(()) function_subsections {
   /* Assembly labels for the hot and cold text sections, to
@@ -443,7 +446,7 @@  struct GTY(()) rtl_data {
      asm.  Unlike regs_ever_live, elements of this array corresponding
      to eliminable regs (like the frame pointer) are set if an asm
      sets them.  */
-  HARD_REG_SET asm_clobbers;
+  hard_reg_set_u GTY ((desc ("cfun ? cfun->target_arch : -1"))) asm_clobbers;
 };
 
 #define return_label (crtl->x_return_label)
@@ -607,6 +610,9 @@  struct GTY(()) function {
      adjusts one of its arguments and forwards to another
      function.  */
   unsigned int is_thunk : 1;
+
+  /* Target architecture to compile this function for.  */
+  unsigned int target_arch : 8;
 };
 
 /* If va_list_[gf]pr_size is set to this, it means we don't know how
Index: gcc/ira.c
===================================================================
--- gcc/ira.c	(revision 161310)
+++ gcc/ira.c	(working copy)
@@ -1464,7 +1464,7 @@  compute_regs_asm_clobbered (void)
 		      + hard_regno_nregs[dregno][mode] - 1;
 
 		    for (i = dregno; i <= end; ++i)
-		      SET_HARD_REG_BIT(crtl->asm_clobbers, i);
+		      SET_HARD_REG_BIT (CRTL_ASM_CLOBBERS, i);
 		  }
 	      }
 	}
@@ -1510,7 +1510,7 @@  ira_setup_eliminable_regset (void)
 	= (! targetm.can_eliminate (eliminables[i].from, eliminables[i].to)
 	   || (eliminables[i].to == STACK_POINTER_REGNUM && need_fp));
 
-      if (!TEST_HARD_REG_BIT (crtl->asm_clobbers, eliminables[i].from))
+      if (!TEST_HARD_REG_BIT (CRTL_ASM_CLOBBERS, eliminables[i].from))
 	{
 	    SET_HARD_REG_BIT (eliminable_regset, eliminables[i].from);
 
@@ -1524,7 +1524,7 @@  ira_setup_eliminable_regset (void)
 	df_set_regs_ever_live (eliminables[i].from, true);
     }
 #if FRAME_POINTER_REGNUM != HARD_FRAME_POINTER_REGNUM
-  if (!TEST_HARD_REG_BIT (crtl->asm_clobbers, HARD_FRAME_POINTER_REGNUM))
+  if (!TEST_HARD_REG_BIT (CRTL_ASM_CLOBBERS, HARD_FRAME_POINTER_REGNUM))
     {
       SET_HARD_REG_BIT (eliminable_regset, HARD_FRAME_POINTER_REGNUM);
       if (need_fp)
@@ -1538,7 +1538,7 @@  ira_setup_eliminable_regset (void)
 #endif
 
 #else
-  if (!TEST_HARD_REG_BIT (crtl->asm_clobbers, HARD_FRAME_POINTER_REGNUM))
+  if (!TEST_HARD_REG_BIT (CRTL_ASM_CLOBBERS, HARD_FRAME_POINTER_REGNUM))
     {
       SET_HARD_REG_BIT (eliminable_regset, FRAME_POINTER_REGNUM);
       if (need_fp)
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 161310)
+++ gcc/Makefile.in	(working copy)
@@ -800,6 +800,9 @@  T =
 T_TARGET =
 T_TARGET : $(T_TARGET)
 
+# For building rtl pases for extra target architectures.
+TARGET_NUM=0
+
 # This should name the specs file that we're going to install.  Target
 # Makefiles may override it and name another file to be generated from
 # the built-in specs and installed as the default spec, as long as
@@ -1668,7 +1671,9 @@  cs-tconfig.h: Makefile
 
 cs-tm.h: Makefile
 	TARGET_CPU_DEFAULT="$(target_cpu_default)" \
-	HEADERS="$(tm_include_list)" DEFINES="$(tm_defines)" \
+	HEADERS="$(tm_include_list)" \
+	DEFINES="TARGET_NUM=$(TARGET_NUM) \
+	$(tm_defines)" \
 	$(SHELL) $(srcdir)/mkconfig.sh tm.h
 
 cs-tm_p.h: Makefile
@@ -3671,7 +3676,7 @@  s-constrs-h: $(MD_DEPS) build/genpreds$(
 
 GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(srcdir)/vecprim.h $(srcdir)/vecir.h \
-  $(host_xm_file_list) \
+  $(host_xm_file_list) target-gtypes.h \
   $(tm_file_list) $(HASHTAB_H) $(SPLAY_TREE_H) $(srcdir)/bitmap.h \
   $(srcdir)/alias.h $(srcdir)/coverage.c $(srcdir)/rtl.h \
   $(srcdir)/optabs.h $(srcdir)/tree.h $(srcdir)/libfuncs.h $(SYMTAB_H) \
@@ -3848,6 +3853,17 @@  build/genpreds.o : genpreds.c $(RTL_BASE
 build/genrecog.o : genrecog.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
   coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 
+target-gtypes.h: s-target-gtypes; @true
+# using struct instead of union makes this gty-safe.
+s-target-gtypes: Makefile
+	(echo 'typedef union GTY (())'; \
+	 echo '  {'; \
+	 echo '    HARD_REG_SET GTY ((tag ("TARGET_NUM"))) _hrs;'; \
+	 echo '  } hard_reg_set_u;'; \
+	) >> tmp-target-gtypes.h
+	$(SHELL) $(srcdir)/../move-if-change tmp-target-gtypes.h target-gtypes.h
+	$(STAMP) s-target-gtypes
+
 # Compile the programs that generate insn-* from the machine description.
 # They are compiled with $(COMPILER_FOR_BUILD), and associated libraries,
 # since they need to run on this machine