This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] Include dependencies in expr.h


I've started looking at one of the code cleanliness beginner projects - making
headers explicitly include what they depend on.

For this patch I've done so for expr.h, which has a bit of fallout.  To make
things work, I split some functions defined in alias.c into alias.h, and some
functions from emit-rtl.c into emit.h (I liked the shorter name, but
emit-rtl.h is fine if others prefer that).

I also updated Makefile.in to explicitly list dependencies that expr.h has.

Bootstrapped on i686-pc-linux-gnu

2004-05-26  Jerry Quinn  <jlquinn@optonline.net>

        * Makefile.in (EXPR_H): Add insn-config.h.
	(expr.h): New.
	(cselib.o): Replace EXPR_H with emit.h.
	(cfgcleanup.o): Add emit.h.
	(alias.o): Replace EXPR_H with emit.h and alias.h.
	* alias.c: Replace expr.h with emit.h and alias.h.
	* attribs.c, c-lex.c, c-obj-common.c, c-semantics.c: Remove expr.h.
	* cfgcleanup.c, cselib.c: Replace expr.h with emit.h.
	* expr.h: Add include guard.  Include function.h, rtl,h, flags.h,
	tree.h, machmode.h, insn-config.h, alias.h, emit.h.
	(get_varargs_alias_set, get_frame_alias_set, record_base_value,
	record_alias_subset, new_alias_set, can_address_p): Move to alias.h.
	(set_mem_alias_set, set_mem_align, set_mem_expr, set_mem_offset,
	set_mem_size): Move to emit.h.
	* emit.h: New.
	* alias.h: New.


Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.1281
diff -u -w -r1.1281 Makefile.in
--- Makefile.in	21 May 2004 19:50:48 -0000	1.1281
+++ Makefile.in	25 May 2004 21:42:50 -0000
@@ -686,7 +686,8 @@
 COVERAGE_H = coverage.h gcov-io.h gcov-iov.h
 DEMANGLE_H = $(srcdir)/../include/demangle.h
 RECOG_H = recog.h
-EXPR_H = expr.h
+EXPR_H = expr.h insn-config.h
+expr.h: function.h $(RTL_H) flags.h $(TREE_H) $(MACHMODE_H) emit.h
 OPTABS_H = optabs.h insn-codes.h
 REGS_H = regs.h varray.h $(MACHMODE_H)
 INTEGRATE_H = integrate.h varray.h
@@ -1825,9 +1826,9 @@
    toplev.h $(GGC_H) $(TARGET_H) langhooks.h $(COVERAGE_H) libfuncs.h \
    gt-coverage.h $(HASHTAB_H)
 cselib.o : cselib.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
-   hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
+   hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) emit.h toplev.h \
    output.h function.h cselib.h $(GGC_H) $(TM_P_H) gt-cselib.h $(PARAMS_H) \
    alloc-pool.h
 cse.o : cse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) $(REGS_H) \
    hard-reg-set.h flags.h real.h insn-config.h $(RECOG_H) $(EXPR_H) toplev.h \
    output.h function.h $(BASIC_BLOCK_H) $(GGC_H) $(TM_P_H) $(TIMEVAR_H) \
@@ -1910,7 +1915,7 @@
 cfgcleanup.o : cfgcleanup.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
    $(RTL_H) $(TIMEVAR_H) $(BASIC_BLOCK_H) hard-reg-set.h output.h flags.h \
    $(RECOG_H) toplev.h $(GGC_H) insn-config.h cselib.h $(TARGET_H) $(TM_P_H) \
-   $(PARAMS_H) $(REGS_H)
+   $(PARAMS_H) $(REGS_H) emit.h
 cfgloop.o : cfgloop.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) coretypes.h $(TM_H) \
    $(BASIC_BLOCK_H) hard-reg-set.h cfgloop.h flags.h
 cfgloopanal.o : cfgloopanal.c $(CONFIG_H) $(SYSTEM_H) $(RTL_H) \
@@ -1983,7 +1988,7 @@
    hard-reg-set.h $(BASIC_BLOCK_H) $(REGS_H) insn-config.h $(INSN_ATTR_H) except.h \
    $(RECOG_H) function.h flags.h output.h $(EXPR_H) toplev.h $(PARAMS_H) $(TM_P_H)
 alias.o : alias.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) flags.h \
-   hard-reg-set.h $(BASIC_BLOCK_H) $(REGS_H) toplev.h output.h $(EXPR_H) \
+   hard-reg-set.h $(BASIC_BLOCK_H) $(REGS_H) toplev.h output.h alias.h emit.h \
    $(GGC_H) function.h cselib.h $(TREE_H) $(TM_P_H) langhooks.h $(TARGET_H) \
    gt-alias.h $(TIMEVAR_H) cgraph.h
 regmove.o : regmove.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(RTL_H) insn-config.h \
Index: alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.224
diff -u -w -r1.224 alias.c
--- alias.c	30 Mar 2004 19:18:48 -0000	1.224
+++ alias.c	25 May 2004 21:42:50 -0000
@@ -28,7 +28,8 @@
 #include "tree.h"
 #include "tm_p.h"
 #include "function.h"
