[m-dev.] trivial diff: MLDS back-end: use --c-emit-loops option

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Nov 17 03:15:46 AEDT 1999


Estimated hours taken: 0.25

compiler/mlds_to_c.m:
	Make the code to optimize tail recursion by generating C loops
	conditional on the `--emit-c-loops' option (which is also used
	by the LLDS back-end).

Workspace: /d-drive/home/hg/fjh/mercury
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.14
diff -u -d -r1.14 mlds_to_c.m
--- compiler/mlds_to_c.m	1999/11/15 10:35:18	1.14
+++ compiler/mlds_to_c.m	1999/11/16 15:26:52
@@ -450,9 +450,9 @@
 		% so that we can use `continue;' inside the function body
 		% to optimize tail recursive calls.
 		%
-		% XXX tail recursion optimization should be disable-able
-		%
+		globals__io_lookup_bool_option(emit_c_loops, Emit_C_Loops),
 		(
+			{ Emit_C_Loops = yes },
 			{ statement_contains_statement(Body, Call) },
 			{ Call = mlds__statement(CallStmt, _) },
 			{ can_optimize_tailcall(FuncInfo, CallStmt) }
@@ -942,10 +942,11 @@
 		Results, IsTailCall) },
 	%
 	% Optimize directly-recursive tail calls
-	% XXX tail recursion optimization should be disable-able
 	%
 	{ CallerFuncInfo = func_info(Name, Params) },
+	globals__io_lookup_bool_option(emit_c_loops, Emit_C_Loops),
 	(
+		{ Emit_C_Loops = yes },
 		{ can_optimize_tailcall(CallerFuncInfo, Call) }
 	->
 		mlds_indent(Indent),
@@ -974,6 +975,7 @@
 		% Optimize general tail calls.
 		% We can't really do much here except to insert `return'
 		% as an extra hint to the C compiler.
+		% XXX these optimizations should be disable-able
 		%
 		% If Results = [], i.e. the function has `void' return type,
 		% then this would result in code that is not legal ANSI C

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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