mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-14 13:23:53 +00:00
Estimated hours taken: 1200
Aditi compilation.
compiler/options.m:
The documentation for these is commented out because the Aditi
system is not currently useful to the general public.
--aditi: enable Aditi compilation.
--dump-rl: write the intermediate RL to `<module>.rl_dump'.
--dump-rl-bytecode: write a text version of the bytecodes
to `<module>.rla'
--aditi-only: don't produce a `.c' file.
--filenames-from-stdin: accept a list of filenames to compile
from stdin. This is used by the query shell.
--optimize-rl, --optimize-rl-cse, --optimize-rl-invariants,
--optimize-rl-index, --detect-rl-streams:
Options to control RL optimization passes.
--aditi-user:
Default owner of any Aditi procedures,
defaults to $USER or "guest".
--generate-schemas:
write schemas for base relations to `<module>'.base_schema
and schemas for derived relations to `<module>'.derived_schema.
This is used by the query shell.
compiler/handle_options.m:
Handle the default for --aditi-user.
compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
Add some Aditi pragma declarations - `aditi', `supp_magic', `context',
`naive', `psn' (predicate semi-naive), `aditi_memo', `aditi_no_memo',
`base_relation', `owner' and `index'.
Separate out code to parse a predicate name and arity.
compiler/hlds_pred.m:
Add predicates to identify Aditi procedures.
Added markers `generate_inline' and `aditi_interface', which
are used internally for Aditi code generation.
Add an `owner' field to pred_infos, which is used for database
security checks.
Add a field to pred_infos to hold the list of indexes for a base
relation.
compiler/make_hlds.m:
Some pragmas must be exported if the corresponding predicates
are exported, check this.
Make sure stratification of Aditi procedures is checked.
Predicates with a mode declaration but no type declaration
are no longer assumed to be local.
Set the `do_aditi_compilation' field of the module_info if there
are any local Aditi procedures or base relations.
Check that `--aditi' is set if Aditi compilation is required.
compiler/post_typecheck.m:
Check that every Aditi predicate has an `aditi__state' argument,
which is used to ensure sequencing of updates and that Aditi
procedures are only called within transactions.
compiler/dnf.m:
Changed the definition of disjunctive normal form slightly
so that a call followed by some atomic goals not including
any database calls is considered atomic. magic.m can handle
this kind of goal, and it results in more efficient RL code.
compiler/hlds_module.m:
compiler/dependency_graph.m:
Added dependency_graph__get_scc_entry_points which finds
the procedures in an SCC which could be called from outside.
Added a new field to the dependency_info, the
aditi_dependency_ordering. This contains all Aditi SCCs of
the original program, with multiple SCCs merged where
possible to improve the effectiveness of differential evaluation
and the low level RL optimizations.
compiler/hlds_module.m:
Add a field to record whether there are any local Aditi procedures
in the current module.
Added versions of module_info_pred_proc_info and
module_info_set_pred_proc_info which take a pred_proc_id,
not a separate pred_id and proc_id.
compiler/polymorphism.m:
compiler/lambda.m:
Make sure that predicates created for closures in Aditi procedures
have the correct markers.
compiler/goal_util.m:
Added goal_util__switch_to_disjunction,
goal_util__case_to_disjunct (factored out from simplify.m)
and goal_util__if_then_else_to_disjunction. These are
require because supplementary magic sets can't handle
if-then-elses or switches.
compiler/type_util.m:
Added type_is_aditi_state/1.
compiler/mode_util.m:
Added partition_args/5 which partitions a list of arguments
into inputs and others.
compiler/inlining.m:
Don't inline memoed procedures.
Don't inline Aditi procedures into non-Aditi procedures.
compiler/intermod.m:
Handle Aditi markers.
Clean up handling of markers which should not appear in `.opt' files.
compiler/simplify.m:
Export a slightly different interface for use by magic.m.
Remove explicit quantifications where possible.
Merge multiple nested quantifications.
Don't report infinite recursion warnings for Aditi procedures.
compiler/prog_out.m:
Generalised the code to output a module list to write any list.
compiler/code_gen.m:
compiler/arg_info.m:
Don't process Aditi procedures.
compiler/mercury_compile.m:
Call magic.m and rl_gen.m.
Don't perform the low-level annotation passes on Aditi procedures.
Remove calls to constraint.m - sometime soon a rewritten version
will be called directly from deforestation.
compiler/passes_aux.m:
Add predicates to process only non-Aditi procedures.
compiler/llds.m:
compiler/llds_out.m:
Added new `code_addr' enum members, do_{det,semidet,nondet}_aditi_call,
which are defined in extras/aditi/aditi.m.
compiler/call_gen.m:
Handle generation of do_*_aditi_call.
compiler/llds_out.m:
Write the RL code for the module as a constant char array
in the `.c' file.
compiler/term_errors.m:
compiler/error_util.m:
Move code to describe predicates into error_util.m
Allow the caller to explicitly add line breaks.
Added error_util:list_to_pieces to format a list of
strings.
Reordered some arguments for currying.
compiler/hlds_out.m:
Don't try to print clauses if there are none.
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
Added a function `mercury__load_aditi_rl_code()' to the generated
`<module>_init.c' file which throws all the RL code for the program
at the database. This should be called at connection time by
`aditi__connect'.
Added an option `--aditi' which controls the output
`mercury__load_aditi_rl_code()'.
compiler/notes/compiler_design.html:
Document the new files.
Mmakefile:
bindist/Mmakefile:
Don't distribute extras/aditi yet.
New files:
compiler/magic.m:
compiler/magic_util.m:
Supplementary magic sets transformation. Report errors
for constructs that Aditi can't handle.
compiler/context.m:
Supplementary context transformation.
compiler/rl_gen.m:
compiler/rl_relops.m:
Aditi code generation.
compiler/rl_info.m:
Code generator state.
compiler/rl.m:
Intermediate RL representation.
compiler/rl_util:
Predicates to collect information about RL instructions.
compiler/rl_dump.m:
Print out the representation in rl.m.
compiler/rl_opt.m:
Control low-level RL optimizations.
compiler/rl_block.m:
Break a procedure into basic blocks.
compiler/rl_analyse.m:
Generic dataflow analysis for RL procedures.
compiler/rl_liveness.m:
Make sure all relations are initialised before used, clear
references to relations that are no longer required.
compiler/rl_loop.m:
Loop invariant removal.
compiler/rl_block_opt.m:
CSE and instruction merging on basic blocks.
compiler/rl_key.m:
Detect upper/lower bounds for which a goal could succeed.
compiler/rl_sort.m:
Use indexing for joins and projections.
Optimize away unnecessary sorting and indexing.
compiler/rl_stream.m:
Detect relations which don't need to be materialised.
compiler/rl_code.m:
RL bytecode definitions. Automatically generated from the Aditi
header files.
compiler/rl_out.m:
compiler/rl_file.m:
Output the RL bytecodes in binary to <module>.rlo (for use by Aditi)
and in text to <module>.rla (for use by the RL interpreter).
Also output the schema information if --generate-schemas is set.
compiler/rl_exprn.m:
Generate bytecodes for join conditions.
extras/aditi/Mmakefile:
extras/aditi/aditi.m:
Definitions of some Aditi library predicates and the
interfacing and transaction processing code.
311 lines
9.0 KiB
Plaintext
311 lines
9.0 KiB
Plaintext
#-----------------------------------------------------------------------------#
|
|
# Copyright (C) 1995-1998 The University of Melbourne.
|
|
# This file may only be copied under the terms of the GNU General
|
|
# Public License - see the file COPYING in the Mercury distribution.
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Mmake.rules - rules for building Mercury programs
|
|
|
|
# N.B. All the builtin rules must use $@ as the target, so that they work
|
|
# when $(VPATH) is set.
|
|
|
|
main_target: $(MAIN_TARGET)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Beware that the order of suffixes is significant.
|
|
.SUFFIXES: .m .nl .no .err \
|
|
.int0 .int .int2 .int3 .opt .trans_opt \
|
|
.dep .depend .doit .ugly \
|
|
.date0 .date .date3 .optdate .trans_opt_date \
|
|
.c .nu .o .pic_o \
|
|
.i .s .pic_s \
|
|
.ql .pl \
|
|
.rlo
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Code to set variables based on the setting of MMAKE_USE_SUBDIRS
|
|
# (i.e. --use-subdirs).
|
|
#
|
|
|
|
ifeq ($(MMAKE_USE_SUBDIRS),yes)
|
|
|
|
MCFLAGS += --use-subdirs
|
|
MSCFLAGS += --use-subdirs
|
|
MNCFLAGS += --use-subdirs
|
|
MGNUCFLAGS += -I.
|
|
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PRECIOUS: $(date0s_subdir)%.date0
|
|
.PRECIOUS: $(dates_subdir)%.date
|
|
.PRECIOUS: $(date3s_subdir)%.date3
|
|
.PRECIOUS: $(optdates_subdir)%.optdate
|
|
.PRECIOUS: $(trans_opt_dates_subdir)%.trans_opt_date
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Rules for NU-Prolog and SICStus Prolog.
|
|
#
|
|
|
|
.m.pl:
|
|
sicstus_conv $<
|
|
|
|
.nl.pl:
|
|
sicstus_conv $<
|
|
|
|
$(nos_subdir)%.no : %.m
|
|
$(MNC) $(ALL_MNCFLAGS) -o $@ $<
|
|
|
|
$(nos_subdir)%.no : %.nl
|
|
$(MNC) $(ALL_MNCFLAGS) -o $@ $<
|
|
|
|
$(qls_subdir)%.ql : %.m
|
|
$(MSC) $(ALL_MSCFLAGS) -o $@ $<
|
|
|
|
$(qls_subdir)%.ql : %.nl
|
|
$(MSC) $(ALL_MSCFLAGS) -o $@ $<
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Rules for building dependency files
|
|
#
|
|
|
|
# When creating the dependencies with `--use-subdirs' enabled,
|
|
# we need to create the `Mercury/dates' directories manually
|
|
# in order to get things started. This should not be necessary,
|
|
# but there is a bug in GNU Make with regard to directory caching.
|
|
# I have sent off a bug report to the GNU Make maintainers (19 March 1998).
|
|
# -fjh.
|
|
|
|
# beware the code for `%.depend' and `%.dep' is duplicated
|
|
$(deps_subdir)%.dep:
|
|
$(MCD) $(ALL_MCDFLAGS) $*
|
|
ifeq ($(MMAKE_USE_SUBDIRS),yes)
|
|
# the following mkdirs work around a bug in GNU Make
|
|
-[ -d Mercury/dates ] || mkdir Mercury/dates
|
|
-[ -d Mercury/date0s ] || mkdir Mercury/date0s
|
|
-[ -d Mercury/date3s ] || mkdir Mercury/date3s
|
|
-[ -d Mercury/optdates ] || mkdir Mercury/optdates
|
|
endif
|
|
|
|
# beware the code for `%.depend' and `%.dep' is duplicated
|
|
.PHONY: %.depend
|
|
%.depend :
|
|
$(MCD) $(ALL_MCDFLAGS) $*
|
|
ifeq ($(MMAKE_USE_SUBDIRS),yes)
|
|
# the following mkdirs work around a bug in GNU Make
|
|
-[ -d Mercury/dates ] || mkdir Mercury/dates
|
|
-[ -d Mercury/date0s ] || mkdir Mercury/date0s
|
|
-[ -d Mercury/date3s ] || mkdir Mercury/date3s
|
|
-[ -d Mercury/optdates ] || mkdir Mercury/optdates
|
|
endif
|
|
|
|
# The `.doit' files are helpful when using Prolog.
|
|
|
|
%.doit : $(deps_subdir)%.dep
|
|
sed -e ':a' -e '/\\/N' -e 's/\\\n //' -e 't a' $< | \
|
|
grep '\.ms *=' | \
|
|
sed -e 's/.*=/:-[ '\''nu_library.doit'\'', /' \
|
|
-e 's/\.m/,/g' \
|
|
-e 's/$$/ portray ]./' \
|
|
> $@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Rules for building interface files
|
|
# WARNING: any changes here will probably need to be
|
|
# duplicated in compiler/modules.m.
|
|
#
|
|
|
|
$(date0s_subdir)%.date0 : %.m
|
|
$(MCPI) $(ALL_MCPIFLAGS) $<
|
|
|
|
$(dates_subdir)%.date : %.m
|
|
$(MCI) $(ALL_MCIFLAGS) $<
|
|
|
|
$(date3s_subdir)%.date3 : %.m
|
|
$(MCSI) $(ALL_MCSIFLAGS) $<
|
|
|
|
$(optdates_subdir)%.optdate : %.m
|
|
$(MCOI) $(ALL_MCOIFLAGS) $<
|
|
|
|
$(trans_opt_dates_subdir)%.trans_opt_date : %.m
|
|
$(MCTOI) $(ALL_MCTOIFLAGS) $<
|
|
|
|
# Be very careful about changing the following rules.
|
|
# The `@:' is a silent do-nothing command.
|
|
# It is used to force GNU Make to recheck the timestamp
|
|
# on the target file. (It is a pity that GNU Make doesn't
|
|
# have a way of handling these sorts of rules in a nicer manner.)
|
|
|
|
$(int0s_subdir)%.int0 : $(date0s_subdir)%.date0
|
|
@:
|
|
|
|
$(ints_subdir)%.int : $(dates_subdir)%.date
|
|
@:
|
|
|
|
$(int2s_subdir)%.int2 : $(dates_subdir)%.date
|
|
@:
|
|
|
|
$(int3s_subdir)%.int3 : $(date3s_subdir)%.date3
|
|
@:
|
|
|
|
$(opts_subdir)%.opt : $(optdates_subdir)%.optdate
|
|
@:
|
|
|
|
$(trans_opts_subdir)%.trans_opt : $(trans_opt_dates_subdir)%.trans_opt_date
|
|
@:
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Rules for compiling Mercury source files
|
|
# WARNING: any changes here will probably need to be
|
|
# duplicated in compiler/modules.m.
|
|
#
|
|
|
|
$(cs_subdir)%.c : %.m
|
|
rm -f $(cs_subdir)$*.c
|
|
$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) $< > $*.err 2>&1
|
|
|
|
$(rlos_subdir)%.rlo : %.m
|
|
rm -f $(rlos_subdir)$*.c
|
|
$(MCG) $(ALL_GRADEFLAGS) $(ALL_MCGFLAGS) --aditi-only $< > $*.err 2>&1
|
|
|
|
# If we are removing the .c files, we need to tell Make that we're
|
|
# generating the .o files directly from the .m files, but
|
|
# in order to avoid remaking the .c files if they're already there,
|
|
# we need to invoke mmake recursively for each .c file.
|
|
# This can be pretty inefficient.
|
|
|
|
ifneq ($(RM_C),:)
|
|
|
|
$(os_subdir)%.o : %.m
|
|
$(MMAKE_MAKE_CMD) $(MFLAGS) MC="$(MC)" ALL_MCFLAGS="$(ALL_MCFLAGS)" \
|
|
ALL_GRADEFLAGS="$(ALL_GRADEFLAGS)" $(cs_subdir)$*.c
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $(cs_subdir)$*.c -o $@
|
|
$(RM_C) $(cs_subdir)$*.c
|
|
|
|
$(os_subdir)%.pic_o : %.m
|
|
$(MMAKE_MAKE_CMD) $(MFLAGS) MC="$(MC)" ALL_MCFLAGS="$(ALL_MCFLAGS") \
|
|
ALL_GRADEFLAGS="$(ALL_GRADEFLAGS)" $(cs_subdir)$*.c
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) \
|
|
-c $(cs_subdir)$*.c -o $@
|
|
|
|
endif # RM_C != :
|
|
|
|
# For --split-c-files, we generate the .o files directly from the .m files.
|
|
# (One reason for this is that there's no easy of telling Make how many
|
|
# `.o' files it should make, since the number of them depends on what's
|
|
# in the source files.)
|
|
|
|
$(dirs_subdir)%.dir/*.o: %.m
|
|
rm -f $@
|
|
$(MCS) $(ALL_GRADEFLAGS) $(ALL_MCSFLAGS) $<
|
|
|
|
# The `touch' is necessary, since otherwise if
|
|
# the old .err file was of size zero and
|
|
# the new .err file is also of size zero,
|
|
# the time-stamp doesn't get updated!
|
|
# (Is that a bug in unix? In bash?)
|
|
|
|
.m.err:
|
|
$(MC) $(ALL_MCFLAGS) --errorcheck-only $< > $@ 2>&1
|
|
@touch $@
|
|
|
|
.m.ugly:
|
|
$(MC) --convert-to-mercury $(ALL_MCFLAGS) $<
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Rules for compiling C files in the user's source directory.
|
|
#
|
|
|
|
.c.o:
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $< -o $@
|
|
|
|
.c.pic_o:
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) \
|
|
-c $< -o $@
|
|
|
|
.c.s:
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -S $< -o $@
|
|
|
|
.c.pic_s:
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) \
|
|
-S $< -o $@
|
|
|
|
.c.i:
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -E $< > $@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Rules for compiling C files in a subdirectory.
|
|
# Note that we need both these rules and the ones above,
|
|
# since even if the compiler generates all of its files in subdirectories,
|
|
# the user may have some C files of their own which need to be compiled.
|
|
#
|
|
|
|
ifneq ("$(cs_subdir)","")
|
|
|
|
$(os_subdir)%.o : $(cs_subdir)%.c
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -c $< -o $@
|
|
|
|
$(os_subdir)%.pic_o : $(cs_subdir)%.c
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) \
|
|
-c $< -o $@
|
|
|
|
%.s: $(cs_subdir)%.c
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -S $< -o $@
|
|
|
|
%.pic_s: $(cs_subdir)%.c
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) $(CFLAGS_FOR_PIC) \
|
|
-S $< -o $@
|
|
|
|
%.i: $(cs_subdir)%.c
|
|
$(MGNUC) $(ALL_GRADEFLAGS) $(ALL_MGNUCFLAGS) -E $< > $@
|
|
|
|
endif # $(cs_subdir) != ""
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Code to handle dependencies on $(MLOBJS) and $(MLPICOBJS).
|
|
#
|
|
|
|
# The generated `.dep' files include rules for targets which may depend
|
|
# on $(MLOBJS) or $(MLPICOBJS). However, the definition of $(MLOBJS)
|
|
# or $(MLPICOBJS) is in the user's Mmakefile, and the `.dep' files get
|
|
# included *before* the Mmakefile. The `.dep' files cannot contain
|
|
# those dependency directly, because $(MLOBJS) and $(MLPICOBJS) variables
|
|
# have not yet been defined.
|
|
#
|
|
# Instead, the generated `.dep' files just add the appropriate targets to
|
|
# the $(MLOBJS_DEPS) or $(MLPICOBJS_DEPS) variables, and then we record the
|
|
# dependency of those files on $(MLOBJS) or $(MLPICOBJS) here in Mmake.rules,
|
|
# which gets included after the user's Mmakefile.
|
|
|
|
$(MLOBJS_DEPS) : $(MLOBJS)
|
|
$(MLPICOBJS_DEPS) : $(MLPICOBJS)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Targets for cleaning up.
|
|
#
|
|
# Note that the actions for most of these targets are in the
|
|
# automatically generated `.d' files.
|
|
#
|
|
|
|
.PHONY: clean realclean change_clean clean_nu clean_sicstus clean_prof_files
|
|
|
|
realclean: clean
|
|
|
|
clean: clean_prof_files
|
|
|
|
clean_prof_files:
|
|
-rm -f Prof.CallPair Prof.Counts Prof.Decl Prof.MemWords Prof.MemCells
|
|
|
|
#-----------------------------------------------------------------------------#
|