-#include "expr.h"
+#include "alias.h"
+#include "emit.h"
 #include "regs.h"
 #include "hard-reg-set.h"
 #include "basic-block.h"
Index: attribs.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/attribs.c,v
retrieving revision 1.30
diff -u -w -r1.30 attribs.c
--- attribs.c	30 Apr 2004 22:26:48 -0000	1.30
+++ attribs.c	25 May 2004 21:42:50 -0000
@@ -29,7 +29,6 @@
 #include "output.h"
 #include "rtl.h"
 #include "ggc.h"
-#include "expr.h"
 #include "tm_p.h"
 #include "cpplib.h"
 #include "target.h"
Index: c-lex.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lex.c,v
retrieving revision 1.220
diff -u -w -r1.220 c-lex.c
--- c-lex.c	27 Feb 2004 02:01:06 -0000	1.220
+++ c-lex.c	25 May 2004 21:42:51 -0000
@@ -27,7 +27,6 @@
 #include "real.h"
 #include "rtl.h"
 #include "tree.h"
-#include "expr.h"
 #include "input.h"
 #include "output.h"
 #include "c-tree.h"
Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.44
diff -u -w -r1.44 c-objc-common.c
--- c-objc-common.c	13 May 2004 06:39:29 -0000	1.44
+++ c-objc-common.c	25 May 2004 21:42:51 -0000
@@ -26,7 +26,6 @@
 #include "rtl.h"
 #include "insn-config.h"
 #include "integrate.h"
-#include "expr.h"
 #include "c-tree.h"
 #include "function.h"
 #include "flags.h"
Index: c-semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-semantics.c,v
retrieving revision 1.79
diff -u -w -r1.79 c-semantics.c
--- c-semantics.c	13 May 2004 06:39:29 -0000	1.79
+++ c-semantics.c	25 May 2004 21:42:51 -0000
@@ -39,7 +39,6 @@
 #include "flags.h"
 #include "ggc.h"
 #include "rtl.h"
-#include "expr.h"
 #include "output.h"
 #include "timevar.h"
 #include "predict.h"
Index: cfgcleanup.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cfgcleanup.c,v
retrieving revision 1.113
diff -u -w -r1.113 cfgcleanup.c
--- cfgcleanup.c	13 May 2004 06:39:32 -0000	1.113
+++ cfgcleanup.c	25 May 2004 21:42:51 -0000
@@ -50,7 +50,7 @@
 #include "target.h"
 #include "regs.h"
 #include "cfglayout.h"
-#include "expr.h"
+#include "emit.h"
 
 /* cleanup_cfg maintains following flags for each basic block.  */
 
Index: cselib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cselib.c,v
retrieving revision 1.45
diff -u -w -r1.45 cselib.c
--- cselib.c	22 Apr 2004 17:47:47 -0000	1.45
+++ cselib.c	25 May 2004 21:42:51 -0000
@@ -33,7 +33,7 @@
 #include "insn-config.h"
 #include "recog.h"
 #include "function.h"
-#include "expr.h"
+#include "emit.h"
 #include "toplev.h"
 #include "output.h"
 #include "ggc.h"
Index: expr.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.h,v
retrieving revision 1.157
diff -u -w -r1.157 expr.h
--- expr.h	15 May 2004 23:07:45 -0000	1.157
+++ expr.h	25 May 2004 21:42:52 -0000
@@ -19,6 +19,21 @@
 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA.  */
 
+#ifndef GCC_EXPR_H
+#define GCC_EXPR_H
+
+/* For inhibit_defer_pop */
+#include "function.h"
+/* For XEXP, GEN_INT, rtx_code */
+#include "rtl.h"
+/* For optimize_size */
+#include "flags.h"
+/* For host_integerp, tree_low_cst, convert, size_binop, ssize_int, TREE_CODE,
+   TYPE_SIZE, int_size_in_bytes,    */
+#include "tree.h"
+/* For GET_MODE_BITSIZE, word_mode */
+#include "machmode.h"
+
 /* The default branch cost is 1.  */
 #ifndef BRANCH_COST
 #define BRANCH_COST 1
@@ -305,6 +320,8 @@
 /* Generate code to indirectly jump to a location given in the rtx LOC.  */
 extern void emit_indirect_jump (rtx);
 
