diff mbox

[4/5] Remove cgraph.h dependence on hard-reg-set.h

Message ID 55805AE3.9020803@redhat.com
State New
Headers show

Commit Message

Andrew MacLeod June 16, 2015, 5:20 p.m. UTC
cgraph.h requires hard-reg-set.h in order to compile simply because the 
cgraph_rtl_info structure contains a HARD_REG_SET element.

All accesses to this structure are already handled by returning a 
pointer to the structure within the cgraph_node.  By moving the 
defintion of struct cgraph_rtl_info into rtl.h and maintaining a pointer 
to it instead of the structure within cgraph_node,  the compilation 
requirement on hard-reg-set.h can be completely removed when including 
cgraph.h.  This will hopefully help prevent bringing hard-reg-set and 
tm.h into a number of source files.

  The structure in rtl.h is protected by  checking for HARD_CONST (which 
many other things in rtl.h do). This is mostly so generator files won't 
trip over them.  2 source files needed adjustment because they didn't 
include hard-reg-set.h before rtl.h.  I guess they never referenced the 
other things protected by HARD_CONST in the file.  This ordering issue 
should shortly be resolved by an include grouping.

Bootstraps on x86_64-unknown-linux-gnu with no new regressions. Also 
passes all the targets in config-list.mk

OK for trunk?

Andrew

PS shortly I plan to do some module header bundling and include 
reductions. At that point I'll remove unneeded includes of 
hard-reg-set.h from files

Comments

Jeff Law June 25, 2015, 5:04 a.m. UTC | #1
On 06/16/2015 11:20 AM, Andrew MacLeod wrote:
> cgraph.h requires hard-reg-set.h in order to compile simply because the
> cgraph_rtl_info structure contains a HARD_REG_SET element.
>
> All accesses to this structure are already handled by returning a
> pointer to the structure within the cgraph_node.  By moving the
> defintion of struct cgraph_rtl_info into rtl.h and maintaining a pointer
> to it instead of the structure within cgraph_node,  the compilation
> requirement on hard-reg-set.h can be completely removed when including
> cgraph.h.  This will hopefully help prevent bringing hard-reg-set and
> tm.h into a number of source files.
>
>   The structure in rtl.h is protected by  checking for HARD_CONST (which
> many other things in rtl.h do). This is mostly so generator files won't
> trip over them.  2 source files needed adjustment because they didn't
> include hard-reg-set.h before rtl.h.  I guess they never referenced the
> other things protected by HARD_CONST in the file.  This ordering issue
> should shortly be resolved by an include grouping.
>
> Bootstraps on x86_64-unknown-linux-gnu with no new regressions. Also
> passes all the targets in config-list.mk
>
> OK for trunk?
OK.
jeff
diff mbox

Patch


	* cgraph.h (cgraph_rtl_info): Move to rtl.h
	(cgraph_node): Maintain pointer to struct cgraph_rtl_info instead of
	and instance.
	* rtl.h (struct cgraph_rtl_info): Define when HARD_REG_SET available.
	* cgraph.c (cgraph_node::rtl_info): Allocate cgraph_rtl_info if one
	doesn't exist.
	* calls.c: Include hard-reg-set.h before rtl.h.
	* ira.c: Likewise.

Index: cgraph.h
===================================================================
*** cgraph.h	(revision 224342)
--- cgraph.h	(working copy)
*************** struct GTY(()) cgraph_global_info {
*** 613,632 ****
    cgraph_node *inlined_to;
  };
  
- /* Information about the function that is propagated by the RTL backend.
-    Available only for functions that has been already assembled.  */
- 
- struct GTY(()) cgraph_rtl_info {
-    unsigned int preferred_incoming_stack_boundary;
- 
-   /* Call unsaved hard registers really used by the corresponding
-      function (including ones used by functions called by the
-      function).  */
-   HARD_REG_SET function_used_regs;
-   /* Set if function_used_regs is valid.  */
-   unsigned function_used_regs_valid: 1;
- };
- 
  /* Represent which DECL tree (or reference to such tree)
     will be replaced by another tree while versioning.  */
  struct GTY(()) ipa_replace_map
--- 613,618 ----
*************** public:
*** 1194,1200 ****
    static cgraph_local_info *local_info (tree decl);
  
    /* Return local info for the compiled function.  */
!   static cgraph_rtl_info *rtl_info (tree);
  
    /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
       Return NULL if there's no such node.  */
