Commit 0a050485 by Daniel Berlin Committed by Daniel Berlin

Makefile.def: Remove libbanshee.

Toplevel:

2004-09-09  Daniel Berlin  <dberlin@dberlin.org>

	* Makefile.def: Remove libbanshee.
	* Makefile.tpl: Ditto.
	* configure.in: Ditto.
	* Makefile.in: Regen.
	* configure: Ditto.

gcc/

2004-09-09  Daniel Berlin  <dberlin@dberlin.org>

	* Makefile.in: Remove libbanshee, tree-alias-*.
	Remove tree-alias-common.h dependencies.
	* common.opt: Remove -ftree-points-to.
	* configure.ac: Remove libbanshee.
	* flags.h: Remove pta_type, flag_tree_points_to.
	* gengtype.c (open_base_files): Remove tree-alias-type.h.
	* opts.c (OPT_ftree_points_to): Remove.
	* toplev.c: Remove tree-alias-common.h, flag_tree_points_to.
	* tree-dfa.c: Remove tree-alias-common.h
	* tree-into-ssa.c: Ditto.
	* tree-outof-ssa.c: Ditto.
	* tree-ssa-copyrename.c: Ditto.
	* tree-ssa-live.c: Ditto.
	* tree-optimize.c: Ditto.
	* tree-ssa.c: Ditto.
	Remove pass_build_pta, pass_del_pta.
	* tree-pass.h: Ditto.
	* tree-ssa-alias.c: Remove tree-alias-common.h.
	(struct alias_stats_d):	Remove pta_queries, pta_resolved.
	(pass_may_alias): Remove PROP_pta requirement.
	(may_alias_p): Remove pta_queries, pta_resolved, use of andersens.
	(get_tmt_for): Ditto.
	(dump_alias_stats): Ditto.
	* doc/passes.texi: Remove blurb about points-to analysis.
	* fortran/Make-lang.in: Remove tree-alias-*.o.