+#include "insn-config.h"
+
 #ifdef HAVE_conditional_move
 /* Emit a conditional move operation.  */
 rtx emit_conditional_move (rtx, enum rtx_code, rtx, rtx, enum machine_mode,
@@ -360,12 +377,6 @@
 extern void expand_builtin_longjmp (rtx, rtx);
 extern rtx expand_builtin_saveregs (void);
 extern void expand_builtin_trap (void);
-extern HOST_WIDE_INT get_varargs_alias_set (void);
-extern HOST_WIDE_INT get_frame_alias_set (void);
-extern void record_base_value (unsigned int, rtx, int);
-extern void record_alias_subset (HOST_WIDE_INT, HOST_WIDE_INT);
-extern HOST_WIDE_INT new_alias_set (void);
-extern int can_address_p (tree);
 extern tree simplify_builtin_fputs (tree, int, int, tree);
 extern tree simplify_builtin_strcpy (tree, tree);
 extern tree simplify_builtin_strncpy (tree, tree);
@@ -563,6 +574,15 @@
    XXX Should be a target hook.  */
 extern unsigned int case_values_threshold (void);
 
+/* Functions from alias.c */
+#include "alias.h"
+/* extern HOST_WIDE_INT new_alias_set (void); */
+/* extern void record_alias_subset (HOST_WIDE_INT, HOST_WIDE_INT); */
+/* extern HOST_WIDE_INT get_varargs_alias_set (void); */
+/* extern HOST_WIDE_INT get_frame_alias_set (void); */
+/* extern void record_base_value (unsigned int, rtx, int); */
+/* extern int can_address_p (tree); */
+
 
 /* rtl.h and tree.h were included.  */
 /* Return an rtx for the size in bytes of the value of an expr.  */
@@ -623,21 +643,6 @@
 /* Like `memory_address' but pretent `flag_force_addr' is 0.  */
 extern rtx memory_address_noforce (enum machine_mode, rtx);
 
-/* Set the alias set of MEM to SET.  */
-extern void set_mem_alias_set (rtx, HOST_WIDE_INT);
-
-/* Set the alignment of MEM to ALIGN bits.  */
-extern void set_mem_align (rtx, unsigned int);
-
-/* Set the expr for MEM to EXPR.  */
-extern void set_mem_expr (rtx, tree);
-
-/* Set the offset for MEM to OFFSET.  */
-extern void set_mem_offset (rtx, rtx);
-
-/* Set the size for MEM to SIZE.  */
-extern void set_mem_size (rtx, rtx);
-
 /* Return a memory reference like MEMREF, but with its mode changed
    to MODE and its address changed to ADDR.
    (VOIDmode means don't change the mode.
@@ -672,14 +677,8 @@
    known to be in OFFSET (possibly 1).  */
 extern rtx offset_address (rtx, rtx, unsigned HOST_WIDE_INT);
 
-/* Return a memory reference like MEMREF, but with its address changed to
-   ADDR.  The caller is asserting that the actual piece of memory pointed
-   to is the same, just the form of the address is being changed, such as
-   by putting something into a register.  */
-extern rtx replace_equiv_address (rtx, rtx);
-
-/* Likewise, but the reference is not required to be valid.  */
-extern rtx replace_equiv_address_nv (rtx, rtx);
+/* Definitions from emit-rtl.c */
+#include "emit.h"
 
 /* Return a memory reference like MEMREF, but with its mode widened to
    MODE and adjusted by OFFSET.  */
@@ -810,3 +809,5 @@
 					  rtx, rtx);
 
 extern int vector_mode_valid_p (enum machine_mode);
+
+#endif /* GCC_EXPR_H */
--- oldgcc/emit.h	2004-05-25 17:46:15.000000000 -0400
+++ gcc/emit.h	2004-05-25 15:48:27.000000000 -0400
@@ -0,0 +1,48 @@
+/* Exported functions from emit-rtl.c
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+#ifndef GCC_EMIT_H
+#define GCC_EMIT_H
+
+/* Set the alias set of MEM to SET.  */
+extern void set_mem_alias_set (rtx, HOST_WIDE_INT);
+
+/* Set the alignment of MEM to ALIGN bits.  */
+extern void set_mem_align (rtx, unsigned int);
+
+/* Set the expr for MEM to EXPR.  */
+extern void set_mem_expr (rtx, tree);
+
+/* Set the offset for MEM to OFFSET.  */
+extern void set_mem_offset (rtx, rtx);
+
+/* Set the size for MEM to SIZE.  */
+extern void set_mem_size (rtx, rtx);
+
+/* Return a memory reference like MEMREF, but with its address changed to
+   ADDR.  The caller is asserting that the actual piece of memory pointed
+   to is the same, just the form of the address is being changed, such as
+   by putting something into a register.  */
+extern rtx replace_equiv_address (rtx, rtx);
+
+/* Likewise, but the reference is not required to be valid.  */
+extern rtx replace_equiv_address_nv (rtx, rtx);
+
+#endif /* GCC_EMIT_H */
--- oldgcc/alias.h	2004-05-25 17:46:18.000000000 -0400
+++ gcc/alias.h	2004-05-25 13:37:07.000000000 -0400
@@ -0,0 +1,31 @@
+/* Exported functions from alias.c
+   Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+#ifndef GCC_ALIAS_H
+#define GCC_ALIAS_H
+
+extern HOST_WIDE_INT new_alias_set (void);
+extern void record_alias_subset (HOST_WIDE_INT, HOST_WIDE_INT);
+extern HOST_WIDE_INT get_varargs_alias_set (void);
+extern HOST_WIDE_INT get_frame_alias_set (void);
+extern void record_base_value (unsigned int, rtx, int);
+extern int can_address_p (tree);
+
+#endif /* GCC_ALIAS_H */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]