--- 1180,1186 ----
    static cgraph_local_info *local_info (tree decl);
  
    /* Return local info for the compiled function.  */
!   static struct cgraph_rtl_info *rtl_info (tree);
  
    /* Return the cgraph node that has ASMNAME for its DECL_ASSEMBLER_NAME.
       Return NULL if there's no such node.  */
*************** public:
*** 1263,1269 ****
  
    cgraph_local_info local;
    cgraph_global_info global;
!   cgraph_rtl_info rtl;
    cgraph_clone_info clone;
    cgraph_thunk_info thunk;
  
--- 1249,1255 ----
  
    cgraph_local_info local;
    cgraph_global_info global;
!   struct cgraph_rtl_info *rtl;
    cgraph_clone_info clone;
    cgraph_thunk_info thunk;
  
Index: rtl.h
===================================================================
*** rtl.h	(revision 224342)
--- rtl.h	(working copy)
*************** extern void _fatal_insn (const char *, c
*** 3709,3712 ****
--- 3709,3729 ----
  /* reginfo.c */
  extern tree GTY(()) global_regs_decl[FIRST_PSEUDO_REGISTER];
  
+ #ifdef HARD_CONST
+ /* Information about the function that is propagated by the RTL backend.
+    Available only for functions that has been already assembled.  */
+ 
+ struct GTY(()) cgraph_rtl_info {
+    unsigned int preferred_incoming_stack_boundary;
+ 
+   /* Call unsaved hard registers really used by the corresponding
+      function (including ones used by functions called by the
+      function).  */
+   HARD_REG_SET function_used_regs;
+   /* Set if function_used_regs is valid.  */
+   unsigned function_used_regs_valid: 1;
+ };
+ #endif
+ 
+ 
  #endif /* ! GCC_RTL_H */
Index: cgraph.c
===================================================================
*** cgraph.c	(revision 224342)
--- cgraph.c	(working copy)
*************** cgraph_node::rtl_info (tree decl)
*** 1894,1900 ****
    if (node->decl != current_function_decl
        && !TREE_ASM_WRITTEN (node->decl))
      return NULL;
!   return &node->ultimate_alias_target ()->rtl;
  }
  
  /* Return a string describing the failure REASON.  */
--- 1894,1903 ----
    if (node->decl != current_function_decl
        && !TREE_ASM_WRITTEN (node->decl))
      return NULL;
!   /* Allocate if it doesnt exist.  */
!   if (node->ultimate_alias_target ()->rtl == NULL)
!     node->ultimate_alias_target ()->rtl = ggc_cleared_alloc<cgraph_rtl_info> ();
!   return node->ultimate_alias_target ()->rtl;
  }
  
  /* Return a string describing the failure REASON.  */
Index: calls.c
===================================================================
*** calls.c	(revision 224342)
--- calls.c	(working copy)
*************** along with GCC; see the file COPYING3.
*** 21,26 ****
--- 21,27 ----
  #include "system.h"
  #include "coretypes.h"
  #include "tm.h"
+ #include "hard-reg-set.h"
  #include "rtl.h"
  #include "input.h"
  #include "alias.h"
*************** along with GCC; see the file COPYING3.
*** 32,38 ****
  #include "stringpool.h"
  #include "attribs.h"
  #include "predict.h"
- #include "hard-reg-set.h"
  #include "function.h"
  #include "basic-block.h"
  #include "tree-ssa-alias.h"
--- 33,38 ----
Index: ira.c
===================================================================
*** ira.c	(revision 224342)
--- ira.c	(working copy)
*************** along with GCC; see the file COPYING3.
*** 372,384 ****
  #include "alias.h"
  #include "symtab.h"
  #include "tree.h"
  #include "rtl.h"
  #include "tm_p.h"
  #include "target.h"
  #include "flags.h"
  #include "obstack.h"
  #include "bitmap.h"
- #include "hard-reg-set.h"
  #include "predict.h"
  #include "function.h"
  #include "dominance.h"
--- 372,384 ----
  #include "alias.h"
  #include "symtab.h"
  #include "tree.h"
+ #include "hard-reg-set.h"
  #include "rtl.h"
  #include "tm_p.h"
  #include "target.h"
  #include "flags.h"
  #include "obstack.h"
  #include "bitmap.h"
  #include "predict.h"
  #include "function.h"
  #include "dominance.h"