Commit Graph

3 Commits

Author SHA1 Message Date
Zoltan Somogyi
33eb3028f5 Clean up the tests in half the test directories.
tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
    Make these tests use four-space indentation, and ensure that
    each module is imported on its own line. (I intend to use the latter
    to figure out which subdirectories' tests can be executed in parallel.)

    These changes usually move code to different lines. For the debugger tests,
    specify the new line numbers in .inp files and expect them in .exp files.
2015-02-14 20:14:03 +11:00
Zoltan Somogyi
bea43284e7 Implement lookup disjunctions and model_non lookup switches.
Estimated hours taken: 24
Branches: main

Implement lookup disjunctions and model_non lookup switches.

compiler/ml_disj_gen.m:
	New module that looks after code generation for disjunctions.
	Note the link to disj_gen.m.

	Part of the code in it comes from ml_code_gen.m, but the part that
	implements lookup disjunctions is new, and its bulk is what justifies
	a separate module.

	Even the old code has been restructured to make the decision
	about whether this is a model_non disj or not just once, instead
	of once for every single disjunct.

compiler/ml_backend.m:
compiler/notes/compiler_design.html:
	Mention the new module.

compiler/mlds.m:
	Use a purpose-specific type instead of a bool to represent
	whether a loop can loop zero times.

compiler/ml_code_gen.m:
	Remove the code moved to ml_disj_gen.m.

	Improve the style of the ml_gen_maybe_convert_goal_code_model
	predicate.

compiler/ml_lookup_switch.m:
	Implement model_non lookup switches.

	Note the link to lookup_switch.m.

	Give better names to some predicates and variables.

	Remove the predicates moved to ml_code_util.m, goal_form.m and
	ml_util.m.

compiler/switch_util.m:
	When a switch arm has several solutions, store the first solution
	separately. This assures statically that there IS a first solution
	(which a simple list of solutions does not), and prepares the first
	solution for its special treatment (it is stored in a different vector
	than the later solutions, and in the LLDS backend, we take the liveness
	after the arms from it).

compiler/ml_code_util.m:
	Move here the predicates previously in ml_lookup_switch.m that are now
	needed by ml_disj_gen.m as well. Make it possible to generate
	constants for individual arms, as well as individual field assigns,
	since ml_disj_gen.m now needs this capability.

compiler/goal_form.m:
	Move here a suitably generalized version of the two previously
	backend-specific versions of the predicates that test goals to see
	if they can be part of a lookup switch or disjunction.

compiler/ml_util.m:
	Move here from ml_lookup_switch.m a predicate now needed by
	ml_disj_gen.m as well.

compiler/lookup_util.m:
	Remove the predicate moved to goal_form.m.

	Make it possible to generate constants for a single disjunct.

	Avoid uselessly wrapping up a return argument in a yes().

compiler/disj_gen.m:
compiler/lookup_switch.m:
	Move a cheap test significantly earlier, to avoid wasting time
	on disjunctions on which it would fail.

	Conform to the changes in the backend libraries.

	In lookup_switch.m, note the paper that describes the code generation
	scheme followed by the module.

compiler/mlds_to_c.m:
	Conform to the changes above.

	When generating scalar and vector static cells, indicate the row
	numbers in comments, since without this, it is too difficult to check
	visually whether the generated code is correct.

compiler/mlds_to_java.m:
	Conform to the changes above.

	Improve the style of a big predicate.

compiler/ml_accurate_gc.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tailcall.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
	Conform to the changes above.

tests/hard_coded/dense_lookup_switch_non.{m,exp}:
	Make this test case significantly more comprehensive, by making it
	test all combinations of the presence and absence of both range checks
	and bit vector checks.

tests/hard_coded/lookup_switch_simple_bitvec.{m,exp}:
	This test was not doing its job, because the switch had too few arms
	for ml_switch_gen.m to decide that a lookup switch was worthwhile.
	It succeeded, but did not exercise the lookup switch code that existed
	in the MLDS backend before this diff. Fix this by adding more arms.
2009-10-02 03:55:36 +00:00
Zoltan Somogyi
00ea415659 Implement scalar and vector global data for the MLDS backend, modelled on
Estimated hours taken: 32
Branches: main

Implement scalar and vector global data for the MLDS backend, modelled on
the implementation of global data for the LLDS backend. Use scalar global
data to eliminate redundant copies of static memory cells. Use vector global
data to implement lookup switches, and to implement string switches more
efficiently.

The diff reduces the compiler executable's size by 3.3% by eliminating
duplicate copies of static cells. The diff can reduce the sizes of object files
not only through this reduction in the size of read-only data, but also through
reductions in the size of the needed relocation info: even in the absence of
duplicated cells, using one global variable that holds an array of all the
cells of the same type requires less relocation info than a whole bunch of
separate global variables each holding one cell. If C debugging is enabled,
we can also expect a significant reduction in the size of the debug information
stored in object files AND in executables, for the same reason. (This was the
original motivation for scalar static data on the LLDS backend; the large
amount of relocation information in object files, especially if Mercury
debugging was enabled, led to long link times.)

compiler/ml_global_data.m:
	Make the changes described above.

compiler/ml_lookup_switch.m:
	This new module implements lookup switches for the MLDS backend.
	For now, it implements only model_det and model_semi switches.

compiler/ml_switch_gen.m:
	Call the new module when appropriate.

	Do not require the switch generation methods that never generate
	definitions to return an empty list of definitions.

compiler/ml_backend.m:
	Add the new module.

compiler/notes/compiler_design.html:
	Mention the new module, and fix some documentation rot.

compiler/mlds.m:
	Extend the relevant types to allow the generated MLDS code to refer
	to both scalar and vector global data.

	Move a predicate that belongs here from ml_code_util.m.

	Rename a predicate to avoid ambiguity with its own return type.

	Give the functors of some types distinguishing prefixes.

compiler/ml_util.m:
	Replace some semidet predicates with functions returning bool,
	since the semidet predicates silently did the wrong thing on the new
	additions to the MLDS.

compiler/ml_code_gen.m:
	Ensure that we do not generate references to scalar and vector common
	cells on platforms which do not (yet) support them. At the moment,
	they are supported only when generating C.

	Put some code into a predicate of its own.

compiler/builtin_ops.m:
	Extend the type that represents array elements to allow them to be
	structures, which they are for vector globals.

compiler/ml_code_util.m:
	Add some new utility predicates and functions.

	Move some predicates that are now needed in more than one module here.

	Remove the predicates moved to mlds.m.

	Conform to the changes above.

compiler/ml_string_switch.m:
compiler/string_switch.m:
	Instead of two separate arrays, use one array of structures (a static
	vector), since they way, the string and the next slot indicator,
	which are accesses together, are next to each other and thus
	in the same cache block.

compiler/lookup_switch.m:
compiler/switch_util.m:
	Move several predicates from lookup_switch.m to switch_util.m,
	since now ml_lookup_switch.m needs them too. Parameterize the moved
	predicates as needed.

	Conform to the changes above.

compiler/llds.m:
	Add prefixes to some functor names to avoid ambiguities.

compiler/llds_out.m:
compiler/lookup_util.m:
compiler/mercury_compile.m:
	Minor style improvements.

compiler/global_data.m:
	Minor cleanups. Give names to some data types, and add prefixes to some
	field names.

	Conform to the changes above.

compiler/jumpopt.m:
	Minor style improvements.

	Conform to the changes above.

compiler/opt_debug.m:
	Fix some misleading variable names.

compiler/reassign.m:
	Factor out some duplicated code.

compiler/ll_pseudo_type_info.m:
compiler/ml_closure_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tag_switch.m:
compiler/ml_tailcall.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/rtti_to_mlds.m:
compiler/stack_layout.m:
compiler/unify_gen.m:
	Conform to the changes above.

tests/hard_coded/lookup_switch_simple.{m,exp}:
tests/hard_coded/lookup_switch_simple_bitvec.{m,exp}:
tests/hard_coded/lookup_switch_simple_non.{m,exp}:
tests/hard_coded/lookup_switch_simple_opt.{m,exp}:
	New test cases to exercise the new functionality.

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
	Enable the new tests.
2009-09-21 04:09:06 +00:00