[m-dev.] for review: added new option `--mark-tailcalls'

Julien Fischer juliensf at students.cs.mu.oz.au
Fri Feb 2 15:16:11 AEDT 2001


Estimated hours taken: 1.

Added an option `--mark-tailcalls' which makes detection of tailcalls
in the MLDS backend optional.  If this is not turned on then the 
tailcalls will not be optimized later on.  This is turned off in
optimization level 0 and when the Java grade is being used; for other
optimization levels it is on.

compiler/handle_options.m:
compiler/mercury_compile.m:
compiler/options.m:
	Added new option `--mark-tailcalls'.

Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.100
diff -u -r1.100 handle_options.m
--- compiler/handle_options.m	2001/01/29 01:54:13	1.100
+++ compiler/handle_options.m	2001/02/02 04:03:59
@@ -297,7 +297,7 @@
 	),
 	% Generating Java implies high-level code, turning off nested functions,
 	% using copy-out for both det and nondet output arguments,
-	% using no tags and no static ground terms.
+	% using no tags, not marking tailcalls and no static ground terms.
 	% XXX no static ground terms should be eliminated in a later
 	%     version.
 	( { Target = java } ->
@@ -306,6 +306,7 @@
 		globals__io_set_option(nondet_copy_out, bool(yes)),
 		globals__io_set_option(det_copy_out, bool(yes)),
 		globals__io_set_option(num_tag_bits, int(0)),
+		globals__io_set_option(mark_tailcalls, bool(no)),
 		globals__io_set_option(static_ground_terms, bool(no))
 	;
 		[]
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.190
diff -u -r1.190 mercury_compile.m
--- compiler/mercury_compile.m	2001/01/29 01:54:09	1.190
+++ compiler/mercury_compile.m	2001/02/02 04:03:59
@@ -2530,11 +2530,15 @@
 	maybe_report_stats(Stats),
 	mercury_compile__maybe_dump_mlds(MLDS10, "10", "rtti"),
 
-	% XXX this pass should be conditional on a compilation option
-
-	maybe_write_string(Verbose, "% Detecting tail calls...\n"),
-	ml_mark_tailcalls(MLDS10, MLDS20),
-	maybe_write_string(Verbose, "% done.\n"),
+	globals__io_lookup_bool_option(mark_tailcalls, MarkTailCalls),
+	( { MarkTailCalls = yes } ->
+		maybe_write_string(Verbose, 
+			"% Detecting tail calls...\n"),
+		ml_mark_tailcalls(MLDS10, MLDS20),
+		maybe_write_string(Verbose, "% done.\n")
+	;
+		{ MLDS10 = MLDS20 }
+	),
 	maybe_report_stats(Stats),
 	mercury_compile__maybe_dump_mlds(MLDS20, "20", "tailcalls"),
 
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.306
diff -u -r1.306 options.m
--- compiler/options.m	2001/01/29 01:54:11	1.306
+++ compiler/options.m	2001/02/02 04:03:59
@@ -368,6 +368,8 @@
 		;	simple_neg
 		;	follow_vars
 		;	allow_hijacks
+	%	- MLDS
+		;	mark_tailcalls
 	%	- LLDS
 		;	common_data
 		;	optimize	% also used for MLDS->MLDS optimizations
@@ -755,7 +757,8 @@
 	simple_neg		-	bool(no),
 	follow_vars		-	bool(no),
 	allow_hijacks		-	bool(yes),
-
+% MLDS
+	mark_tailcalls		- 	bool(no),
 % LLDS
 	common_data		-	bool(no),
 	optimize		-	bool(no),
@@ -1181,6 +1184,7 @@
 % you can't use both at the same time it doesn't really matter.
 long_option("mlds-optimize",		optimize).
 long_option("mlds-optimise",		optimize).
+long_option("mark-tailcalls",		mark_tailcalls).
 
 % LLDS optimizations
 long_option("common-data",		common_data).
@@ -1451,7 +1455,8 @@
 	optimize_delay_slot	-	bool(DelaySlot),
 	follow_vars		-	bool(yes),
 	middle_rec		-	bool(yes),
-	emit_c_loops		-	bool(yes)
+	emit_c_loops		-	bool(yes),
+	mark_tailcalls		-	bool(yes)
 	% dups?
 ]) :-
 	getopt__lookup_bool_option(OptionTable, have_delay_slot, DelaySlot).
@@ -2527,7 +2532,9 @@
 	io__write_string("\n    MLDS -> MLDS optimizations:\n"),
 	write_tabbed_lines([
 		"--no-mlds-optimize",
-		"\tDisable the MLDS->MLDS optimization passes."
+		"\tDisable the MLDS->MLDS optimization passes.",
+		"--mark-tailcalls",
+		"\tMark tailcalls that can be optimized."
 	]).
 
 

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list