mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-19 07:45:09 +00:00
Estimated hours taken: 40
Branches: main
Implement lookup switches in which a switch arm may contain more than one
solution, such as this code here:
p(d, "four", f1, 4.4).
p(e, "five", f2, 5.5).
p(e, "five2", f3(5), 55.5).
p(f, "six", f4("hex"), 6.6).
p(g, "seven", f5(77.7), 7.7).
p(g, "seven2", f1, 777.7).
p(g, "seven3", f2, 7777.7).
Such code occurs frequently in benchmark programs used to evaluate the
performance of tabled logic programming systems.
Change frameopt.m, which previously worked only on det and semidet code,
to also work for nondet code. For predicates such as the one above, frameopt
can now arrange for the predicate's nondet stack frame to be created only
when a switch arm that has more than one solution is selected.
compiler/lookup_switch.m:
Extend the existing code for recognizing and implementing lookup
switches to recognize and implement them even if they are model_non.
compiler/lookup_util.m:
New module containing utility predicates useful for implementing
both lookup switches, and in the future, lookup disjunctions (i.e.
disjunctions that correspond to a nondet arm of a lookup switch).
compiler/ll_backend.m:
Include the new module.
compiler/notes/compiler_design.html:
Mention the new module.
compiler/global_data.m:
Move the job of filling in dummy slots to our caller, in this case
lookup_switch.m.
compiler/frameopt.m:
Generalize the existing code for delaying stack frame creation,
which worked only on predicates that live on the det stack, to work
also on predicates that live on the nondet stack. Without this,
predicates whose bodies are model_non lookup switches would create
a nonstack stack frame before the switch is ever entered, which
is wasteful if the selected switch arm has at most one solution.
Since the structure of model_non predicates is more complex (you can
cause a branch to a label by storing its address in a redoip slot,
you can succeed from the frame without removing the frame), this
required considerable extra work. To make the new code debuggable,
record, for each basic block that needs a stack frame, *why* it
needs that stack frame.
compiler/opt_util.m:
Be more conservative about what refers to the stack. Export some
previously internal functionality for frameopt. Turn some predicates
into functions, and rename them to better reflect their purpose.
compiler/opt_debug.m:
Print much more information about pragma_c and call LLDS instructions.
compiler/prog_data.m:
Add an extra attribute to foreign_procs that says that the code
of the foreign_proc assumes the existence of a stack frame.
This is needed to avoid frameopt optimizing the stack frame away.
compiler/add_pragma.m:
When processing fact tables, we create foreign_procs that assume
the existence of the stack frame, so set the new attribute.
compiler/pragma_c_gen.m:
When processing foreign_procs, transmit the information in the
attribute to the generated LLDS code.
compiler/llds.m:
Rename the function symbols referring to the fixed slots in nondet
stack frames to make them clearer and to avoid overloading function
symbols such as curfr and succip.
Rename the function symbols of the call_model type to avoid overloading
the function symbols of the code_model type.
Add a new field to the c_procedure type giving the code_model of the
procedure, and give names to all the fields.
Describe the stack slots used by lookup switches to the debugger
and native gc.
compiler/options.m:
doc/user_guide.texi:
Add a new option, --debug-opt-pred-name, that does when the existing
--debug-opt-pred-id options does, but taking a user-friendly predicate
name rather than a pred_id as its argument.
compiler/handle_options.m:
Process --debug-opt-pred-name, and make --frameopt-comments imply
--auto-comments, since it is not useful without it.
Reformat some existing comments that were written in the days of
8-space indentation.
compiler/optimize.m:
Implement the new option.
Use the new field of the c_procedure type to try only the version
of frameopt appropriate for the code model of the current procedure.
Do a peephole pass after frameopt, since frameopt can generate code
sequences that peephole can optimize.
Make the mechanism for recording the process of optimizing procedure
bodies more easily usable by including the name of the optimization
that created a given version of the code in the name of the file
that contains that version of the code, and ensuring that all numbers
are two characters long, so that "vi procname*.opt*" looks at the
relevant files in the proper chronological sequence, instead of having
version 11 appear before version 2.
compiler/peephole.m:
Add a new optimization pattern: a "mkframe, goto fail" pair (which
can be generated by frameopt) should be replaced by a simple "goto
redo".
compiler/code_gen.m:
Factor out some common code.
compiler/llds_out.m:
Ensure that C comments nested inside comment(_) LLDS instructions
aren't emitted as nested C comments, since C compilers cannot handle
these.
compiler/code_info.m:
compiler/code_util.m:
compiler/continuation_info.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/middle_rec.m:
compiler/ml_code_gen.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/peephole.m:
compiler/stack_layout.m:
compiler/transform_llds.m:
compiler/var_locn.m:
Conform to the change to prog_data.m, opt_util.m and/or llds.m.
compiler/handle_options.m:
Don't execute the code in stdlabel.m if doing so would cause a compiler
abort.
tests/hard_coded/dense_lookup_switch_non.{m,exp}:
New test case to exercise the new algorithm.
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/hard_coded/cycles.m:
Make this test case conform to our coding convention.
656 lines
16 KiB
Plaintext
656 lines
16 KiB
Plaintext
#-----------------------------------------------------------------------------#
|
|
|
|
THIS_DIR = hard_coded
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
ORDINARY_PROGS= \
|
|
abstract_eqv \
|
|
address_of_builtins \
|
|
agg \
|
|
any_free_unify \
|
|
backquoted_qualified_ops \
|
|
bidirectional \
|
|
boyer \
|
|
brace \
|
|
builtin_inst_rename \
|
|
cc_and_non_cc_test \
|
|
cc_multi_bug \
|
|
cc_nondet_disj \
|
|
checked_nondet_tailcall \
|
|
closure_extension \
|
|
common_type_cast \
|
|
compare_spec \
|
|
comparison \
|
|
constant_prop_1 \
|
|
constraint \
|
|
constraint_order \
|
|
construct_bug \
|
|
construct_test \
|
|
construct_test_exist \
|
|
contains_char \
|
|
contravariance_bug \
|
|
contravariance_poly \
|
|
curry \
|
|
curry2 \
|
|
cut_test \
|
|
c_write_string \
|
|
cycles \
|
|
cycles2 \
|
|
deconstruct_arg \
|
|
deep_copy \
|
|
deep_copy_bug \
|
|
deep_copy_exist \
|
|
deforest_cc_bug \
|
|
dense_lookup_switch \
|
|
dense_lookup_switch2 \
|
|
dense_lookup_switch3 \
|
|
dense_lookup_switch_non \
|
|
det_in_semidet_cntxt \
|
|
disjs_in_switch \
|
|
division_test \
|
|
dos \
|
|
dot_separator \
|
|
dst_test \
|
|
dummy_type_construct \
|
|
dupcall_impurity \
|
|
dupcall_types_bug \
|
|
elim_special_pred \
|
|
equality_pred_which_requires_boxing \
|
|
eqv_type_bug \
|
|
erroneous_liveness \
|
|
error_func \
|
|
existential_bound_tvar \
|
|
existential_float \
|
|
existential_reordering \
|
|
existential_reordering_class \
|
|
existential_types_test \
|
|
existential_type_switch_opt \
|
|
expand \
|
|
export_test \
|
|
external_unification_pred \
|
|
failure_unify \
|
|
field_syntax \
|
|
finalise_decl \
|
|
float_field \
|
|
float_map \
|
|
float_reg \
|
|
float_rounding_bug \
|
|
foreign_and_mercury \
|
|
foreign_import_module \
|
|
foreign_name_mutable \
|
|
foreign_type \
|
|
foreign_type2 \
|
|
foreign_type3 \
|
|
frameopt_pragma_redirect \
|
|
free_free_mode \
|
|
func_and_pred \
|
|
func_ctor_ambig \
|
|
func_test \
|
|
getopt_test \
|
|
ground_dd \
|
|
hash_bug \
|
|
hash_init_bug \
|
|
higher_order_func_test \
|
|
higher_order_syntax \
|
|
higher_order_syntax2 \
|
|
higher_order_type_manip \
|
|
ho_func_default_inst \
|
|
ho_func_reg \
|
|
ho_order \
|
|
ho_order2 \
|
|
ho_solns \
|
|
ho_univ_to_type \
|
|
impossible_unify \
|
|
impure_foreign \
|
|
impure_foreign2 \
|
|
impure_foreign3 \
|
|
impure_init_and_final \
|
|
impure_prune \
|
|
initialise_decl \
|
|
integer_test \
|
|
intermod_c_code \
|
|
intermod_foreign_type \
|
|
intermod_multimode_main \
|
|
intermod_poly_mode \
|
|
intermod_pragma_clause \
|
|
intermod_type_qual \
|
|
intermod_unused_args \
|
|
int_fold_up_down \
|
|
join_list \
|
|
list_series_int \
|
|
loop_inv_test \
|
|
loop_inv_test1 \
|
|
mapped_module \
|
|
merge_and_remove_dups \
|
|
minint_bug \
|
|
mode_check_clauses \
|
|
mode_choice \
|
|
multi_map_test \
|
|
multimode \
|
|
myset_test \
|
|
name_mangling \
|
|
no_fully_strict \
|
|
no_inline \
|
|
no_inline_builtins \
|
|
nonascii \
|
|
nondet_copy_out \
|
|
nondet_ctrl_vn \
|
|
no_warn_singleton \
|
|
nullary_ho_func \
|
|
null_char \
|
|
one_member \
|
|
ppc_bug \
|
|
pprint_test \
|
|
pprint_test2 \
|
|
pragma_c_code \
|
|
pragma_export \
|
|
pragma_import \
|
|
pragma_inline \
|
|
pretty_printing \
|
|
prince_frameopt \
|
|
promise_equivalent_clauses \
|
|
promise_equivalent_solutions_test \
|
|
promise_equiv_with_svars \
|
|
pure_mutable \
|
|
qual_adv_test \
|
|
qual_basic_test \
|
|
qual_is_test \
|
|
quantifier \
|
|
quantifier2 \
|
|
quoting_bug_test \
|
|
random_permutation \
|
|
random_simple \
|
|
rational_test \
|
|
recursive_main \
|
|
redoip_clobber \
|
|
relation_test \
|
|
remove_file \
|
|
reorder_di \
|
|
rev_arith \
|
|
reverse_arith \
|
|
rtc_bug \
|
|
rtree_test \
|
|
rtti_strings \
|
|
setjmp_test \
|
|
shift_test \
|
|
solve_quadratic \
|
|
solver_build_call \
|
|
solver_construction_init_test \
|
|
solver_disj_inits \
|
|
solver_ite_inits \
|
|
space \
|
|
stable_sort \
|
|
string_alignment \
|
|
string_alignment_bug \
|
|
string_loop \
|
|
string_string \
|
|
string_strip \
|
|
string_suffix_bug \
|
|
switch_detect \
|
|
system_sort \
|
|
target_mlobjs \
|
|
term_io_test \
|
|
term_to_univ_test \
|
|
test_bitset \
|
|
test_cord \
|
|
test_imported_no_tag \
|
|
test_promise_impure_implicit \
|
|
time_test \
|
|
tim_qual1 \
|
|
transform_value \
|
|
trans_intermod_user_equality \
|
|
transitive_inst_type \
|
|
trigraphs \
|
|
tuple_test \
|
|
tuple_test \
|
|
type_ctor_desc \
|
|
type_ctor_desc_manip \
|
|
type_info_order \
|
|
type_qual \
|
|
type_spec_ho_term \
|
|
type_spec_modes \
|
|
type_to_term_bug \
|
|
unify_existq_cons \
|
|
unify_expression \
|
|
unify_typeinfo_bug \
|
|
uniq_duplicate_call \
|
|
unused_float_box_test \
|
|
unusual_name_mutable \
|
|
user_compare \
|
|
user_defined_equality2 \
|
|
version_array_test \
|
|
write \
|
|
write_reg1 \
|
|
write_reg2 \
|
|
write_xml \
|
|
xmlable_test
|
|
|
|
# JAVA_PASS_PROGS lists those tests which will succeed in grade Java.
|
|
|
|
JAVA_PASS_PROGS= \
|
|
address_of_builtins \
|
|
brace \
|
|
c_write_string \
|
|
compare_spec \
|
|
constant_prop_2 \
|
|
contains_char \
|
|
constraint \
|
|
curry \
|
|
cut_test \
|
|
deforest_cc_bug \
|
|
division_test \
|
|
dot_separator \
|
|
dst_test \
|
|
existential_type_switch_opt \
|
|
failure_unify \
|
|
foreign_and_mercury \
|
|
foreign_type \
|
|
free_free_mode \
|
|
func_and_pred \
|
|
func_test \
|
|
higher_order_func_test \
|
|
higher_order_syntax \
|
|
ho_func_reg \
|
|
join_list \
|
|
mapped_module \
|
|
no_inline_builtins \
|
|
no_warn_singleton \
|
|
nondet_ctrl_vn \
|
|
nondet_copy_out \
|
|
pragma_inline \
|
|
qual_basic_test \
|
|
recursive_main \
|
|
reorder_di \
|
|
rev_arith \
|
|
reverse_arith \
|
|
solve_quadratic \
|
|
string_alignment \
|
|
string_loop \
|
|
string_suffix_bug \
|
|
system_sort \
|
|
target_mlobjs \
|
|
time_test
|
|
|
|
# Some tests only link in trailing grades.
|
|
ifeq "$(filter tr%,$(GRADE))" ""
|
|
TRAILED_PROGS =
|
|
else
|
|
TRAILED_PROGS = \
|
|
mutable_decl
|
|
endif
|
|
|
|
# Tests of the C#, MC++, and IL foreign language interfaces only
|
|
# work in IL grades
|
|
ifeq "$(filter il%,$(GRADE))" ""
|
|
DOTNET_PROGS =
|
|
else
|
|
DOTNET_PROGS = \
|
|
csharp_test
|
|
endif
|
|
|
|
# Tests of the Java foreign language interface only
|
|
# work in Java grades
|
|
ifeq "$(filter java%,$(GRADE))" ""
|
|
JAVA_PROGS =
|
|
else
|
|
JAVA_PROGS = \
|
|
java_test
|
|
endif
|
|
|
|
# Fact tables currently work only in the C grades.
|
|
# The foreign_type_assertion test is currently meaningful only in C grades.
|
|
# Mutables work properly only in C grades.
|
|
ifeq "$(filter il% java%,$(GRADE))" ""
|
|
C_ONLY_PROGS= \
|
|
factt \
|
|
factt_sort_test \
|
|
float_gv \
|
|
foreign_type_assertion
|
|
else
|
|
C_ONLY_PROGS=
|
|
endif
|
|
|
|
# constant_prop_2 fails in hl*prof* grades, due to a complicated phase
|
|
# ordering problem. The first simplify pass eliminates a call to
|
|
# private_builtin.typed_unify, but does not yet simplify the if-then-else
|
|
# which contains it; then at the end of that pass determinism analysis
|
|
# is rerun, and the condition is inferred to be det. Then dead proc
|
|
# elimination is run, and it does not eliminate link_error, since there
|
|
# is still a call to it. The second simplify pass notices that the
|
|
# condition is det, and simplifies the if-then-else, deleting the else part,
|
|
# so link_error is now dead. But dead proc elimination doesn't get run
|
|
# again, so we go ahead and emit a declaration for link_error, and in
|
|
# MLDS profiling grades also a reference, which causes the test case to fail.
|
|
|
|
# constant_prop_2 relies on deleting all references to an external predicate,
|
|
# but the appearance of the call in the caller puts a reference to its proc
|
|
# layout structure into the call sites array of its caller, even if the call
|
|
# is never made. We could fix this by skipping over call sites in unreachable
|
|
# code, but doing so would require duplicating, in deep_profiling.m, the code
|
|
# used by simplify.m to eliminate the unreachable code. Since the only profit
|
|
# would be to pass unrealistic test cases like constant_prop_2, this is not
|
|
# worth doing.
|
|
|
|
ifeq "$(findstring hl,$(GRADE))$(findstring prof,$(GRADE))" "hlprof"
|
|
PROF_PROGS =
|
|
else
|
|
ifeq "$(findstring profdeep,$(GRADE))" ""
|
|
PROF_PROGS = \
|
|
constant_prop_2
|
|
else
|
|
PROF_PROGS =
|
|
endif
|
|
endif
|
|
|
|
# These tests trigger a bug in lcc
|
|
ifeq "$(findstring lcc,$(shell $(MGNUC) -v 2>&1))" "lcc"
|
|
BROKEN_FOR_LCC_PROGS =
|
|
else
|
|
BROKEN_FOR_LCC_PROGS = \
|
|
bigtest \
|
|
rnd
|
|
endif
|
|
|
|
# These tests require the implementation to support closure layouts
|
|
CLOSURE_LAYOUT_PROGS = \
|
|
copy_pred \
|
|
copy_pred_2
|
|
|
|
# This test requires the implementation's representation of characters
|
|
# to be the same as their representation in files, which is not true
|
|
# for the IL and Java back-ends, which use Unicode internally.
|
|
ifeq "$(filter il% java%,$(GRADE))" ""
|
|
CHAR_REP_PROGS = special_char
|
|
else
|
|
CHAR_REP_PROGS =
|
|
endif
|
|
|
|
# We do not pass the following tests at all:
|
|
#
|
|
# XXX export_test2
|
|
# Fails in hl* grades. I think this never passed.
|
|
#
|
|
# XXX float_consistency:
|
|
# floats in Mercury aren't consistent -- see the comments at the
|
|
# top of library/float.m.
|
|
#
|
|
# XXX loop_inv_test0, loop_inv_test2:
|
|
# These test cases test some more sophisticated cases of loop invariant
|
|
# optimization which our current loop_inv pass is not capable of
|
|
# optimizing.
|
|
#
|
|
# XXX var_not_found -- mode error in automatically generated unification
|
|
# predicate. This test uses partially instantiated modes,
|
|
# which are not yet fully supported.
|
|
#
|
|
# XXX needs_init doesn't work yet in profiling grades.
|
|
#
|
|
# XXX compare_rep_array doesn't work because MR_COMPARE_BY_RTTI is
|
|
# not yet implemented for arrays.
|
|
#
|
|
# XXX puzzle_detism_bug exposes a bug in mode analysis
|
|
#
|
|
# XXX we fail some of the commented-out tests in write_binary
|
|
|
|
# The following tests are passed only in some grades.
|
|
|
|
# The following tests do not work in the the .profdeep grades.
|
|
# All of them, aside from backend_external, don't work because
|
|
# deep profiling cannot yet handle exceptions being caught and
|
|
# these test cases do that.
|
|
#
|
|
# backend_external fails because the predicates whose implementation
|
|
# is handwritten in C do not have the necessary proc_statics etc,
|
|
# defined.
|
|
|
|
ifeq "$(findstring profdeep,$(GRADE))" ""
|
|
NON_PROFDEEP_PROGS = \
|
|
allow_stubs \
|
|
backend_external \
|
|
dir_test \
|
|
test_array2d \
|
|
test_injection \
|
|
user_defined_equality \
|
|
write_binary
|
|
else
|
|
NON_PROFDEEP_PROGS =
|
|
endif
|
|
|
|
# compare_representation does not work in the MLDS grades (e.g. hlc.gc),
|
|
# because comparison of closures gives "Sorry, not implemented" when
|
|
# MR_HIGHLEVEL_CODE is set. Likewise for closure_arg_comparison.
|
|
#
|
|
# factt_non does not work in the MLDS grades because the code for nondet
|
|
# fact tables assumes that we're using the LLDS back-end. Also, fact tables
|
|
# and deep profiling do not (yet) mix.
|
|
#
|
|
# type_tables does not work in the MLDS grades because the test itself
|
|
# is a quick hack that assumes the use of the LLDS backend; it should
|
|
# be replaced by a test that exercises functionality enabled by type tables.
|
|
# However, this must wait for the implementation of that functionality.
|
|
|
|
ifeq "$(filter hl% il% java%,$(GRADE))" ""
|
|
ifeq "$(findstring profdeep,$(GRADE))" ""
|
|
BACKEND_PROGS_2 = \
|
|
factt_non
|
|
else
|
|
BACKEND_PROGS_2 =
|
|
endif
|
|
|
|
BACKEND_PROGS = \
|
|
$(BACKEND_PROGS_2) \
|
|
closure_arg_comparison \
|
|
compare_representation \
|
|
compare_rep_usereq \
|
|
stable_foreign \
|
|
type_tables
|
|
else
|
|
BACKEND_PROGS =
|
|
endif
|
|
|
|
# The MLDS back-end doesn't support nondet C in trailing grades,
|
|
# or in no-GC grades (except with --no-reclaim-heap-on-failure).
|
|
# We also don't support nondet C in deep profiling grades.
|
|
# These tests are also not supported in IL and Java grades,
|
|
# since those back-ends don't support the C interface at all.
|
|
# (XXX perhaps we should add analogous tests of the nondet IL, C#, MC++,
|
|
# and [eventually] Java interfaces?)
|
|
ifneq "$(filter il% java%,$(GRADE))" ""
|
|
NONDET_C_PROGS =
|
|
else
|
|
ifeq "$(findstring hl,$(GRADE))$(findstring .tr,$(GRADE))" "hl.tr"
|
|
NONDET_C_PROGS =
|
|
else
|
|
ifeq "$(findstring hl,$(GRADE))$(findstring .gc,$(GRADE))" "hl"
|
|
NONDET_C_PROGS =
|
|
else
|
|
ifneq "$(findstring profdeep,$(GRADE))" ""
|
|
NONDET_C_PROGS =
|
|
else
|
|
NONDET_C_PROGS = \
|
|
inline_nondet_pragma_c \
|
|
nondet_c \
|
|
nondet_pragma_c_bug
|
|
endif
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
# string_hash tests features of the Mercury C runtime.
|
|
# It requires too much memory to be used in non-GC grades.
|
|
ifeq "$(filter il% java%,$(GRADE))$(findstring gc,$(GRADE))" "gc"
|
|
C_AND_GC_ONLY_PROGS=string_hash
|
|
else
|
|
C_AND_GC_ONLY_PROGS=
|
|
endif
|
|
|
|
# Static linking doesn't work on Solaris in debug grades
|
|
# ('-ldl' doesn't work with static linking).
|
|
#
|
|
# Static linking (against the system libraries) doesn't
|
|
# work on MacOS X because the static versions of the
|
|
# libraries are not installed by default.
|
|
#
|
|
STATIC_LINK_PROGS =
|
|
ifneq "$(findstring apple-darwin,$(FULLARCH))" "apple-darwin"
|
|
ifneq "$(findstring solaris,$(FULLARCH))" "solaris"
|
|
# The `parse' test also links with the debug libraries,
|
|
# so it only works in LLDS grades.
|
|
ifeq "$(filter hl% java% il%,$(GRADE))" ""
|
|
STATIC_LINK_PROGS = parse
|
|
endif
|
|
endif
|
|
endif
|
|
|
|
# We currently test only a limited selection in grade java on this directory.
|
|
ifneq "$(findstring java,$(GRADE))" ""
|
|
PROGS = $(JAVA_PROGS) $(JAVA_PASS_PROGS)
|
|
else
|
|
PROGS = $(ORDINARY_PROGS) $(PROF_PROGS) $(BROKEN_FOR_LCC_PROGS) \
|
|
$(CLOSURE_LAYOUT_PROGS) $(NON_PROFDEEP_PROGS) \
|
|
$(BACKEND_PROGS) $(NONDET_C_PROGS) \
|
|
$(C_AND_GC_ONLY_PROGS) $(STATIC_LINK_PROGS) \
|
|
$(CHAR_REP_PROGS) $(C_ONLY_PROGS) \
|
|
$(DOTNET_PROGS) $(JAVA_PROGS) $(TRAILED_PROGS)
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
TESTS = $(PROGS)
|
|
SUBDIRS = typeclasses sub-modules exceptions purity
|
|
TESTS_DIR=..
|
|
include $(TESTS_DIR)/Mmake.common
|
|
|
|
# Module-specific options should go in Mercury.options so they
|
|
# can be found by `mmc --make'.
|
|
include Mercury.options
|
|
|
|
%.runtest: %.res ;
|
|
|
|
mapped_module.depend: Mercury.modules
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# For term_io_test, we want to run it once using the supplied input file.
|
|
# But we want to check that the output parses the same as the input did,
|
|
# so we also run it with the .exp file as the input.
|
|
|
|
term_io_test.fix_out: term_io_test term_io_test.exp
|
|
./term_io_test < term_io_test.exp > $@ 2>&1 || \
|
|
{ grep . $@ /dev/null; exit 1; }
|
|
|
|
term_io_test.res: term_io_test.out term_io_test.fix_out
|
|
@echo "Comparing term_io_test.{,fix_}out with term_io_test.exp,"
|
|
@echo " results in $@"
|
|
@-rm -f $@ term_io_test.res
|
|
@{ diff $(DIFF_OPTS) term_io_test.exp term_io_test.out > $@ && \
|
|
echo "term_io_test.out matched term_io_test.exp"; } && \
|
|
{ diff $(DIFF_OPTS) term_io_test.exp term_io_test.fix_out >> $@ && \
|
|
echo "term_io_test.fix_out matched term_io_test.exp"; } || \
|
|
{ echo "** term_io_test.{,fix_}out did not match the expected output"; \
|
|
cat $@; \
|
|
exit 1; }
|
|
|
|
nonascii.out: nonascii.data
|
|
|
|
nonascii.data: nonascii_gen
|
|
./nonascii_gen > nonascii.data
|
|
|
|
nonascii_gen: nonascii_gen.c
|
|
$(CC) nonascii_gen.c -o nonascii_gen
|
|
|
|
# no_fully_strict is expected to fail (it calls error/1).
|
|
# We also need to pipe the output through sed to avoid hard-coding
|
|
# dependencies on particular line numbers in the standard library source code.
|
|
no_fully_strict.out: no_fully_strict
|
|
if ./no_fully_strict > $@.tmp 2>&1; then \
|
|
grep . $@.tmp; \
|
|
exit 1; \
|
|
else \
|
|
sed -e 's/exception.m:[0-9]*/exception.m:NNNN/g' \
|
|
-e 's/require.m:[0-9]*/require.m:NNNN/g' \
|
|
< $@.tmp > $@; \
|
|
rm -f $@.tmp; \
|
|
fi
|
|
|
|
# For the constant_prop_1 test case, we test that constant propagation
|
|
# has been achieved by grepping the generated target code for particular
|
|
# patterns that will only arise if the Mercury compiler did the intended
|
|
# constant propagation.
|
|
constant_prop_1.c: constant_prop_1.c_date
|
|
grep foobar $@
|
|
grep 1234 $@
|
|
grep '5678\.0' $@
|
|
constant_prop_1.s: constant_prop_1.s_date
|
|
grep foobar $@
|
|
grep 1234 $@
|
|
grep '5678\.0' $@
|
|
constant_prop_1.pic_s: constant_prop_1.pic_s_date
|
|
grep foobar $@
|
|
grep 1234 $@
|
|
grep '5678\.0' $@
|
|
constant_prop_1.java: constant_prop_1.java_date
|
|
grep foobar $@
|
|
grep 1234 $@
|
|
grep '5678\.0' $@
|
|
constant_prop_1.il: constant_prop_1.il_date
|
|
grep foobar $@
|
|
grep 1234 $@
|
|
grep '5678\.0' $@
|
|
|
|
# Force intermod_unused_args2.m to be compiled and analysed before
|
|
# intermod_unused_args.m.
|
|
intermod_unused_args.c: intermod_unused_args2.c
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
dir_test.out: prepare_for_dir_test
|
|
|
|
prepare_for_dir_test:
|
|
rm -rf test_dir unwritable
|
|
touch unwritable
|
|
chmod -w unwritable
|
|
|
|
dir_test.clean: clean_dir_test
|
|
|
|
.PHONY: clean_dir_test
|
|
clean_dir_test:
|
|
rm -rf test_dir unwritable
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# dst_test checks various predicates associated with Daylight Savings.
|
|
# Since all the test data is based on Melbourne's DST conventions, the
|
|
# timezone environment variable TZ must be set accordingly.
|
|
|
|
ifneq "$(findstring java,$(GRADE))" ""
|
|
|
|
dst_test.out: dst_test.class
|
|
TZ="Australia/Melbourne" $(JAVA) dst_test > $@ 2>&1 || \
|
|
{ grep . $@ /dev/null; exit 1; }
|
|
|
|
else
|
|
|
|
dst_test.out: dst_test
|
|
TZ="Australia/Melbourne" ./$< > $@ 2>&1 || \
|
|
{ grep . $@ /dev/null; exit 1; }
|
|
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
clean_local:
|
|
rm -f target_mlobjs_c.o
|
|
|
|
realclean_local:
|
|
rm -f Mercury.modules
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PHONY: Mercury.modules
|
|
Mercury.modules:
|
|
$(MC) -f $(ALL_MCFLAGS) source_file_map.m
|
|
|
|
#-----------------------------------------------------------------------------#
|