From-SVN: r87253
parent c1a404bd
2004-09-09 Daniel Berlin <dberlin@dberlin.org>
* Makefile.def: Remove libbanshee.
* Makefile.tpl: Ditto.
* configure.in: Ditto.
* Makefile.in: Regen.
* configure: Ditto.
2004-09-08 David Edelsohn <edelsohn@gnu.org>
* ltmain.sh: Use $pic_object as $non_pic_object if
......
......@@ -70,7 +70,6 @@ host_modules= { module= itcl; };
host_modules= { module= ld; bootstrap=true; };
host_modules= { module= libcpp; bootstrap=true; };
host_modules= { module= libgui; };
host_modules= { module= libbanshee; bootstrap=true; no_install=true; };
host_modules= { module= libiberty; bootstrap=true; };
host_modules= { module= libtool; };
host_modules= { module= m4; };
......@@ -253,7 +252,6 @@ dependencies = { module=all-gcc; on=all-binutils; };
dependencies = { module=all-gcc; on=all-gas; };
dependencies = { module=all-gcc; on=all-ld; };
dependencies = { module=all-gcc; on=all-zlib; };
dependencies = { module=all-gcc; on=all-libbanshee; };
dependencies = { module=all-gcc; on=all-libcpp; hard=true; };
dependencies = { module=all-gcc; on=all-build-libiberty; };
......
......@@ -107,7 +107,7 @@ REALLY_SET_LIB_PATH = \
$(RPATH_ENVVAR)=`echo "$(HOST_LIB_PATH):$(TARGET_LIB_PATH):$$$(RPATH_ENVVAR)" | sed 's,::*,:,g;s,^:*,,;s,:*$$,,'`; export $(RPATH_ENVVAR);
# This is the list of directories to be built for the build system.
BUILD_CONFIGDIRS = libiberty libbanshee
BUILD_CONFIGDIRS = libiberty
# Build programs are put under this directory.
BUILD_SUBDIR = @build_subdir@
# This is set by the configure script to the arguments to use when configuring
......
......@@ -136,7 +136,7 @@ build_tools="build-texinfo build-byacc build-flex build-bison build-m4 build-fix
# these libraries are used by various programs built for the host environment
#
host_libs="intl mmalloc libiberty opcodes bfd readline tcl tk itcl libgui zlib libbanshee libcpp"
host_libs="intl mmalloc libiberty opcodes bfd readline tcl tk itcl libgui zlib libcpp"
# these tools are built for the host environment
# Note, the powerpc-eabi build depends on sim occurring before gdb in order to
......@@ -308,17 +308,6 @@ case "${host}" in
;;
esac
AC_ARG_WITH(libbanshee,
[ --without-libbanshee Don't build with libbanshee])
case ${with_libbanshee} in
no)
noconfigdirs="$noconfigdirs libbanshee" ;;
yes|"")
with_libbanshee=yes
;;
*)
AC_MSG_ERROR([--with-libbanshee can only be empty, "yes" or "no" (empty defaults to "yes".])
esac
AC_ARG_ENABLE(libada,
[ --enable-libada Builds libada directory],
......@@ -1526,10 +1515,6 @@ if test x${with_newlib} != xno && echo " ${target_configdirs} " | grep " target-
extra_host_args="$extra_host_args --with-newlib"
fi
if test x${with_libbanshee} = xyes && echo " ${configdirs} " | grep " libbanshee " >/dev/null 2>&1; then
extra_host_args="$extra_host_args --with-libbanshee"
fi
# Default to using --with-stabs for certain targets.
if test x${with_stabs} = x ; then
case "${target}" in
......
2004-09-09 Daniel Berlin <dberlin@dberlin.org>
* Makefile.in: Remove libbanshee, tree-alias-*.
Remove tree-alias-common.h dependencies.
* common.opt: Remove -ftree-points-to.
* configure.ac: Remove libbanshee.
* flags.h: Remove pta_type, flag_tree_points_to.
* gengtype.c (open_base_files): Remove tree-alias-type.h.
* opts.c (OPT_ftree_points_to): Remove.
* toplev.c: Remove tree-alias-common.h, flag_tree_points_to.
* tree-dfa.c: Remove tree-alias-common.h
* tree-into-ssa.c: Ditto.
* tree-outof-ssa.c: Ditto.
* tree-ssa-copyrename.c: Ditto.
* tree-ssa-live.c: Ditto.
* tree-optimize.c: Ditto.
* tree-ssa.c: Ditto.
Remove pass_build_pta, pass_del_pta.
* tree-pass.h: Ditto.
* tree-ssa-alias.c: Remove tree-alias-common.h.
(struct alias_stats_d): Remove pta_queries, pta_resolved.
(pass_may_alias): Remove PROP_pta requirement.
(may_alias_p): Remove pta_queries, pta_resolved, use of andersens.
(get_tmt_for): Ditto.
(dump_alias_stats): Ditto.
* doc/passes.texi: Remove blurb about points-to analysis.
* fortran/Make-lang.in: Remove tree-alias-*.o.
2004-09-09 Richard Sandiford <rsandifo@redhat.com>
* genattrtab.c (write_insn_cases): New function, split out from
......
......@@ -200,8 +200,6 @@ SYSCALLS.c.X-warn = -Wno-strict-prototypes -Wno-error
# recognizing that the loop will always be executed at least once. We need
# a new loop optimizer.
reload1.o-warn = -Wno-error
# These warnings are due to libbanshee.
tree-alias-ander.o-warn = -Wno-error
# All warnings have to be shut off in stage1 if the compiler used then
# isn't gcc; configure determines that. WARN_CFLAGS will be either
......@@ -286,9 +284,6 @@ ZLIBINC = @zlibinc@
GMPLIBS = @GMPLIBS@
GMPINC = @GMPINC@
BANSHEELIB = @BANSHEELIB@
BANSHEEINC = @BANSHEEINC@
CPPLIB = ../libcpp/libcpp.a
CPPINC = -I$(srcdir)/../libcpp/include
......@@ -757,7 +752,7 @@ LIBIBERTY = ../libiberty/libiberty.a
BUILD_LIBIBERTY = ../$(build_subdir)/libiberty/libiberty.a
# Dependencies on the intl and portability libraries.
LIBDEPS= $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP) $(BANSHEELIB)
LIBDEPS= $(CPPLIB) $(LIBIBERTY) $(LIBINTL_DEP) $(LIBICONV_DEP)
# Likewise, for use in the tools that must run on this machine
# even if we are cross-building GCC.
......@@ -765,7 +760,7 @@ BUILD_LIBDEPS= $(BUILD_LIBIBERTY)
# How to link with both our special library facilities
# and the system's installed libraries.
LIBS = @LIBS@ $(CPPLIB) $(LIBINTL) $(LIBICONV) $(BANSHEELIB) $(LIBIBERTY)
LIBS = @LIBS@ $(CPPLIB) $(LIBINTL) $(LIBICONV) $(LIBIBERTY)
# Any system libraries needed just for GNAT.
SYSLIBS = @GNAT_LIBEXC@
......@@ -794,7 +789,7 @@ BUILD_VARRAY = build-varray.o
# libintl.h will be found in ../intl if we are using the included libintl.
INCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \
-I$(srcdir)/../include @INCINTL@ \
$(CPPINC) $(BANSHEEINC) $(GMPINC)
$(CPPINC) $(GMPINC)
.c.o:
$(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
......@@ -890,9 +885,9 @@ C_OBJS = c-parse.o c-lang.o stub-objc.o $(C_AND_OBJC_OBJS)
OBJS-common = \
tree-chrec.o tree-scalar-evolution.o tree-data-ref.o \
tree-cfg.o tree-dfa.o tree-eh.o tree-ssa.o tree-optimize.o tree-gimple.o \
tree-alias-type.o gimplify.o tree-pretty-print.o tree-into-ssa.o \
tree-outof-ssa.o tree-alias-common.o tree-ssa-ccp.o tree-vn.o \
@ANDER@ tree-ssa-dce.o tree-ssa-copy.o tree-nrv.o tree-ssa-copyrename.o \
gimplify.o tree-pretty-print.o tree-into-ssa.o \
tree-outof-ssa.o tree-ssa-ccp.o tree-vn.o \
tree-ssa-dce.o tree-ssa-copy.o tree-nrv.o tree-ssa-copyrename.o \
tree-ssa-pre.o tree-ssa-live.o tree-ssa-operands.o tree-ssa-alias.o \
tree-ssa-phiopt.o tree-ssa-forwprop.o tree-nested.o tree-ssa-dse.o \
tree-ssa-dom.o domwalk.o tree-tailcall.o gimple-low.o tree-iterator.o \
......@@ -1556,7 +1551,7 @@ gtype-desc.o: gtype-desc.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
varray.h $(HASHTAB_H) $(SPLAY_TREE_H) bitmap.h $(TREE_H) $(RTL_H) \
function.h insn-config.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
cselib.h insn-addr.h $(OPTABS_H) libfuncs.h debug.h $(GGC_H) \
cgraph.h tree-alias-type.h $(TREE_FLOW_H) reload.h $(CPP_ID_DATA_H)
cgraph.h $(TREE_FLOW_H) reload.h $(CPP_ID_DATA_H)
ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GGC_H) \
$(HASHTAB_H) toplev.h $(PARAMS_H) hosthooks.h
......@@ -1599,31 +1594,19 @@ stor-layout.o : stor-layout.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(PARAMS_H) $(FLAGS_H) function.h $(EXPR_H) $(RTL_H) toplev.h \
$(GGC_H) $(TM_P_H) $(TARGET_H) \
langhooks.h $(REGS_H)
tree-alias-type.o: tree-alias-type.c tree-alias-type.h $(SYSTEM_H) $(CONFIG_H) \
$(GGC_H) $(TM_H) coretypes.h $(VARRAY_H)
tree-alias-ander.o: tree-alias-ander.c tree-alias-ander.h $(SYSTEM_H) \
$(CONFIG_H) $(GGC_H) $(TREE_H) $(TREE_FLOW_H) tree-alias-common.h \
$(TM_H) coretypes.h cgraph.h tree-pass.h
tree-alias-common.o: tree-alias-common.c tree-alias-common.h $(SYSTEM_H) \
$(CONFIG_H) $(GGC_H) $(TREE_H) gt-tree-alias-common.h $(TREE_FLOW_H) \
$(TM_H) coretypes.h cgraph.h tree-pass.h $(TIMEVAR_H) tree-alias-type.h \
bitmap.h tree-alias-ander.h $(FLAGS_H) $(RTL_H) $(TM_P_H) \
hard-reg-set.h $(BASIC_BLOCK_H) output.h errors.h $(EXPR_H) \
$(DIAGNOSTIC_H) $(C_COMMON_H) tree-inline.h varray.h $(C_TREE_H) \
$(TREE_GIMPLE_H) $(HASHTAB_H) function.h
tree-ssa.o : tree-ssa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) output.h diagnostic.h \
errors.h toplev.h function.h $(TIMEVAR_H) tree-alias-common.h \
errors.h toplev.h function.h $(TIMEVAR_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) langhooks.h $(CFGLOOP_H) \
tree-pass.h
tree-into-ssa.o : tree-into-ssa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) output.h diagnostic.h \
errors.h toplev.h function.h $(TIMEVAR_H) tree-alias-common.h \
errors.h toplev.h function.h $(TIMEVAR_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) langhooks.h domwalk.h tree-pass.h \
$(GGC_H)
tree-outof-ssa.o : tree-outof-ssa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) output.h diagnostic.h \
errors.h toplev.h function.h $(TIMEVAR_H) tree-alias-common.h \
errors.h toplev.h function.h $(TIMEVAR_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) langhooks.h domwalk.h \
tree-pass.h $(TREE_SSA_LIVE_H)
tree-ssa-dse.o : tree-ssa-dse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
......@@ -1665,12 +1648,12 @@ domwalk.o : domwalk.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(BASIC_BLOCK_H) $(TREE_FLOW_H) domwalk.h $(GGC_H)
tree-ssa-live.o : tree-ssa-live.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \
errors.h toplev.h function.h $(TIMEVAR_H) tree-alias-common.h \
errors.h toplev.h function.h $(TIMEVAR_H) \
$(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_SSA_LIVE_H)
tree-ssa-copyrename.o : tree-ssa-copyrename.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h \
diagnostic.h errors.h toplev.h function.h $(TIMEVAR_H) tree-pass.h \
tree-alias-common.h $(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_SSA_LIVE_H)
$(TM_H) coretypes.h $(TREE_DUMP_H) $(TREE_SSA_LIVE_H)
tree-ssa-pre.o : tree-ssa-pre.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(TREE_H) $(TM_P_H) $(EXPR_H) \
$(GGC_H) output.h diagnostic.h errors.h toplev.h $(TIMEVAR_H) \
......@@ -1697,7 +1680,7 @@ tree-iterator.o : tree-iterator.c $(CONFIG_H) $(SYSTEM_H) $(TREE_H) \
tree-dfa.o : tree-dfa.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) output.h diagnostic.h \
errors.h tree-inline.h $(HASHTAB_H) $(FLAGS_H) function.h $(TIMEVAR_H) \
tree-alias-common.h convert.h $(TM_H) coretypes.h langhooks.h \
convert.h $(TM_H) coretypes.h langhooks.h \
$(TREE_DUMP_H) tree-pass.h params.h
tree-ssa-operands.o : tree-ssa-operands.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(TREE_H) $(TM_P_H) $(GGC_H) diagnostic.h errors.h \
......@@ -1736,11 +1719,11 @@ tree-ssa-loop-im.o : tree-ssa-loop-im.c $(TREE_FLOW_H) $(CONFIG_H) \
tree-pass.h flags.h
tree-ssa-alias.o : tree-ssa-alias.c $(TREE_FLOW_H) $(CONFIG_H) $(SYSTEM_H) \
$(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) $(GGC_H) tree-inline.h $(FLAGS_H) \
function.h $(TIMEVAR_H) tree-alias-common.h convert.h $(TM_H) coretypes.h \
function.h $(TIMEVAR_H) convert.h $(TM_H) coretypes.h \
langhooks.h $(TREE_DUMP_H) tree-pass.h params.h
tree-optimize.o : tree-optimize.c $(TREE_FLOW_H) $(CONFIG_H) \
$(SYSTEM_H) $(RTL_H) $(TREE_H) $(TM_P_H) $(EXPR_H) \
$(GGC_H) output.h diagnostic.h errors.h $(FLAGS_H) tree-alias-common.h \
$(GGC_H) output.h diagnostic.h errors.h $(FLAGS_H) \
$(TIMEVAR_H) $(TM_H) coretypes.h $(TREE_DUMP_H) toplev.h function.h \
langhooks.h $(FLAGS_H) cgraph.h tree-inline.h tree-mudflap.h $(GGC_H) \
cgraph.h tree-pass.h
......@@ -2430,8 +2413,6 @@ GTFILES = $(srcdir)/input.h $(srcdir)/coretypes.h \
$(srcdir)/tree-phinodes.c $(srcdir)/tree-cfg.c \
$(srcdir)/tree-dfa.c $(srcdir)/tree-ssa-propagate.c \
$(srcdir)/tree-iterator.c $(srcdir)/gimplify.c \
$(srcdir)/tree-alias-type.h $(srcdir)/tree-alias-common.h \
$(srcdir)/tree-alias-type.c $(srcdir)/tree-alias-common.c \
$(srcdir)/tree-chrec.h \
$(srcdir)/tree-ssa-operands.h $(srcdir)/tree-ssa-operands.c \
$(srcdir)/tree-profile.c $(srcdir)/rtl-profile.c $(srcdir)/tree-nested.c \
......@@ -2451,7 +2432,7 @@ gt-expr.h gt-sdbout.h gt-optabs.h gt-bitmap.h gt-dojump.h \
gt-dwarf2out.h gt-ra-build.h gt-reg-stack.h gt-dwarf2asm.h \
gt-dbxout.h gt-c-common.h gt-c-decl.h gt-c-parse.h \
gt-c-pragma.h gtype-c.h gt-input.h gt-cfglayout.h \
gt-tree-alias-common.h gt-tree-mudflap.h \
gt-tree-mudflap.h \
gt-tree-ssa-ccp.h gt-tree-eh.h \
gt-tree-ssanames.h gt-tree-iterator.h gt-gimplify.h \
gt-tree-phinodes.h gt-tree-cfg.h gt-tree-nested.h \
......
......@@ -876,9 +876,6 @@ ftree-loop-optimize
Common Report Var(flag_tree_loop_optimize) Init(1)
Enable loop optimizations on tree level
ftree-points-to=
Common Joined RejectNegative
ftree-pre
Common Report Var(flag_tree_pre)
Enable SSA-PRE optimization on trees
......
......@@ -309,7 +309,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_subdir host_subdir target_subdir GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP strict1_warn warn_cflags WERROR nocommon_flag TREEBROWSER EGREP valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR stage1_cflags COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file PACKAGE VERSION USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS STMP_FIXINC STMP_FIXPROTO collect2 libgcc_visibility GGC zlibdir zlibinc MAINT ANDER BANSHEEINC BANSHEELIB gcc_tooldir dollar slibdir objdir subdirs srcdir all_boot_languages all_compilers all_gtfiles all_gtfiles_files_langs all_gtfiles_files_files all_lang_makefrags all_lang_makefiles all_languages all_stagestuff build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines check_languages cc_set_by_configure quoted_cc_set_by_configure cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir libstdcxx_incdir gcc_version gcc_version_full gcc_version_trigger host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file stage_prefix_set_by_configure quoted_stage_prefix_set_by_configure symbolic_link thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs target_cpu_default GMPLIBS GMPINC LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os target_noncanonical build_subdir host_subdir target_subdir GENINSRC CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT NO_MINUS_C_MINUS_O OUTPUT_OPTION CPP strict1_warn warn_cflags WERROR nocommon_flag TREEBROWSER EGREP valgrind_path valgrind_path_defines valgrind_command coverage_flags enable_multilib enable_shared TARGET_SYSTEM_ROOT TARGET_SYSTEM_ROOT_DEFINE CROSS_SYSTEM_HEADER_DIR onestep SET_MAKE AWK LN_S LN RANLIB ac_ct_RANLIB ranlib_flags INSTALL INSTALL_PROGRAM INSTALL_DATA make_compare_target have_mktemp_command MAKEINFO BUILD_INFO GENERATED_MANPAGES FLEX BISON NM AR stage1_cflags COLLECT2_LIBS GNAT_LIBEXC LDEXP_LIB TARGET_GETGROUPS_T LIBICONV LIBICONV_DEP manext objext gthread_flags extra_modes_file PACKAGE VERSION USE_NLS LIBINTL LIBINTL_DEP INCINTL XGETTEXT GMSGFMT POSUB CATALOGS CROSS ALL SYSTEM_HEADER_DIR inhibit_libc CC_FOR_BUILD BUILD_CFLAGS STMP_FIXINC STMP_FIXPROTO collect2 libgcc_visibility GGC zlibdir zlibinc MAINT gcc_tooldir dollar slibdir objdir subdirs srcdir all_boot_languages all_compilers all_gtfiles all_gtfiles_files_langs all_gtfiles_files_files all_lang_makefrags all_lang_makefiles all_languages all_stagestuff build_exeext build_install_headers_dir build_xm_file_list build_xm_include_list build_xm_defines check_languages cc_set_by_configure quoted_cc_set_by_configure cpp_install_dir xmake_file tmake_file extra_gcc_objs extra_headers_list extra_objs extra_parts extra_passes extra_programs float_h_file gcc_config_arguments gcc_gxx_include_dir libstdcxx_incdir gcc_version gcc_version_full gcc_version_trigger host_exeext host_xm_file_list host_xm_include_list host_xm_defines out_host_hook_obj install lang_opt_files lang_specs_files lang_tree_files local_prefix md_file objc_boehm_gc out_file out_object_file stage_prefix_set_by_configure quoted_stage_prefix_set_by_configure symbolic_link thread_file tm_file_list tm_include_list tm_defines tm_p_file_list tm_p_include_list xm_file_list xm_include_list xm_defines c_target_objs cxx_target_objs target_cpu_default GMPLIBS GMPINC LIBOBJS LTLIBOBJS'
ac_subst_files='language_hooks'
# Initialize some variables set by options.
......@@ -925,7 +925,6 @@ Optional Packages:
--with-gc={page,zone} choose the garbage collection mechanism to use
with the compiler
--with-system-zlib use installed libz
--with-libbanshee enable libbanshee
--with-slibdir=DIR shared libraries in DIR LIBDIR
Some influential environment variables:
......@@ -5291,7 +5290,7 @@ if test "${gcc_cv_prog_makeinfo_modern+set}" = set; then
else
ac_prog_version=`$MAKEINFO --version 2>&1 |
sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'`
echo "configure:5294: version of makeinfo is $ac_prog_version" >&5
echo "configure:5293: version of makeinfo is $ac_prog_version" >&5
case $ac_prog_version in
'') gcc_cv_prog_makeinfo_modern=no;;
4.[2-9]*)
......@@ -12186,38 +12185,6 @@ else
MAINT='#'
fi
echo "$as_me:$LINENO: checking whether to use libbanshee for points-to alias analysis" >&5
echo $ECHO_N "checking whether to use libbanshee for points-to alias analysis... $ECHO_C" >&6
# Check whether --with-libbanshee or --without-libbanshee was given.
if test "${with_libbanshee+set}" = set; then
withval="$with_libbanshee"
libbanshee="$with_libbanshee"
else
libbanshee=no
fi;
if test x"$libbanshee" = xyes; then
BANSHEELIB="../libbanshee/points-to/libandersen.a ../libbanshee/engine/libbansheeengine.a ../libbanshee/libcompat/libbansheecompat.a "
BANSHEEINC="-I\$(srcdir)/../libbanshee/libcompat -I\$(srcdir)/../libbanshee -I\$(srcdir)/../libbanshee/points-to"
ANDER="tree-alias-ander.o"
cat >>confdefs.h <<\_ACEOF
#define HAVE_BANSHEE 1
_ACEOF
else
BANSHEELIB=""
BANSHEEINC=""
ANDER=""
fi
echo "$as_me:$LINENO: result: $with_libbanshee" >&5
echo "${ECHO_T}$with_libbanshee" >&6
# --------------
# Language hooks
# --------------
......@@ -13250,9 +13217,6 @@ s,@GGC@,$GGC,;t t
s,@zlibdir@,$zlibdir,;t t
s,@zlibinc@,$zlibinc,;t t
s,@MAINT@,$MAINT,;t t
s,@ANDER@,$ANDER,;t t
s,@BANSHEEINC@,$BANSHEEINC,;t t
s,@BANSHEELIB@,$BANSHEELIB,;t t
s,@gcc_tooldir@,$gcc_tooldir,;t t
s,@dollar@,$dollar,;t t
s,@slibdir@,$slibdir,;t t
......
......@@ -2973,28 +2973,6 @@ else
fi
AC_SUBST(MAINT)dnl
AC_MSG_CHECKING([whether to use libbanshee for points-to alias analysis])
AC_ARG_WITH(libbanshee,
[ --with-libbanshee enable libbanshee],
libbanshee="$with_libbanshee",
libbanshee=no)
if test x"$libbanshee" = xyes; then
BANSHEELIB="../libbanshee/points-to/libandersen.a ../libbanshee/engine/libbansheeengine.a ../libbanshee/libcompat/libbansheecompat.a "
BANSHEEINC="-I\$(srcdir)/../libbanshee/libcompat -I\$(srcdir)/../libbanshee -I\$(srcdir)/../libbanshee/points-to"
ANDER="tree-alias-ander.o"
AC_DEFINE(HAVE_BANSHEE, 1, [Define if BANSHEE is available])
else
BANSHEELIB=""
BANSHEEINC=""
ANDER=""
fi
AC_MSG_RESULT($with_libbanshee)
AC_SUBST(ANDER)
AC_SUBST(BANSHEEINC)
AC_SUBST(BANSHEELIB)
# --------------
# Language hooks
# --------------
......
......@@ -240,12 +240,6 @@ for the variable within this function. This data is needed by the
SSA rewriting routines. The pass is located in @file{tree-dfa.c}
and is described by @code{pass_referenced_vars}.
@item Points-to analysis
This pass constructs flow-insensitive alias analysis information.
The pass is located in @file{tree-alias-common.c} and described by
@code{pass_build_pta}.
@item Enter static single assignment form
This pass rewrites the function such that it is in SSA form. After
......
......@@ -240,14 +240,6 @@ extern enum graph_dump_types graph_dump_format;
and to print them when we are done. */
extern int flag_detailed_statistics;
/* Enable points-to analysis on trees. */
enum pta_type
{
PTA_NONE,
PTA_ANDERSEN
};
extern enum pta_type flag_tree_points_to;
extern int flag_web;
/* Nonzero means that we defer emitting functions until they are actually
......
......@@ -83,7 +83,7 @@ F95_OBJS = $(F95_PARSER_OBJS) \
F95_ADDITIONAL_OBJS = \
tree-cfg.o tree-dfa.o tree-optimize.o tree-gimple.o \
tree-ssa.o tree-ssa-ccp.o tree-ssa-dce.o \
tree-alias-common.o tree-alias-type.o gimplify.o stor-layout.o
gimplify.o stor-layout.o
# GFORTRAN uses GMP for its internal arithmetics.
F95_LIBS = $(GMPLIBS) $(LIBS)
......
......@@ -1085,7 +1085,7 @@ open_base_files (void)
"function.h", "insn-config.h", "expr.h", "hard-reg-set.h",
"basic-block.h", "cselib.h", "insn-addr.h", "optabs.h",
"libfuncs.h", "debug.h", "ggc.h", "cgraph.h",
"tree-alias-type.h", "tree-flow.h", "reload.h",
"tree-flow.h", "reload.h",
"cpp-id-data.h",
"tree-chrec.h",
NULL
......
......@@ -954,22 +954,6 @@ common_handle_option (size_t scode, const char *arg, int value)
flag_tracer_set = true;
break;
case OPT_ftree_points_to_:
if (!strcmp (arg, "andersen"))
#ifdef HAVE_BANSHEE
flag_tree_points_to = PTA_ANDERSEN;
#else
warning ("Andersen's PTA not available - libbanshee not compiled.");
#endif
else if (!strcmp (arg, "none"))
flag_tree_points_to = PTA_NONE;
else
{
warning ("`%s`: unknown points-to analysis algorithm", arg);
return 0;
}
break;
case OPT_funroll_loops:
flag_unroll_loops_set = true;
break;
......
......@@ -74,7 +74,6 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "target.h"
#include "langhooks.h"
#include "cfglayout.h"
#include "tree-alias-common.h"
#include "cfgloop.h"
#include "hosthooks.h"
#include "cgraph.h"
......@@ -332,9 +331,6 @@ rtx stack_limit_rtx;
one, unconditionally renumber instruction UIDs. */
int flag_renumber_insns = 1;
/* Enable points-to analysis on trees. */
enum pta_type flag_tree_points_to = PTA_NONE;
/* Nonzero if we should track variables. When
flag_var_tracking == AUTODETECT_FLAG_VAR_TRACKING it will be set according
to optimize, debug_info_level and debug_hooks in process_options (). */
......
/* Tree based Andersen points-to analysis
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@dberlin.org>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, 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; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TREE_ALIAS_ANDER
#define TREE_ALIAS_ANDER
#include "tree-alias-common.h"
extern struct tree_alias_ops *andersen_alias_ops;
#endif /* TREE_ALIAS_ANDER */
/* Tree based points-to analysis
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@dberlin.org>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, 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; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TREE_ALIAS_COMMON
#define TREE_ALIAS_COMMON
#include "tree-alias-type.h"
/* Alias analysis function pointers.
Functions implemented by the actual alias analysis algorithms in
order for them to work with the common points-to structure. */
struct tree_alias_ops
{
/* Initialization.
Called right before we start using the other functions. */
void (*init) (struct tree_alias_ops *);
/* Cleanup.
Called when we are finished with the alias analyzer. */
void (*cleanup) (struct tree_alias_ops *);
/* Add variable.
Called when we want to inform the alias analyzer about a new
variable we've found. */
alias_var (*add_var) (struct tree_alias_ops *, tree);
/* Add variable equivalent to existing one.
Called when we want to inform the alias analyzer about a new
variable that has the same points-to set as an existing
variable. */
alias_var (*add_var_same) (struct tree_alias_ops *, tree,
alias_var);
/* Process a simple assignment (a = b).
Called to process simple assignment statements of the form a = b,
where a and b are both variables. */
void (*simple_assign) (struct tree_alias_ops *, alias_var,
alias_var);
/* Process an address assignment (a = &b).
Called to process address assignment statements of the form a =
&b, where a and b are both variables. */
void (*addr_assign) (struct tree_alias_ops *, alias_var, alias_var);
/* Process a pointer assignment (a = *b).
Called to process pointer assignment statements of the form a =
*b, where a and b are both variables. */
void (*ptr_assign) (struct tree_alias_ops *, alias_var, alias_var);
/* Process an operator assignment (a = op (...))
Called to process operators of the form a = op(...), where a is a
variable. */
void (*op_assign) (struct tree_alias_ops *, alias_var, varray_type,
tree, bitmap);
/* Process a heap assignment (a = alloc (...))
Called to process a heap assignment of the form a = alloc
(...), where a is a variable, and *alloc is a function that
returns new memory. */
void (*heap_assign) (struct tree_alias_ops *, alias_var);
/* Process an assignment to a pointer (*a = b)
Called to process assignment to pointer statements of the form
*a = b, where a and b are both variables. */
void (*assign_ptr) (struct tree_alias_ops *, alias_var, alias_var);
/* Process a function definition.
Called to inform the alias analyzer about a new function
definition. */
void (*function_def) (struct tree_alias_ops *, alias_var,
varray_type, alias_var);
/* Process a function call.
Return 1 if we need to assume conservative side-effects. */
int (*function_call) (struct tree_alias_ops *, alias_var,
alias_var, varray_type, bitmap);
/* Determine if two alias variables may alias. */
bool (*may_alias) (struct tree_alias_ops *, alias_var, alias_var);
/* Determine if two alias variables have the same points-to set. */
bool (*same_points_to_set) (struct tree_alias_ops *, alias_var,
alias_var);
/* Determine if the alias variable has an empty points-to set. */
bool (*empty_points_to_set) (struct tree_alias_ops *, alias_var);
/* Private data. */
void *data;
/* Interprocedural. */
unsigned int ip:1;
/* Can do conservative interprocedural analysis if we save the
* info. */
unsigned int ip_partial:1;
};
extern struct tree_alias_ops *current_alias_ops;
extern void init_alias_vars (void);
extern bool ptr_may_alias_var (tree, tree);
extern bool same_points_to_set (tree, tree);
extern bool empty_points_to_set (tree);
extern const char *alias_get_name (tree);
#endif /* TREE_ALIAS_COMMON */
/* Tree based linear points-to analysis
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@dberlin.org>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, 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; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "ggc.h"
#include "tree-alias-type.h"
alias_var
alias_var_new_with_aterm (tree decl, struct aterm_ *term)
{
alias_var ret = ggc_alloc (sizeof (struct alias_var_aterm));
ALIAS_VAR_KIND (ret) = ATERM_AVAR;
ALIAS_VAR_DECL (ret) = decl;
ALIAS_VAR_ATERM (ret) = term;
return ret;
}
/* Tree based linear points-to analysis
Copyright (C) 2002, 2003 Free Software Foundation, Inc.
Contributed by Daniel Berlin <dberlin@dberlin.org>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, 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; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef TREE_ALIAS_TYPE_H
#define TREE_ALIAS_TYPE_H
#include "varray.h"
union alias_var_def;
struct aterm_;
struct aterm_list_a;
enum alias_var_kind
{
ATERM_AVAR
};
struct alias_var_common GTY (())
{
enum alias_var_kind kind;
unsigned int varnum;
tree decl;
};
struct alias_var_aterm GTY (())
{
struct alias_var_common common;
struct aterm_ * GTY((skip (""))) term;
struct aterm_list_a *GTY ((skip (""))) ptset;
};
union alias_var_def GTY ((desc ("%0.common.kind")))
{
struct alias_var_common GTY ((tag ("-1"))) common;
struct alias_var_aterm GTY ((tag ("ATERM_AVAR"))) aterm;
};
typedef union alias_var_def *alias_var;
#define ALIAS_VAR_KIND(x) ((x)->common.kind)
#define ALIAS_VAR_VARNUM(x) ((x)->common.varnum)
#define ALIAS_VAR_DECL(x) ((x)->common.decl)
#define ALIAS_VAR_ATERM(x) ((x)->aterm.term)
#define ALIAS_VAR_PTSET(x) ((x)->aterm.ptset)
union alias_type_def;
typedef union alias_type_def *alias_type;
alias_var alias_var_new_with_aterm (tree, struct aterm_ *);
#endif /* TREE_ALIAS_TYPE_H */
......@@ -42,7 +42,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-gimple.h"
#include "tree-flow.h"
#include "tree-inline.h"
#include "tree-alias-common.h"
#include "tree-pass.h"
#include "convert.h"
#include "params.h"
......
......@@ -41,7 +41,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-inline.h"
#include "varray.h"
#include "timevar.h"
#include "tree-alias-common.h"
#include "hashtab.h"
#include "tree-dump.h"
#include "tree-pass.h"
......
......@@ -44,7 +44,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-inline.h"
#include "tree-mudflap.h"
#include "tree-pass.h"
#include "tree-alias-common.h"
#include "ggc.h"
#include "cgraph.h"
#include "graph.h"
......@@ -346,7 +345,6 @@ init_tree_optimization_passes (void)
p = &pass_all_optimizations.sub;
NEXT_PASS (pass_referenced_vars);
NEXT_PASS (pass_build_pta);
NEXT_PASS (pass_build_ssa);
NEXT_PASS (pass_may_alias);
NEXT_PASS (pass_rename_ssa_copies);
......@@ -384,7 +382,6 @@ init_tree_optimization_passes (void)
NEXT_PASS (pass_phiopt);
NEXT_PASS (pass_tail_calls);
NEXT_PASS (pass_late_warn_uninitialized);
NEXT_PASS (pass_del_pta);
NEXT_PASS (pass_del_ssa);
NEXT_PASS (pass_nrv);
NEXT_PASS (pass_remove_useless_vars);
......
......@@ -42,7 +42,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-inline.h"
#include "varray.h"
#include "timevar.h"
#include "tree-alias-common.h"
#include "hashtab.h"
#include "tree-dump.h"
#include "tree-ssa-live.h"
......
......@@ -119,8 +119,6 @@ extern struct tree_opt_pass pass_lower_eh;
extern struct tree_opt_pass pass_build_cfg;
extern struct tree_opt_pass pass_tree_profile;
extern struct tree_opt_pass pass_referenced_vars;
extern struct tree_opt_pass pass_build_pta;
extern struct tree_opt_pass pass_del_pta;
extern struct tree_opt_pass pass_sra;
extern struct tree_opt_pass pass_tail_recursion;
extern struct tree_opt_pass pass_tail_calls;
......
......@@ -39,7 +39,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-gimple.h"
#include "tree-flow.h"
#include "tree-inline.h"
#include "tree-alias-common.h"
#include "tree-pass.h"
#include "convert.h"
#include "params.h"
......@@ -125,8 +124,6 @@ struct alias_stats_d
unsigned int simple_resolved;
unsigned int tbaa_queries;
unsigned int tbaa_resolved;
unsigned int pta_queries;
unsigned int pta_resolved;
};
......@@ -354,7 +351,7 @@ struct tree_opt_pass pass_may_alias =
NULL, /* next */
0, /* static_pass_number */
TV_TREE_MAY_ALIAS, /* tv_id */
PROP_cfg | PROP_ssa | PROP_pta, /* properties_required */
PROP_cfg | PROP_ssa, /* properties_required */
PROP_alias, /* properties_provided */
0, /* properties_destroyed */
0, /* todo_flags_start */
......@@ -1618,18 +1615,6 @@ may_alias_p (tree ptr, HOST_WIDE_INT mem_alias_set,
}
}
if (flag_tree_points_to != PTA_NONE)
alias_stats.pta_queries++;
/* If -ftree-points-to is given, check if PTR may point to VAR. */
if (flag_tree_points_to == PTA_ANDERSEN
&& !ptr_may_alias_var (ptr, var))
{
alias_stats.alias_noalias++;
alias_stats.pta_resolved++;
return false;
}
alias_stats.alias_mayalias++;
return true;
}
......@@ -2119,9 +2104,7 @@ get_tmt_for (tree ptr, struct alias_info *ai)
for (i = 0, tag = NULL_TREE; i < ai->num_pointers; i++)
{
struct alias_map_d *curr = ai->pointers[i];
if (tag_set == curr->set
&& (flag_tree_points_to == PTA_NONE
|| same_points_to_set (curr->var, ptr)))
if (tag_set == curr->set)
{
tag = var_ann (curr->var)->type_mem_tag;
break;
......@@ -2203,10 +2186,6 @@ dump_alias_stats (FILE *file)
alias_stats.tbaa_queries);
fprintf (file, "Total TBAA resolved:\t%u\n",
alias_stats.tbaa_resolved);
fprintf (file, "Total PTA queries:\t%u\n",
alias_stats.pta_queries);
fprintf (file, "Total PTA resolved:\t%u\n",
alias_stats.pta_resolved);
}
......
......@@ -33,7 +33,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-gimple.h"
#include "tree-inline.h"
#include "timevar.h"
#include "tree-alias-common.h"
#include "hashtab.h"
#include "tree-dump.h"
#include "tree-ssa-live.h"
......
......@@ -34,7 +34,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-inline.h"
#include "varray.h"
#include "timevar.h"
#include "tree-alias-common.h"
#include "hashtab.h"
#include "tree-dump.h"
#include "tree-ssa-live.h"
......
......@@ -41,7 +41,6 @@ Boston, MA 02111-1307, USA. */
#include "tree-inline.h"
#include "varray.h"
#include "timevar.h"
#include "tree-alias-common.h"
#include "hashtab.h"
#include "tree-dump.h"
#include "tree-pass.h"
......
Copyright (c) 2000-2001
The Regents of the University of California. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
2004-06-27 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR bootstrap/15627
* engine/flowrow-sort.c (update_upper_bound): Converted comment to
C-style.
(flowrow_inclusion): Likewise.
(flowrow_extract_field): Unnest field_eq.
* engine/setif-sort.c (search_ubs): Unnest search_ubs_aux.
(search_lbs): Unnest search_lbs_aux.
(setif_inclusion): Unnest collapse_cycle_lower, collapse_cycle_upper,
update_lower_bound, update_upper_bound.
2004-06-15 Paolo Bonzini <bonzini@gnu.org>
* Makefile.in: Regenerate with automake 1.8.5.
* aclocal.m4: Likewise.
* engine/Makefile.in: Likewise.
* libcompat/Makefile.in: Likewise.
* points-to/Makefile.in: Likewise.
* configure: Regenerate.
* .cvsignore: New file.
2004-05-28 Kelley Cook <kcook@gcc.gnu.org>
* configure.in: Rename to ...
* configure.ac: this. Update to modern autoconf style.
Correct AC_INIT macro with the actual package name.
Replace gcc_AC_HEADER_STDBOOL and GCC_AC_C__BOOL with AC_HEADER_STDBOOL.
* acinclude.m4, stamp.h-in: Delete.
* config.h, configure: Regenerate with autoconf 2.59.
* aclocal.m4, Makefile.in: Regenerate with automake 1.7.9.
* engine/Makefile.in: Likewise.
* libcompat/Makefile.in: Likewise.
* points-to/Makefile.in: Likewise.
2004-05-24 Daniel Berlin <dberlin@dberlin.org>
PR other/15627
* engine/util.h: Include ansidecl.h.
Make max and min static inline.
* engine/util.c: Remove max and min from here.
2004-03-26 Andreas Jaeger <aj@suse.de>
* configure.in: Remove GCC_NO_EXECUTABLES.
* configure: Regenerated.
2004-03-07 Daniel Berlin <dberlin@dberlin.org>
* engine/Makefile.am (AM_CFLAGS): Add -I$(top_srcddir)/../include, so we
can get ansidecl.h and friends.
* engine/array.c (array_extend): Fix unsigned/signed comparison.
* engine/banshee.h (struct gen_e): Just make void * when empty, instead
of empty struct.
* engine/compiler.h: Don't ever define HAVE_VARIADIC_MACROS, -pedantic
whines about them even when we know we can use them.
* engine/dot.c: constify our char *'s everywhere.
(declare_node): Cast &result to char * before casting to hash_data *.
* engine/dot.h: constify our char *'s everywhere.
* engine/flow-var.c: Ditto.
* engine/flow-var.h: Ditto.
* engine/flowrow-sort.c: Include ansidecl.h.
(get_contour): Mark unused parameter.
(update_upper_bound): Make comment /* instead of //.
(field_eq): Staticify.
* engine/hash.c (string_hash): Staticify.
(string_eq): Ditto.
(entry_cmp): Ditto.
* engine/hash.h: Move comments around.
(hash_table_apply): Add prototype.
* engine/hashset.c (INIT_TABLE_SIZE): Remove extra semicolon.
(EMPTY_KEY): Ditto.
* engine/jcollection.c (jcoll_create_chain): // -> /* comment.
(jcoll_accum): Staticify.
* engine/list.c (sort_linked_list): Staticify.
(compare): Use comparator_fn as last argument, not void *.
* engine/list.h: Declare the functions even for opaque lists.
(list_clear macro): don't return value.
* engine/setif-sort.c: Replaced with new version from banshee cvs.
* engine/setif-var.c: constify our char *'s.
* engine/setif-var.h: Ditto.
* engine/setst-var.c: Ditto.
* engine/setst-var.h: Ditto.
* engine/stamp.c (stamp_string): Use long, not int.
Cast through char *.
* engine/stamp.h (stamp): Long, not int.
* engine/term-sort.c (term_print_stats): Mark argument unused.
include ansidecl.h.
* engine/term-var.c: constify the char *'s.
* engine/term-var.h: Ditto.
* engine/ufind.h (union find update macro): Don't return uf_update's value
(which is void anyway).
* engine/util.c (ptr_hash): Return long, not int.
* engine/util.h (ptr_hash): Ditto.
2004-02-29 Andreas Jaeger <aj@suse.de>
* configure.in: Set ac_libbanshee_warn_cflags for GCC.
* configure: Regenerated.
* libcompat/Makefile.am (AM_CFLAGS): Add
ac_libbanshee_warn_cflags.
* engine/Makefile.am (AM_CFLAGS): Likewise.
* points-to/Makefile.am (AM_CFLAGS): Likewise.
* libcompat/Makefile.in: Regenerated.
* engine/Makefile.in: Regenerated.
* points-to/Makefile.in: Regenerated.
* Makefile.in: Regenerated.
* libcompat/radix-tree.c: Include <stdlib.h> for calloc.
2004-02-03 Daniel Berlin <dberlin@dberlin.org>
Fix PR other/12220
* engine/Makefile.am: Remove -fno-strict-aliasing.
* libcompat/Makefile.am: Ditto.
* points-to/Makefile.am: Ditto.
* configure: Regenerated.
* config.h.in: Ditto.
* Makefile.in: Ditto.
* engine/Makefile.am: Ditto.
* libcompat/Makefile.am: Ditto.
* points-to/Makefile.am: Ditto.
2003-07-01 Daniel Berlin <dberlin@dberlin.org>
* acinclude.m4: New, copy the bool tests from gcc.
* configure.in: Use the new bool tests.
* Regenerate configure.
* engine/bool.h: Rewrite to use the part of gcc's system.h that does
bool type handling.
2002-12-26 Daniel Berlin <dberlin@dberlin.org>
* Makefile.am: Use the same flag passing hack all other subdirs use.
* */Makefile.am: Use -fno-strict-aliasing till i get rid of the
type-punning.
* Regenerate configure and Makefiles.
* engine/setst-*.c: Remove nested functions.
2002-11-28 Diego Novillo <dnovillo@redhat.com>
* aclocal.m4: Don't call aclocal and automake with a
version number suffix.
* Makefile.in, config.h.in, configure,
engine/Makefile.in, libcompat/Makefile.in,
points-to/Makefile.in: Regenerate.
2002-11-24 Daniel Berlin <dberlin@dberlin.org>
* points-to/andersen_terms.c: Fix multi-line string literals
2002-10-31 Daniel Berlin <dberlin@dberlin.org>
* Autoconf'ed, automak'ed, de-nested functified, etc.
SUBDIRS = engine points-to libcompat
# Work around what appears to be a GNU make bug handling MAKEFLAGS
# values defined in terms of make variables, as is the case for CC and
# friends when we are called from the top level Makefile.
AM_MAKEFLAGS = \
"AR_FLAGS=$(AR_FLAGS)" \
"CC_FOR_BUILD=$(CC_FOR_BUILD)" \
"CFLAGS=$(CFLAGS)" \
"CXXFLAGS=$(CXXFLAGS)" \
"CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
"CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
"INSTALL=$(INSTALL)" \
"INSTALL_DATA=$(INSTALL_DATA)" \
"INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
"INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
"LDFLAGS=$(LDFLAGS)" \
"LIBCFLAGS=$(LIBCFLAGS)" \
"LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
"MAKE=$(MAKE)" \
"MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
"PICFLAG=$(PICFLAG)" \
"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
"SHELL=$(SHELL)" \
"EXPECT=$(EXPECT)" \
"RUNTEST=$(RUNTEST)" \
"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
"exec_prefix=$(exec_prefix)" \
"infodir=$(infodir)" \
"libdir=$(libdir)" \
"prefix=$(prefix)" \
"tooldir=$(tooldir)" \
"AR=$(AR)" \
"AS=$(AS)" \
"CC=$(CC)" \
"CXX=$(CXX)" \
"LD=$(LD)" \
"LIBCFLAGS=$(LIBCFLAGS)" \
"NM=$(NM)" \
"PICFLAG=$(PICFLAG)" \
"RANLIB=$(RANLIB)" \
"DESTDIR=$(DESTDIR)"
This is banshee, a toolkit for constructing constraint-based program analyses.
See the user manual in docs/banshee.ps for a complete description of banshee.
This is a beta release of banshee. Although banshee has been designed to solve
many kinds of constraints, it has only been extensively tested on
Andersen's-style points-to analysis.
banshee is distributed under the BSD license. See the COPYRIGHT file for more
details.
Send bug reports to jkodumal@cs.berkeley.edu.
\ No newline at end of file
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
#undef HAVE_DOPRNT
/* Define to 1 if you have the `dup2' function. */
#undef HAVE_DUP2
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the `floor' function. */
#undef HAVE_FLOOR
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the `munmap' function. */
#undef HAVE_MUNMAP
/* Define to 1 if stdbool.h conforms to C99. */
#undef HAVE_STDBOOL_H
/* Define to 1 if you have the <stddef.h> header file. */
#undef HAVE_STDDEF_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/param.h> header file. */
#undef HAVE_SYS_PARAM_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the `vprintf' function. */
#undef HAVE_VPRINTF
/* Define to 1 if the system has the type `_Bool'. */
#undef HAVE__BOOL
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
This source diff could not be displayed because it is too large. You can view the blob instead.
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(libbanshee,0.9,dberlin@dberlin.org)
AC_CONFIG_SRCDIR(engine/flowrow-sort.c)
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE
# Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_RANLIB
# Checks for libraries.
# FIXME: Replace `main' with a function in `-llambda':
#AC_CHECK_LIB([lambda], [main])
# FIXME: Replace `main' with a function in `-lm':
#AC_CHECK_LIB([m], [main])
if test x$GCC = xyes; then
ac_libbanshee_warn_cflags='-W -Wall -pedantic -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes'
fi
AC_SUBST(ac_libbanshee_warn_cflags)
AM_MAINTAINER_MODE
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h limits.h stddef.h stdlib.h string.h sys/param.h unistd.h])
AC_HEADER_STDBOOL
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_INLINE
AC_TYPE_PID_T
AC_TYPE_SIZE_T
# Checks for library functions.
AC_FUNC_MEMCMP
AC_FUNC_MMAP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([atexit dup2 floor getpagesize memset munmap])
AC_CONFIG_FILES([Makefile
engine/Makefile
libcompat/Makefile
points-to/Makefile])
AC_OUTPUT
2004-05-28 Aaron W. LaFramboise <aaronraolete36@aaronwl.com>
* engine/util.c (vfail): Remove unnecessary sync, fsync, and fflush.
2003-07-01 Daniel Berlin <dberlin@dberlin.org>
* bool.h: Can't include gcc's system.h and bool.h at the same time.
2003-06-25 Daniel Berlin <dberlin@dberlin.org>
* compiler.h: Fix the grouping of the #if
2003-02-02 Daniel Berlin <dberlin@dberlin.org>
* compiler.h: Only define HAVE_VARIADIC_MACROS if IN_GCC is not
defined.
* util.h: Add prototypes for min and max.
AM_CFLAGS = -I$(srcdir)/../libcompat -I$(top_srcdir)/../include -I$(srcdir)/../include -I. -Ddeletes= -Dtraditional= -Dsameregion= -Dparentptr= @ac_libbanshee_warn_cflags@
noinst_LIBRARIES = libbansheeengine.a
libbansheeengine_a_SOURCES = array.c bounds.c hash.c hashset.c list.c stamp.c \
ufind.c util.c setif-sort.c termhash.c setif-var.c flow-var.c flowrow-sort.c \
setst-var.c jcollection.c banshee.c buffer.c setst-sort.c term-var.c \
term-sort.c dot.c
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <regions.h>
#include <assert.h>
#include <limits.h>
#include "array.h"
struct array {
region sameregion r;
void *sameregion data;
size_t elemsize;
type_t elemtype;
size_t nelems, nalloc;
};
struct array *new_array(region r, size_t initialsize,
size_t typesize, type_t typeinfo)
{
struct array *a = ralloc(r, struct array);
a->r = r;
a->data = typed_rarrayalloc(r, initialsize, typesize, typeinfo);
a->elemsize = typesize;
a->elemtype = typeinfo;
a->nelems = 0;
a->nalloc = initialsize;
return a;
}
void *array_extend(struct array *a, int by)
{
size_t oldelems = a->nelems;
if (by < 0)
assert(((unsigned int)-by) <= a->nelems && by != INT_MIN);
else if (a->nelems + by > a->nalloc)
{
size_t newsize = a->nalloc * 2 + by;
void *newdata = typed_rarrayalloc(a->r, newsize, a->elemsize, a->elemtype);
/* XXX: could work harder to support really large array sizes
(this code will fail for a->nalloc >= (max(size_t)-by)/2) */
assert(newsize > a->nalloc); /* die when we get really big */
typed_rarraycopy(newdata, a->data, a->nelems, a->elemsize, a->elemtype);
a->data = newdata;
a->nalloc = newsize;
}
a->nelems += by;
return (char *)a->data + a->elemsize * oldelems;
}
void array_reset(struct array *a)
{
a->nelems = 0;
}
size_t array_length(struct array *a)
{
return a->nelems;
}
void *array_data(struct array *a)
{
return a->data;
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef ARRAY_H
#define ARRAY_H
/* A region-based growable array type */
struct array;
struct array *new_array(region r, size_t initialsize,
size_t typesize, type_t typeinfo);
void *array_extend(struct array *a, int by);
void array_reset(struct array *a);
size_t array_length(struct array *a);
void *array_data(struct array *a);
#define DECLARE_ARRAY(name, type) \
typedef struct name ## _a *name; \
name new_ ## name(region r, size_t initialsize); \
type *name ## _extend(name a, int by); \
void name ## _reset(name a); \
size_t name ## _length(name a); \
type *name ## _data(name a);
#define DEFINE_ARRAY(name, type) \
name new_ ## name(region r, size_t initialsize) \
{ \
return (name)new_array(r, initialsize, sizeof(type), rctypeof(type)); \
} \
type *name ## _extend(name a, int by) \
{ \
return array_extend((struct array *)a, by); \
} \
void name ## _reset(name a) \
{ \
return array_reset((struct array *)a); \
} \
size_t name ## _length(name a) \
{ \
return array_length((struct array *)a); \
} \
type *name ## _data(name a) \
{ \
return array_data((struct array *)a); \
}
#endif
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <regions.h>
#include "banshee.h"
#include "setif-sort.h"
#include "setst-sort.h"
#include "flowrow-sort.h"
#include "setif-var.h"
DEFINE_LIST(gen_e_list,gen_e)
void engine_init(void)
{
region_init();
stamp_init();
}
void engine_reset(void) deletes
{
stamp_reset();
}
/* TODO */
void engine_update(void)
{
}
void engine_stats(FILE *f)
{
setif_print_stats(f);
setst_print_stats(f);
flowrow_print_stats(f);
}
void print_constraint_graphs(FILE *f)
{
setif_print_constraint_graph(f);
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef BANSHEE_H
#define BANSHEE_H
#include <stdio.h>
#include "linkage.h"
#include "stamp.h"
#include "list.h"
#include "util.h"
#include "dot.h"
#define ALIAS_TYPE -2
#define VAR_TYPE -1
#define ZERO_TYPE 0
#define ONE_TYPE 1
#define UNION_TYPE 2
#define INTER_TYPE 3
#define CONSTANT_TYPE 4
EXTERN_C_BEGIN
#ifdef NONSPEC
typedef enum sort_kind
{
flowrow_sort,
setif_sort,
setst_sort,
flowterm_sort,
term_sort
} sort_kind;
typedef struct gen_e
{
sort_kind sort;
} *gen_e;
#else
typedef void *gen_e;
#endif
DECLARE_LIST(gen_e_list,gen_e)
typedef void (*gen_e_pr_fn_ptr) (FILE *, gen_e);
/*
Function pointers that are common to all sorts
*/
/* inclusion */
typedef void (*incl_fn_ptr) (gen_e, gen_e) deletes;
/* match constructed terms */
typedef void (*con_match_fn_ptr) (gen_e, gen_e) deletes;
/* make fresh variables */
typedef gen_e (*fresh_fn_ptr) (const char *);
typedef gen_e (*fresh_small_fn_ptr) (const char *);
typedef gen_e (*fresh_large_fn_ptr) (const char *);
/* get a stamp */
typedef stamp (*get_stamp_fn_ptr) (gen_e);
/* extract a term from a proj pat */
typedef gen_e (*get_proj_fn_ptr) (gen_e_list);
void engine_init(void);
void engine_reset(void) deletes;
void engine_update(void);
void engine_stats(FILE *f);
void print_constraint_graphs(FILE *f);
EXTERN_C_END
#endif /* BANSHEE_H */
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef BOOL_H
#define BOOL_H
#ifndef GCC_SYSTEM_H
#include "config.h"
/* 1 if we have _Bool. */
#ifndef HAVE__BOOL
# define HAVE__BOOL \
((GCC_VERSION >= 3000) || (__STDC_VERSION__ >= 199901L))
#endif
/* Provide some sort of boolean type. We use stdbool.h if it's
available. This must be after all inclusion of system headers,
as some of them will mess us up. */
#undef bool
#undef true
#undef false
#undef TRUE
#undef FALSE
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#else
# if !HAVE__BOOL
typedef char _Bool;
# endif
# define bool _Bool
# define true 1
# define false 0
#endif
#define TRUE true
#define FALSE false
#endif
#endif
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdlib.h>
#include <assert.h>
#include "bounds.h"
struct bounds
{
hash_set set;
gen_e_list elems;
};
bounds bounds_create(region r)
{
bounds result;
result = ralloc(r, struct bounds);
result->set = hs_create(r);
result->elems = new_gen_e_list(r);
return result;
}
gen_e_list bounds_exprs(bounds b)
{
return b->elems;
}
bool bounds_add(bounds b, gen_e e, stamp s)
{
if (hs_member(b->set, s))
return TRUE;
else
{
gen_e_list_cons(e,b->elems);
return FALSE;
}
}
bool bounds_empty(bounds b)
{
return (gen_e_list_empty(b->elems));
}
bool bounds_query(bounds b, stamp x)
{
return (hs_query(b->set, x));
}
void bounds_set(bounds b,gen_e_list l)
{
b->elems = l;
}
void bounds_delete(bounds b)
{
hs_delete(b->set);
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef BOUNDS_H
#define BOUNDS_H
#include "linkage.h"
#include "banshee.h"
#include "stamp.h"
#include "hashset.h"
EXTERN_C_BEGIN
typedef struct bounds *bounds;
bounds bounds_create(region r);
gen_e_list bounds_exprs(bounds);
/* returns true if the bound was already present */
bool bounds_add(bounds,gen_e,stamp);
bool bounds_query(bounds,stamp);
bool bounds_empty(bounds);
void bounds_delete(bounds);
void bounds_set(bounds,gen_e_list);
EXTERN_C_END
#endif /* BOUNDS_H */
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "buffer.h"
/* Invariant: buffer always null-terminated */
struct growbuf
{
region r;
unsigned int maxsize, cursize;
char *buffer;
};
/* Make a new buffer with initial size */
growbuf growbuf_new(region r, int size)
{
growbuf b = ralloc(r, struct growbuf);
assert(size > 0);
b->r = r;
b->maxsize = size; /* Force some growth! */
b->cursize = 1;
b->buffer = rstralloc(r, size);
b->buffer[0] = '\0';
return b;
}
/* Empty a buffer */
void growbuf_reset(growbuf b)
{
assert(b->maxsize > 0);
b->cursize = 1;
b->buffer[0] = '\0';
}
/* Print to a buffer */
int gprintf(growbuf b, const char *fmt, ...)
{
va_list args;
va_start(args, fmt);
return gvprintf(b, fmt, args);
}
/* Print to a buffer */
int gvprintf(growbuf b, const char *fmt, va_list args)
{
int nchars;
if (!fmt) /* Bug (?)/feature of vnsprintf -- printing \0 returns -1,
goes into infinite loop. */
return 0;
while (1)
{
char *bufStart;
int sizeLeft;
bufStart = b->buffer + b->cursize - 1; /* chop trailing \0 */
sizeLeft = b->maxsize - b->cursize + 1; /* +1 size we're chooping
the trailing \0 */
assert(*bufStart == '\0');
nchars = vsnprintf(bufStart, sizeLeft, fmt, args);
if (nchars > -1 && nchars < sizeLeft)
{
b->cursize += nchars; /* nchars doesn't include \0,
but we overwrote our \0 */
break;
}
else
{
/* How much room do we need? In the new glibc, nchars
tells us how much (not including the trailing null).
So we need the current size, -1 since we'll remove the null,
plus the new size, plus 1 for the new null. */
int newSize = (nchars > -1) ? b->cursize - 1 + nchars + 1
: b->maxsize * 2;
char *newBuf;
/* fprintf(stderr, "Reallocating buffer, newSize=%d\n", newSize); */
newBuf = rstralloc(b->r, newSize);
memcpy(newBuf, b->buffer, b->cursize);
newBuf[b->cursize-1] = '\0'; /* vsnprintf has printed something! */
b->buffer = newBuf;
b->maxsize = newSize;
/* b->cursize unchanged */
}
}
return nchars;
}
/* Get the contents of a buffer */
char *growbuf_contents(growbuf b)
{
return b->buffer;
}
bool growbuf_empty(growbuf b)
{
return b->cursize == 1; /* Buffer always null terminated */
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef BUFFER_H
#define BUFFER_H
/*
* Growable buffers
*
* Always null terminated.
*/
#include <stdarg.h>
#include "bool.h"
#include "regions.h"
#include "linkage.h"
EXTERN_C_BEGIN
typedef struct growbuf *growbuf;
growbuf growbuf_new(region, int); /* Make a new buffer with initial size */
void growbuf_reset(growbuf); /* Empty a buffer */
int gprintf(growbuf, const char *, ...); /* Print to a buffer */
int gvprintf(growbuf, const char *, va_list); /* Print to a buffer */
char *growbuf_contents(growbuf); /* Get the contents of a buffer */
bool growbuf_empty(growbuf); /* Return true iff buffer is empty */
EXTERN_C_END
#endif
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef COMPILER_H
#define COMPILER_H
# if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
# define HAVE_C99
# endif
# if 0
/*(defined(__GNUC__) || defined(HAVE_C99)) && !defined (IN_GCC) */
# define HAVE_VARIADIC_MACROS
# endif
# if !defined(__GNUC__) && !defined(__attribute__)
# define __attribute__(attributes)
# endif
#endif /* !COMPILER_H */
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <assert.h>
#include <regions.h>
#include "dot.h"
#include "hash.h"
static FILE *of;
static hash_table node_hash_table;
static region dot_region;
static int node_count;
static const char *edge_op;
static void print_n_attrs(node_attr *attrs, int n)
{
int i;
fputc('[',of);
for (i = 0; i < n; i++)
{
const char *name;
switch (attrs[i].name)
{
case n_color:
name = "color";
break;
case n_fontcolor:
name = "fontcolor";
break;
case n_fontname:
name = "fontname";
break;
case n_fontsize:
name = "fontsize";
break;
case n_height:
name = "height";
break;
case n_width:
name = "width";
break;
case n_label:
name = "label";
break;
case n_layer:
name = "layer";
break;
case n_shape:
name = "shape";
break;
case n_shapefile:
name = "shapefile";
break;
case n_style:
name = "style";
break;
default:
name = "";
assert(0);
break;
}
if (i > 0)
fputc(',',of);
fprintf(of,"%s = %s",name,attrs[i].value);
}
fputc(']',of);
}
static void print_e_attrs(edge_attr *attrs, int n)
{
int i;
fputc('[',of);
for (i = 0; i < n; i++)
{
const char *name;
switch(attrs[i].name)
{
case e_color:
name = "color";
break;
case e_decorate:
name = "decorate";
break;
case e_dir:
name = "dir";
break;
case e_fontcolor:
name = "fontcolor";
break;
case e_fontname:
name = "fontname";
break;
case e_fontsize:
name = "fontsize";
break;
case e_id:
name = "id";
break;
case e_label:
name = "label";
break;
case e_layer:
name = "layer";
break;
case e_minlen:
name = "minlen";
break;
case e_style:
name = "style";
break;
case e_weight:
name = "weight";
break;
default :
name = "";
assert(0);
break;
}
if (i > 0)
fputc(',',of);
fprintf(of,"%s = %s",name,attrs[i].value);
}
fputc(']',of);
}
static void print_g_attrs(graph_attr *attrs, int n)
{
int i;
fputc('[',of);
for (i = 0; i < n; i++)
{
const char *name;
switch (attrs[i].name)
{
case g_center:
name = "center";
break;
case g_clusterrank:
name = "clusterrank";
break;
case g_color:
name = "color";
break;
case g_concentrate:
name = "concentrate";
break;
case g_fontcolor:
name = "fontcolor";
break;
case g_fontname:
name = "fontname";
break;
case g_fontsize:
name = "fontsize";
break;
case g_label:
name = "label";
break;
case g_layerseq:
name = "layerseq";
break;
case g_margin:
name = "margin";
break;
case g_mclimit:
name = "mclimit";
break;
case g_nodesep:
name = "nodesep";
break;
case g_nslimit:
name = "nslimit";
break;
case g_ordering:
name = "ordering";
break;
case g_orientation:
name = "orientation";
break;
case g_page:
name = "page";
break;
case g_rank:
name = "rank";
break;
case g_rankdir:
name = "rankdir";
break;
case g_ranksep:
name = "ranksep";
break;
case g_ratio:
name = "ratio";
break;
case g_size:
name = "size";
break;
default :
name = "";
assert(0);
break;
}
if (i > 0)
fputc(',',of);
fprintf(of,"%s = %s",name,attrs[i].value);
}
fputc(']',of);
}
void dot_start(FILE *to,const char *name,bool is_directed,bool is_strict)
{
const char *graph_type,*strict;
node_count = 0;
dot_region = newregion();
node_hash_table = make_string_hash_table(dot_region,8,TRUE);
of = to;
if (is_directed)
{
edge_op = "->";
graph_type = "digraph";
}
else
{
edge_op = "--";
graph_type = "graph";
}
if (is_strict)
strict = "strict";
else
strict = "";
fprintf(of,"%s %s %s{\n",strict,graph_type,name);
}
void dot_global_graph_style(graph_attr *attrs, int n)
{
fputs("graph ",of);
print_g_attrs(attrs,n);
fputc(';',of);
fputc('\n',of);
}
void dot_global_edge_style(edge_attr *attrs, int n)
{
fputs("edge ",of);
print_e_attrs(attrs,n);
fputc(';',of);
fputc('\n',of);
}
void dot_global_node_style(node_attr *attrs, int n)
{
fputs("node ",of);
print_n_attrs(attrs,n);
fputc(';',of);
fputc('\n',of);
}
/* by default, set the node's name to label */
static void declare_node(dot_node n, char *label)
{
int i;
char mangled[512];
if (label[0] == '\"')
mangled[0] = 's';
else
mangled[0] = label[0];
for (i = 1; label[i] && i < 512 ;i++)
{
if (label[i] == '\"')
mangled[i] = '_';
else mangled[i] = label[i];
}
mangled[i] = '\0';
fprintf(of,"nd_%d [label=\"%s\"]\n",n,mangled);
}
dot_node dot_get_node(char *label) deletes
{
dot_node result;
if (!hash_table_lookup(node_hash_table,(hash_key)label,(hash_data *)(char *)&result))
{
dot_node newnode = node_count++;
declare_node(newnode,label);
hash_table_insert(node_hash_table,
(hash_key)rstrdup(dot_region,label),
(hash_data)newnode);
return newnode;
}
else
return result;
}
void dot_node_style(dot_node node,node_attr *attrs, int n)
{
fprintf(of,"nd_%d ",node);
print_n_attrs(attrs,n);
fputc(';',of);
fputc('\n',of);
}
void dot_plain_edge(dot_node from, dot_node to)
{
fprintf(of,"nd_%d %s nd_%d;\n",from,edge_op,to);
}
void dot_styled_edge(dot_node from, dot_node to, edge_attr *attrs, int n)
{
fprintf(of,"nd_%d %s nd_%d ",from,edge_op,to);
print_e_attrs(attrs,n);
fputc(';',of);
fputc('\n',of);
}
void dot_end(void) deletes
{
fputc('}',of);
hash_table_delete(node_hash_table);
deleteregion_ptr(&dot_region);
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef DOT_H
#define DOT_H
#include <stdio.h>
#include "linkage.h"
#include "bool.h"
EXTERN_C_BEGIN
typedef int dot_node;
typedef struct
{
enum n_attrs
{
n_color,
n_fontcolor,
n_fontname,
n_fontsize,
n_height,
n_width,
n_label,
n_layer,
n_shape,
n_shapefile,
n_style
} name;
const char *value;
} node_attr;
typedef struct
{
enum e_attrs
{
e_color,
e_decorate,
e_dir,
e_fontcolor,
e_fontname,
e_fontsize,
e_id,
e_label,
e_layer,
e_minlen,
e_style,
e_weight
} name;
const char *value;
} edge_attr;
typedef struct
{
enum g_attrs
{
g_center,
g_clusterrank,
g_color,
g_concentrate,
g_fontcolor,
g_fontname,
g_fontsize,
g_label,
g_layerseq,
g_margin,
g_mclimit,
g_nodesep,
g_nslimit,
g_ordering,
g_orientation,
g_page,
g_rank,
g_rankdir,
g_ranksep,
g_ratio,
g_size
} name;
const char *value;
} graph_attr;
void dot_start(FILE *to,const char *name,bool directed,bool strict);
void dot_global_graph_style(graph_attr *attrs,int n);
void dot_global_edge_style(edge_attr *attrs,int n);
void dot_global_node_style(node_attr *attrs,int n);
dot_node dot_get_node(char *label) deletes;
void dot_node_style(dot_node node,node_attr *attrs,int n);
void dot_plain_edge(dot_node from, dot_node to);
void dot_styled_edge(dot_node from, dot_node to, edge_attr *attrs,int n);
void dot_end(void) deletes;
EXTERN_C_END
#endif /* DOT_H */
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <assert.h>
#include "banshee.h"
#include "flow-var.h"
#include "ufind.h"
#include "bounds.h"
DECLARE_UFIND(contour_elt,contour)
struct flow_var /* extends gen_e */
{
#ifdef NONSPEC
sort_kind sort;
#endif
int type; /* alias or var */
stamp st;
gen_e alias;
bounds sameregion ubs;
bounds sameregion lbs;
contour_elt elt;
const char *name;
};
DEFINE_UFIND(contour_elt,contour)
DEFINE_LIST(flow_var_list, flow_var)
#define get_contour(x) (contour_elt_get_info((x)->elt))
static flow_var make_var(region r, const char *name, stamp st)
{
flow_var result = ralloc(r,struct flow_var);
result->type = VAR_TYPE;
result->st = st;
result->alias = NULL;
result->ubs = bounds_create(r);
result->lbs = bounds_create(r);
result->elt = new_contour_elt(r,NULL);
result->name = name;
#ifdef NONSPEC
result->sort = flow_sort;
#endif
return result;
}
flow_var fv_fresh(region r, const char *name)
{
return make_var(r,name,stamp_fresh());
}
flow_var fv_fresh_large(region r, const char *name)
{
return make_var(r,name,stamp_fresh_large());
}
flow_var fv_fresh_small(region r, const char *name)
{
return make_var(r,name,stamp_fresh_small());
}
const char * fv_get_name(flow_var v)
{
return v->name;
}
gen_e_list fv_get_lbs(flow_var v)
{
return bounds_exprs(v->lbs);
}
gen_e_list fv_get_ubs(flow_var v)
{
return bounds_exprs(v->ubs);
}
bool fv_add_ub(flow_var v, gen_e e, stamp st)
{
return bounds_add(v->ubs,e,st);
}
bool fv_add_lb(flow_var v, gen_e e, stamp st)
{
return bounds_add(v->lbs,e,st);
}
bool fv_is_ub(flow_var v, stamp st)
{
bool self_edge = v->st == st,
in_bounds = bounds_query(v->ubs,st);
return (self_edge || in_bounds);
}
bool fv_is_lb(flow_var v, stamp st)
{
bool self_edge = v->st == st,
in_bounds = bounds_query(v->lbs,st);
return (self_edge || in_bounds);
}
void fv_set_alias(flow_var v, gen_e e)
{
assert(v->type == VAR_TYPE);
v->type = ALIAS_TYPE;
v->alias = e;
}
gen_e fv_get_alias(flow_var v)
{
return v->alias;
}
bool fv_has_contour(flow_var v)
{
return (get_contour(v) != NULL);
}
void fv_set_contour(flow_var v, contour c)
{
contour_elt_update(v->elt,c);
}
static contour combine_contour(contour c1, contour c2)
{
if (c1 == NULL)
return c2;
else if (c2 == NULL)
return c1;
else
{
fail("Attempt to unify two distinct contours\n");
return NULL;
}
}
void fv_unify_contour(flow_var v1, flow_var v2)
{
contour_elt_unify(combine_contour,v1->elt,v2->elt);
}
gen_e fv_instantiate_contour(flow_var v) deletes
{
contour c = get_contour(v);
return c->instantiate(c->fresh,c->get_stamp,c->shape);
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef FLOW_VAR_H
#define FLOW_VAR_H
#include "linkage.h"
#include "banshee.h"
#include "jcollection.h"
EXTERN_C_BEGIN
typedef struct flow_var *flow_var;
typedef gen_e (*contour_inst_fn_ptr) (fresh_fn_ptr,get_stamp_fn_ptr,gen_e) deletes;
struct contour
{
gen_e shape;
fresh_fn_ptr fresh;
get_stamp_fn_ptr get_stamp;
contour_inst_fn_ptr instantiate;
};
typedef struct contour *contour;
DECLARE_LIST(flow_var_list, flow_var)
flow_var fv_fresh(region r, const char *name);
flow_var fv_fresh_large(region r, const char *name);
flow_var fv_fresh_small(region r, const char *name);
const char * fv_get_name(flow_var v);
gen_e_list fv_get_lbs(flow_var v);
gen_e_list fv_get_ubs(flow_var v);
bool fv_add_ub(flow_var v, gen_e e, stamp st);
bool fv_add_lb(flow_var v, gen_e e, stamp st);
bool fv_is_ub(flow_var v, stamp st);
bool fv_is_lb(flow_var v, stamp st);
void fv_set_alias(flow_var v, gen_e e);
gen_e fv_get_alias(flow_var v);
void fv_set_contour(flow_var v, contour c);
bool fv_has_contour(flow_var v);
void fv_unify_contour(flow_var v1, flow_var v2);
gen_e fv_instantiate_contour(flow_var v) deletes;
EXTERN_C_END
#endif /* FLOW_VAR_H */
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef FLOWROW_SORT_H
#define FLOWROW_SORT_H
#include "stdio.h"
#include "banshee.h"
#include "termhash.h"
#include "flow-var.h"
struct flowrow_field
{
char *label;
gen_e expr;
};
typedef struct flowrow_field *flowrow_field;
DECLARE_LIST(flowrow_map,flowrow_field)
extern region flowrow_region;
void flowrow_inclusion(fresh_fn_ptr fresh, get_stamp_fn_ptr get_stamp,
incl_fn_ptr field_incl,gen_e zero_elem, gen_e e1,
gen_e e2) deletes;
gen_e flowrow_row(get_stamp_fn_ptr get_stamp,flowrow_map fields, gen_e rest) deletes;
gen_e flowrow_extract_field(const char *name, gen_e e);
gen_e flowrow_extract_rest(gen_e e);
flowrow_map flowrow_extract_fields(gen_e e);
stamp flowrow_get_stamp(gen_e e);
#ifndef NONSPEC
gen_e flowrow_zero(void);
gen_e flowrow_one(void);
gen_e flowrow_abs(void);
gen_e flowrow_wild(void);
gen_e flowrow_fresh(const char *name);
gen_e flowrow_fresh_small(const char *name);
gen_e flowrow_fresh_large(const char *name);
#else
sort_kind flowrow_base_sort(gen_e e);
gen_e flowrow_zero(sort_kind base_sort);
gen_e flowrow_one(sort_kind base_sort);
gen_e flowrow_abs(sort_kind base_sort);
gen_e flowrow_wild(sort_kind base_sort);
gen_e flowrow_fresh(sort_kind base_sort);
gen_e flowrow_fresh_small(sort_kind base_sort);
gen_e flowrow_fresh_large(sort_kind base_sort);
#endif
bool flowrow_is_zero(gen_e e);
bool flowrow_is_one(gen_e e);
bool flowrow_is_abs(gen_e e);
bool flowrow_is_wild(gen_e e);
bool flowrow_is_var(gen_e e);
bool flowrow_is_row(gen_e e);
bool flowrow_is_alias(gen_e e);
void flowrow_init(void);
void flowrow_reset(void) deletes;
typedef void (* field_print_fn_ptr) (FILE *f,gen_e e) deletes;
void flowrow_print(FILE *f,get_stamp_fn_ptr get_stamp,
field_print_fn_ptr field_print,gen_e e) deletes;
void flowrow_print_stats(FILE *f);
extern struct flowrow_stats flowrow_stats;
struct flowrow_stats
{
int fresh;
int fresh_small;
int fresh_large;
int rows_disjoint_wild;
int rows_equal;
int rows_zero_one_wild;
int rows_l_inductive;
int rows_r_inductive;
int rows_disjoint_r1_minimal;
int rows_disjoint_r1_var_r2_minimal;
int rows_disjoint_r1_var_r2_maximal;
int rows_disjoint_r1_var_r2_closed;
int rows_disjoint_r1_var_r2_var_lt;
int rows_disjoint_r1_var_r2_var_gt;
int rows_equal_domains;
int rows_nonempty_intersection;
int rows_fresh;
int rows_fresh_large;
};
#endif /* FLOWROW_H */
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef HASH_H
#define HASH_H
#include <regions.h>
#include "bool.h"
/*#include "hash_info.h"*/ /* Includes hash_key, hash_data typedef */
#include "linkage.h"
EXTERN_C_BEGIN
typedef void *hash_key;
typedef void *hash_data;
/* Function to hash a key */
typedef int (*hash_fn)(hash_key k);
/* Function returning true iff k1 and k2 are equal */
typedef bool (*keyeq_fn)(hash_key k1, hash_key k2);
/* Function applied to elts in the hash table */
typedef void (*hash_apply_fn)(hash_key k, hash_data d, void *arg);
/* Function mapped to elts in the hash table */
typedef hash_data (*hash_map_fn)(hash_key k, hash_data d, void *arg);
typedef struct Hash_table *hash_table;
/* Make a new hash table, with size buckets initially. */
hash_table make_hash_table(region rhash, int size, hash_fn hash,
keyeq_fn cmp, bool internal_rgn);
/* Make a hash table for strings. */
hash_table make_string_hash_table(region rhash, int size, bool internal_rgn);
/* Zero out ht. Doesn't reclaim bucket space. */
void hash_table_reset(hash_table ht) deletes;
/* Delete ht and internal memory associated with it. The top level pointer
must still be deleted. */
void hash_table_delete(hash_table ht) deletes;
/* Return the number of entries in ht */
int hash_table_size(hash_table ht);
/* Lookup k in ht. If d is not NULL, returns corresponding data in *d.
Function result is TRUE if the k was in ht, false otherwise. */
bool hash_table_lookup(hash_table ht, hash_key k, hash_data *d);
/* Add k:d to ht. If k was already in ht, replace old entry by k:d.
Rehash if necessary. Returns TRUE if k was not already in ht. */
bool hash_table_insert(hash_table ht, hash_key k, hash_data d) deletes;
/* Remove mapping for k in ht. Returns TRUE if k was in ht. */
bool hash_table_remove(hash_table ht, hash_key k);
/* Return a copy of ht, allocated in rhash */
hash_table hash_table_copy(region rhash, hash_table ht);
/* Apply f to all elements of ht, in some arbitrary order */
void hash_table_apply(hash_table ht, hash_apply_fn f, void *arg);
/* Map f to all elements on ht, creating a new hash table */
hash_table hash_table_map(hash_table ht, hash_map_fn f, void *arg);
typedef struct bucket *bucket;
typedef struct
{
hash_table ht;
int i;
bucket cur;
} hash_table_scanner; /* Opaque type! Do not modify fields. */
/* Begin scanning ht */
void hash_table_scan(hash_table ht, hash_table_scanner *);
/* Get next elt in table, storing the elt in *k and *d if k and d are
non-NULL, respectively. Returns TRUE if there is a next elt, FALSE
otherwise. */
bool hash_table_next(hash_table_scanner *, hash_key *k, hash_data *d);
/* Total order on hash table keys, only uesd for hash_table_scan_sorted */
typedef int (*keycmp_fn)(hash_key k1, hash_key k2);
struct sorted_entry
{
hash_key k;
hash_data d;
};
typedef struct
{
region r;
int i;
int size;
struct sorted_entry *entries;
} hash_table_scanner_sorted;
/* Begin scanning ht in sorted order according to f */
void hash_table_scan_sorted(hash_table ht, keycmp_fn f,
hash_table_scanner_sorted *htss);
/* Just like hash_table_next, but scans in sorted order */
bool hash_table_next_sorted(hash_table_scanner_sorted *htss, hash_key *k,
hash_data *d) deletes;
EXTERN_C_END
#endif
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <stdlib.h>
#include <assert.h>
#include <math.h>
#include "hashset.h"
#include "util.h"
#define INIT_TABLE_SIZE 2
#define EMPTY_KEY 0
#define UB(n) ((1<<n)-1) /* 2^n-1 */
#define CAP(n) (1<<n) /* 2^n */
struct hash_set
{
int *traditional table;
unsigned int ub;
unsigned int capacity;
unsigned int inserts;
unsigned int size;
};
static const int prime_1 = 83;
static const int prime_2 = 5189;
static const int init_table_size = INIT_TABLE_SIZE;
static const int empty_key = EMPTY_KEY;
hash_set hs_create(region r)
{
hash_set hs = ralloc(r, struct hash_set);
hs->ub = UB(init_table_size);
hs->size = init_table_size;
hs->capacity = CAP(init_table_size);
hs->table = (int *)calloc(hs->capacity, sizeof(int));
hs->inserts = 0;
return hs;
}
int hs_num_items(hash_set hs)
{
return hs->inserts;
}
int *hs_list_items(hash_set hs)
{
return hs->table;
}
static bool member(int *table, int ub, int i, int value)
{
while (table[i] != empty_key)
{
if (table[i] == value)
return TRUE;
else
i = ub & (i + prime_2);
}
return FALSE;
}
static inline void reinsert(int *table, int ub, int value)
{
int i;
i = ub & (prime_1 * value);
while (table[i] != empty_key)
{
/* possibly the value is already present */
if (table[i] == value)
return;
else
i = ub & (i + prime_2);
}
table[i] = value;
}
static bool member_or_insert(int *table, int ub, int i, int value)
{
while (table[i] != empty_key)
{
if (table[i] == value)
return TRUE;
else
i = ub & (i + prime_2);
}
table[i] = value;
return FALSE;
}
static void rehash(hash_set hs)
{
int *old_table;
int old_capacity, i;
old_table = hs->table;
old_capacity = hs->capacity;
hs->capacity *= 2;
hs->ub = UB(++hs->size);
hs->table = (int *)calloc(hs->capacity, sizeof(int));
assert(hs->table);
for (i = 0; i < old_capacity; i++)
{
reinsert(hs->table, hs->ub, old_table[i]);
}
free(old_table);
}
/*
static void post_insert(hash_set hs)
{
float percent_full;
int capacity = hs->capacity;
int inserts = ++hs->inserts;
printf("%d,%d->%f\n",inserts,capacity,percent_full);
assert(capacity);
percent_full = (float) inserts / capacity;
if (percent_full != percent_full)
{
assert (0);
}
if (percent_full >= .85)
rehash(hs);
}
*/
static void post_insert(hash_set hs)
{
int capacity = hs->capacity;
int inserts = ++hs->inserts;
float percent_capacity = capacity * .85;
/*
printf("%d,%d->%f\n",inserts,capacity,percent_capacity);
*/
if ( (float) inserts >= percent_capacity)
{
rehash(hs);
}
}
bool hs_query(hash_set hs, int entry)
{
int hash;
int ub = hs->ub;
hash = ub & (prime_1 * abs(entry));
return member(hs->table, ub, hash, entry);
}
bool hs_member(hash_set hs, int entry)
{
int hash;
int ub = hs->ub;
hash = ub & (prime_1 * abs(entry));
if (member_or_insert(hs->table, ub, hash, entry))
return TRUE;
else
{
post_insert(hs);
return FALSE;
}
}
void hs_delete(hash_set hs)
{
free(hs->table);
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef HASHSET_H
#define HASHSET_H
#include "linkage.h"
#include "banshee.h"
EXTERN_C_BEGIN
typedef struct hash_set *hash_set;
hash_set hs_create(region r);
void hs_delete(hash_set);
bool hs_member(hash_set,int); /* adds the entry if not present */
bool hs_query(hash_set,int); /* query only */
int *hs_list_items(hash_set);
int hs_num_items(hash_set);
EXTERN_C_END
#endif /* HASHSET_H */
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <assert.h>
#include "jcollection.h"
#include "hashset.h"
#include "termhash.h"
/*
static term_hash jcoll_hash;
*/
struct jcoll_dict
{
region r;
term_hash hash;
get_stamp_fn_ptr get_stamp;
};
enum jcoll_type
{
j_single,
j_chain,
j_join
};
/* generic jcoll type */
struct jcoll
{
enum jcoll_type type;
stamp st;
};
struct jcoll_single
{
enum jcoll_type type;
stamp st;
gen_e entry;
};
struct jcoll_chain
{
enum jcoll_type type;
stamp st;
gen_e_list sameregion entries;
};
struct jcoll_join
{
enum jcoll_type type;
stamp st;
jcoll_list sameregion joins;
gen_e_list sameregion cache;
};
typedef struct jcoll_single *jcoll_single;
typedef struct jcoll_chain *jcoll_chain;
typedef struct jcoll_join *jcoll_join;
DEFINE_LIST(jcoll_list,jcoll)
jcoll jcoll_new(jcoll_dict d, gen_e e)
{
jcoll_single result = ralloc(d->r, struct jcoll_single);
result->type = j_single;
result->st = stamp_fresh();
result->entry = e;
return (jcoll)result;
}
jcoll jcoll_jjoin(jcoll_dict d,jcoll_list list)
{
if (jcoll_list_empty(list))
return NULL;
else if (jcoll_list_length(list) == 1)
return jcoll_list_head(list);
else
{
int i = 0,
length = jcoll_list_length(list) + 1;
stamp sts[length];
jcoll_join result;
jcoll_list_scanner scan;
jcoll temp;
sts[i++] = j_join;
jcoll_list_scan(list,&scan);
while (jcoll_list_next(&scan,&temp))
{
stamp st = temp ? temp->st : 0;
sts[i++] = st;
}
qsort(&sts[1],length-1,sizeof(int),ptr_cmp);
if ( NULL == (result = (jcoll_join)term_hash_find(d->hash,sts,length)) )
{
result = ralloc(d->r,struct jcoll_join);
result->type = j_join;
result->st = stamp_fresh();
result->joins = list;
result->cache = new_gen_e_list(d->r);
term_hash_insert(d->hash,(gen_e)result,sts,length);
}
return (jcoll)result;
}
}
/*
Hash chains
*/
jcoll jcoll_create_chain(jcoll_dict d, gen_e_list elems)
{
int i = 0,
length = gen_e_list_length(elems) + 1;
stamp sts[length];
gen_e_list_scanner scan;
gen_e temp;
jcoll_chain result;
sts[i++] = j_chain;
gen_e_list_scan(elems,&scan);
while (gen_e_list_next(&scan,&temp))
{
sts[i++] = d->get_stamp(temp);
}
qsort(&sts[1],length-1,sizeof(int),ptr_cmp); /* FIX, first pos should always be chain */
if ( NULL == (result = (jcoll_chain)term_hash_find(d->hash,sts,length)) )
{
result = ralloc(d->r,struct jcoll_chain);
result->type = j_chain;
result->st = stamp_fresh();
result->entries = elems;
term_hash_insert(d->hash,(gen_e)result,sts,
length);
}
return (jcoll)result;
}
typedef void (*japp_fn_ptr) (void *, void *);
static void app_aux(hash_set h, get_stamp_fn_ptr get_stamp, japp_fn_ptr app,
jcoll j, void *data)
{
if (! j)
return;
switch(j->type)
{
case j_single:
{
jcoll_single single = (jcoll_single) j;
if (! hs_member(h,get_stamp(single->entry)) )
app(single->entry, data);
}
break;
case j_chain:
{
jcoll_chain chain = (jcoll_chain) j;
if (! hs_member(h,chain->st) )
{
gen_e_list_scanner scan;
gen_e entry;
gen_e_list_scan(chain->entries, &scan);
while (gen_e_list_next(&scan, &entry))
{
if (! hs_member(h, get_stamp(entry)) )
app(entry, data);
}
}
}
break;
case j_join:
{
jcoll_join join = (jcoll_join) j;
if (! hs_member(h, join->st))
{
if (! gen_e_list_empty(join->cache))
{
gen_e_list_scanner scan;
gen_e entry;
gen_e_list_scan(join->cache, &scan);
while (gen_e_list_next(&scan, &entry))
{
if (! hs_member(h, get_stamp(entry)) )
app(entry, data);
}
}
else
{
jcoll_list_scanner scan;
jcoll temp;
jcoll_list_scan(join->joins, &scan);
while (jcoll_list_next(&scan,&temp))
{
app_aux(h,get_stamp,app,temp, data);
}
}
}
}
break;
}
}
static void jcoll_app(jcoll_dict d, japp_fn_ptr app, jcoll j, void *data) deletes
{
region scratch_rgn = newregion();
hash_set hash = hs_create(scratch_rgn);
app_aux(hash,d->get_stamp, app, j, data);
hs_delete(hash);
deleteregion(scratch_rgn);
}
static void jcoll_accum(void *e, void *accum)
{
gen_e_list_cons((gen_e) e, (gen_e_list) accum);
}
gen_e_list jcoll_flatten(jcoll_dict d, jcoll j) deletes
{
gen_e_list accum = NULL;
if (j == NULL)
return new_gen_e_list(d->r);
switch (j->type)
{
case j_single:
{
jcoll_single single = (jcoll_single)j;
accum = new_gen_e_list(d->r);
gen_e_list_cons(single->entry,accum);
}
break;
case j_chain:
{
jcoll_chain chain = (jcoll_chain)j;
/* accum = gen_e_list_copy(r,chain->entries); */
accum = chain->entries;
}
break;
case j_join:
{
jcoll_join join = (jcoll_join)j;
if (! gen_e_list_empty(join->cache))
return join->cache;
else
{
accum = new_gen_e_list(d->r);
jcoll_app(d, jcoll_accum,j, accum);
gen_e_list_append(join->cache,accum /* gen_e_list_copy(r,accum)*/);
}
}
break;
}
return accum;
}
jcoll_dict jcoll_create_dict(region r,get_stamp_fn_ptr get_stamp)
{
jcoll_dict result = ralloc(r,struct jcoll_dict);
result->r = r;
result->hash = make_term_hash(r);
result->get_stamp = get_stamp;
return result;
}
void jcoll_delete_dict(jcoll_dict d)
{
term_hash_delete(d->hash);
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef JCOLLECTION_H
#define JCOLLECTION_H
#include "linkage.h"
#include "banshee.h"
EXTERN_C_BEGIN
typedef struct jcoll *jcoll;
typedef struct jcoll_dict *jcoll_dict;
DECLARE_LIST(jcoll_list,jcoll)
jcoll jcoll_new(jcoll_dict d, gen_e e);
jcoll jcoll_jjoin(jcoll_dict d, jcoll_list list);
gen_e_list jcoll_flatten(jcoll_dict d, jcoll j) deletes;
jcoll jcoll_create_chain(jcoll_dict d, gen_e_list elems);
jcoll_dict jcoll_create_dict(region r,get_stamp_fn_ptr get_stamp);
void jcoll_delete_dict(jcoll_dict d);
EXTERN_C_END
#endif /* JCOLLECTION_H */
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef LINKAGE_H
#define LINKAGE_H
#ifdef __cplusplus
# define EXTERN_C extern "C"
# define EXTERN_C_BEGIN extern "C" {
# define EXTERN_C_END }
#else
# define EXTERN_C
# define EXTERN_C_BEGIN
# define EXTERN_C_END
#endif
#endif
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#include <assert.h>
#include "list.h"
#include "util.h"
struct list_node
{
void *data;
struct list_node *sameregion next;
};
#define scan_node(b,var) for (var = b; var; var = var->next)
struct list
{
region sameregion r;
int length;
list_node sameregion head;
};
struct list *new_list(region r)
{
struct list *result;
assert(r);
result = ralloc(r,struct list);
result->r = r;
result->length = 0;
result->head = NULL;
return result;
}
int list_size(struct list *l)
{
return l->length;
}
struct list *list_cons(void *data, struct list *l)
{
list_node newnode = ralloc(l->r, struct list_node);
newnode->next = l->head;
newnode->data = data;
l->head = newnode;
l->length++;
return l;
}
struct list *list_reverse(struct list *l)
{
if (list_empty(l))
return l;
else
{
list_node temp,reversed = NULL;
while (l->head)
{
temp = l->head->next;
l->head->next = reversed;
reversed = l->head;
l->head = temp;
}
l->head = reversed;
return l;
}
}
bool list_empty(struct list *l)
{
return (l->head == NULL);
}
static inline list_node tail(list_node n)
{
if (n == NULL)
return NULL;
else
{
list_node temp = NULL,
tail = NULL;
scan_node(n,temp)
tail = temp;
assert(tail && tail->next == NULL);
return tail;
}
}
struct list *list_append(struct list *a, struct list *b)
{
list_node tl;
assert( a && b );
assert( a != b);
assert( ptr_eq(a->r,b->r) );
tl = tail(a->head);
if (! tl)
{
a->head = b->head;
a->length = b->length;
}
else
{
tl->next = b->head;
a->length += b->length;
}
return a;
}
struct list *list_app(struct list *l,app_fn app)
{
list_node n = NULL;
assert(l);
scan_node(l->head,n)
{
app(n->data);
}
return l;
}
void *list_find(struct list *l,eq_fn eq)
{
list_node n = NULL;
assert(l);
scan_node(l->head,n)
{
if (eq(n->data))
return n;
}
return NULL;
}
struct list *list_tail(struct list *l)
{
l->length--;
l->head = l->head->next;
return l;
}
void *list_head(struct list *l)
{
return l->head->data;
}
struct list *list_filter(region r,struct list *l,eq_fn eq)
{
struct list *result;
list_node n = NULL;
assert(l);
result = new_list(r);
scan_node(l->head,n)
{
if (eq(n->data))
list_cons(n->data,result);
}
return result;
}
struct list *list_keep(struct list *l, eq_fn eq)
{
list_node prev, n;
assert(l);
while (l->head && !eq(l->head->data))
{
l->head = l->head->next;
}
prev = l->head;
scan_node(l->head->next,n)
{
if (!eq(n->data))
prev->next = n->next;
else prev = n;
}
return l;
}
struct list *list_filter2(struct list *l,eq_fn eq)
{
return list_filter(l->r,l,eq);
}
struct list *list_copy(region r, struct list *l)
{
struct list *result;
list_node n = NULL;
#ifndef NDEBUG
int count = 0;
#endif
assert(l);
result = new_list(r);
scan_node(l->head,n)
{
list_cons(n->data,result);
assert(++count <= l->length);
}
return list_reverse(result);
}
/* A Linked-List Memory Sort
by Philip J. Erdelsky
pje@acm.org
http://www.alumni.caltech.edu/~pje/
*/
#include <stdio.h>
static void *sort_linked_list(void *p, unsigned index,
int (*compare)(const void *,const void *, comparator_fn), long *pcount, comparator_fn data)
{
unsigned base;
unsigned long block_size;
struct record
{
struct record *next[1];
/* other members not directly accessed by this function */
};
struct tape
{
struct record *first, *last;
unsigned long count;
} tape[4];
/* Distribute the records alternately to tape[0] and tape[1]. */
tape[0].count = tape[1].count = 0L;
tape[0].first = NULL;
base = 0;
while (p != NULL)
{
struct record *next = ((struct record *)p)->next[index];
((struct record *)p)->next[index] = tape[base].first;
tape[base].first = ((struct record *)p);
tape[base].count++;
p = next;
base ^= 1;
}
/* If the list is empty or contains only a single record, then */
/* tape[1].count == 0L and this part is vacuous. */
for (base = 0, block_size = 1L; tape[base+1].count != 0L;
base ^= 2, block_size <<= 1)
{
int dest;
struct tape *tape0, *tape1;
tape0 = tape + base;
tape1 = tape + base + 1;
dest = base ^ 2;
tape[dest].count = tape[dest+1].count = 0;
for (; tape0->count != 0; dest ^= 1)
{
unsigned long n0, n1;
struct tape *output_tape = tape + dest;
n0 = n1 = block_size;
while (1)
{
struct record *chosen_record;
struct tape *chosen_tape;
if (n0 == 0 || tape0->count == 0)
{
if (n1 == 0 || tape1->count == 0)
break;
chosen_tape = tape1;
n1--;
}
else if (n1 == 0 || tape1->count == 0)
{
chosen_tape = tape0;
n0--;
}
else if ((*compare)(tape0->first, tape1->first, data) > 0)
{
chosen_tape = tape1;
n1--;
}
else
{
chosen_tape = tape0;
n0--;
}
chosen_tape->count--;
chosen_record = chosen_tape->first;
chosen_tape->first = chosen_record->next[index];
if (output_tape->count == 0)
output_tape->first = chosen_record;
else
output_tape->last->next[index] = chosen_record;
output_tape->last = chosen_record;
output_tape->count++;
}
}
}
if (tape[base].count > 1L)
tape[base].last->next[index] = NULL;
if (pcount != NULL)
*pcount = tape[base].count;
return tape[base].first;
}
static int compare(const void *node1, const void *node2, comparator_fn data)
{
comparator_fn cmp = (comparator_fn) data;
return cmp(((struct list_node *)node1)->data,
((struct list_node *)node2)->data);
}
struct list *list_sort(struct list *l, comparator_fn cmp)
{
long pcount;
l->head = sort_linked_list(l->head,1,compare,&pcount, cmp);
assert(pcount == l->length);
return l;
}
struct list *list_merge(struct list *a,struct list *b, comparator_fn cmp)
{
return list_sort( list_append(a,b),cmp);
}
void list_scan(struct list *a,struct list_scanner *scan)
{
scan->l = a;
scan->cur = a->head;
}
bool list_next(struct list_scanner *scan, void **data)
{
if (!scan->cur)
return FALSE;
else
{
if (data)
*data = scan->cur->data;
scan->cur = scan->cur->next;
return TRUE;
}
}
void list_clear(struct list *l)
{
l->head = NULL;
l->length = 0;
}
bool list_member(struct list *l,void *data)
{
list_node n = NULL;
scan_node(l->head,n)
{
if (n->data == data)
return TRUE;
}
return FALSE;
}
struct list *list_from_array(region r,void **data, int length)
{
struct list *result = new_list(r);
int i;
for (i = length -1; i >= 0; i--)
{
list_cons(data[i],result);
}
return result;
}
/*
* Copyright (c) 2000-2001
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*/
#ifndef LIST_H
#define LIST_H
#include <regions.h>
#include "bool.h"
typedef void *list_data;
typedef void (*app_fn) (void *);
typedef bool (*eq_fn)(const void *);
typedef int (*comparator_fn)(const void *,const void *);
struct list;
typedef struct list_node *list_node;
struct list_scanner
{
struct list *l;
list_node cur;
}; /* Opaque type. Do not modify fields */
struct list *new_list(region r);
int list_size(struct list *a);
struct list *list_cons(void *data, struct list *a);
struct list *list_append(struct list *a, struct list *b);
struct list *list_app(struct list *a,app_fn app);
void *list_find(struct list *a,eq_fn eq);
void *list_head(struct list *a);
struct list *list_tail(struct list *a);
struct list *list_filter(region r,struct list *a,eq_fn eq);
struct list *list_filter2(struct list *a,eq_fn eq);
struct list *list_keep(struct list *a,eq_fn eq);
struct list *list_copy(region r, struct list *a);
struct list *list_sort(struct list *a, comparator_fn cmp);
struct list *list_merge(struct list *a,struct list *b, comparator_fn cmp);
void list_scan(struct list *a,struct list_scanner *scan);
bool list_next(struct list_scanner *scan, void **data);
bool list_empty(struct list *a);
bool list_member(struct list *a, void *data);
void list_clear(struct list *a);
struct list *list_reverse(struct list *a);
struct list *list_from_array(region r,void **data, int length);
#define DECLARE_OPAQUE_LIST(name,type) \
typedef struct list_scanner name ## _scanner; \
typedef void (* name ## _app_fn) (type); \
typedef bool (* name ## _eq_fn) (const type); \
typedef int (* name ## _comparator_fn)(const type,const type); \
name new_ ## name(region r); \
int name ## _length(name a); \
name name ## _cons(type data, name a); \
name name ## _append(name a, name b); \
name name ## _app(name a, name ## _app_fn app); \
type name ## _find(name a, name ## _eq_fn eq); \
type name ## _head(name a); \
name name ## _tail(name a); \
name name ## _filter(region r,name a, name ## _eq_fn eq); \
name name ## _filter2(name a, name ## _eq_fn eq); \
name name ## _keep(name a, name ## _eq_fn eq); \
name name ## _copy(region r, name a); \
name name ## _sort(name a, name ## _comparator_fn cmp); \
name name ## _merge(name a,name b, name ## _comparator_fn cmp); \
void name ## _scan(name a, name ##_scanner *scan); \
bool name ## _next(name ##_scanner *scan, type *data); \
bool name ## _empty(name a); \
void name ## _clear(name a); \
bool name ## _member(name a, type data); \
name name ## _reverse(name a); \
name name ## _from_array(region r,type data[], int length);
#define DECLARE_LIST(name,type) \
typedef struct name ## _a *name; \
typedef struct list_scanner name ## _scanner; \
typedef void (* name ## _app_fn) (type); \
typedef bool (* name ## _eq_fn) (const type); \
typedef int (* name ## _comparator_fn)(const type,const type); \
name new_ ## name(region r); \
int name ## _length(name a); \
name name ## _cons(type data, name a); \
name name ## _append(name a, name b); \
name name ## _app(name a, name ## _app_fn app); \
type name ## _find(name a, name ## _eq_fn eq); \
type name ## _head(name a); \
name name ## _tail(name a); \
name name ## _filter(region r,name a, name ## _eq_fn eq); \
name name ## _filter2(name a, name ## _eq_fn eq); \
name name ## _keep(name a, name ## _eq_fn eq); \
name name ## _copy(region r, name a); \
name name ## _sort(name a, name ## _comparator_fn cmp); \
name name ## _merge(name a,name b, name ## _comparator_fn cmp); \
void name ## _scan(name a, name ##_scanner *scan); \
bool name ## _next(name ##_scanner *scan, type *data); \
bool name ## _empty(name a); \
void name ## _clear(name a); \
bool name ## _member(name a, type data); \
name name ## _reverse(name a); \
name name ## _from_array(region r,type data[], int length);
#define DEFINE_LIST(name,type) \
name new_ ## name(region r) \
{ \
return (name)new_list(r); \
} \
int name ## _length(name a) \
{ \
return list_size((struct list *)a); \
} \
name name ## _cons(type data, name a) \
{ \
return (name)list_cons((void *)data,(struct list *) a ); \
}\
name name ## _append(name a, name b) \
{ \
return (name)list_append((struct list *)a,(struct list *)b); \
} \
name name ## _app(name a, name ## _app_fn app) \
{ \
return (name)list_app((struct list *) a, (app_fn) app); \
} \
type name ## _find(name a, name ## _eq_fn eq) \
{ \
return (type)list_find((struct list *)a, (eq_fn) eq); \
} \
name name ## _tail(name a) \
{\
return (name)list_tail((struct list *)a);\
}\
type name ## _head(name a) \
{ \
return (type)list_head((struct list *)a); \
} \
name name ## _filter(region r,name a, name ## _eq_fn eq) \
{ \
return (name)list_filter(r,(struct list *)a, (eq_fn) eq); \
} \
name name ## _keep(name a, name ## _eq_fn eq) \
{ \
return (name)list_keep((struct list *)a, (eq_fn) eq); \
} \
name name ## _filter2(name a, name ## _eq_fn eq) \
{ \
return (name)list_filter2((struct list *)a, (eq_fn) eq); \
} \
name name ## _copy(region r, name a) \
{ \
return (name)list_copy(r,(struct list *) a); \
} \
name name ## _sort(name a, name ## _comparator_fn cmp) \
{ \
return (name)list_sort((struct list *)a,(comparator_fn) cmp); \
} \
name name ## _merge(name a,name b, name ## _comparator_fn cmp) \
{ \
return (name)list_merge((struct list *)a,(struct list *)b,(comparator_fn)cmp); \
} \
void name ## _scan(name a, name ##_scanner *scan) \
{ \
list_scan((struct list *)a,(struct list_scanner *)scan);\
}\
bool name ## _next(name ##_scanner *scan, type *data) \
{ \
return list_next((struct list_scanner *)scan, (void **)data); \
} \
bool name ## _empty(name a) \
{ \
return list_empty((struct list *)a); \
} \
void name ## _clear(name a) \
{ \
list_clear((struct list *)a); \
} \
bool name ## _member(name a, type data) \
{ \
return list_member((struct list *)a,(void *)data); \
} \
name name ## _reverse(name a) \
{\
return (name)list_reverse((struct list *)a);\
}\
name name ## _from_array(region r,type data[], int length) \
{\
return (name)list_from_array(r,(void **)data,length); \
}\
#endif /* LIST_H */
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment