[m-rev.] for review: --verbose-dump-mlds

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Mar 6 16:01:38 AEDT 2002


Estimated hours taken: 0.75
Branches: main

compiler/options.m:
	Add a new option `--verbose-mlds-dump'.

compiler/mercury_compile.m:
	When dumping the MLDS, only dump it to the .mlds_dump file if the
	stage was specified with `--verbose-mlds-dump'.  The `--mlds-dump'
	now only controls dumping of the .c_dump and .h_dump files.

doc/user_guide.texi:
	Document the new option.

Workspace: /home/ceres/fjh/mercury
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.237
diff -u -d -r1.237 mercury_compile.m
--- compiler/mercury_compile.m	3 Mar 2002 13:43:44 -0000	1.237
+++ compiler/mercury_compile.m	6 Mar 2002 04:58:38 -0000
@@ -4038,16 +4038,7 @@
 mercury_compile__maybe_dump_hlds(HLDS, StageNum, StageName) -->
 	globals__io_lookup_accumulating_option(dump_hlds, DumpStages),
 	(
-		{
-			list__member(StageNum, DumpStages)
-		;
-			list__member(StageName, DumpStages)
-		;
-			list__member("all", DumpStages)
-		;
-			string__append("0", StrippedStageNum, StageNum),
-			list__member(StrippedStageNum, DumpStages)
-		}
+		{ should_dump_stage(StageNum, StageName, DumpStages) }
 	->
 		{ module_info_name(HLDS, ModuleName) },
 		module_name_to_file_name(ModuleName, ".hlds_dump", yes,
@@ -4060,6 +4051,19 @@
 		[]
 	).
 
+:- pred should_dump_stage(string::in, string::in, list(string)::in) is semidet.
+should_dump_stage(StageNum, StageName, DumpStages) :-
+	(
+		list__member(StageNum, DumpStages)
+	;
+		list__member(StageName, DumpStages)
+	;
+		list__member("all", DumpStages)
+	;
+		string__append("0", StrippedStageNum, StageNum),
+		list__member(StrippedStageNum, DumpStages)
+	).
+
 :- pred mercury_compile__dump_hlds(string, module_info, io__state, io__state).
 :- mode mercury_compile__dump_hlds(in, in, di, uo) is det.
 
@@ -4088,19 +4092,22 @@
 :- mode mercury_compile__maybe_dump_mlds(in, in, in, di, uo) is det.
 
 mercury_compile__maybe_dump_mlds(MLDS, StageNum, StageName) -->
+	globals__io_lookup_bool_option(verbose, Verbose),
 	globals__io_lookup_accumulating_option(dump_mlds, DumpStages),
-	(
-		{
-			list__member(StageNum, DumpStages)
-		;
-			list__member(StageName, DumpStages)
-		;
-			list__member("all", DumpStages)
-		;
-			string__append("0", StrippedStageNum, StageNum),
-			list__member(StrippedStageNum, DumpStages)
-		}
-	->
+	globals__io_lookup_accumulating_option(verbose_dump_mlds,
+		VerboseDumpStages),
+	( { should_dump_stage(StageNum, StageName, DumpStages) } ->
+		maybe_write_string(Verbose, "% Dumping out MLDS as C...\n"),
+		maybe_flush_output(Verbose),
+		{ string__append_list(["_dump.", StageNum, "-", StageName],
+			DumpSuffix) },
+		mlds_to_c__output_mlds(MLDS, DumpSuffix),
+		maybe_write_string(Verbose, "% done.\n")
+	;
+		[]
+	),
+	( { should_dump_stage(StageNum, StageName, VerboseDumpStages) } ->
+		maybe_write_string(Verbose, "% Dumping out raw MLDS...\n"),
 		{ ModuleName = mlds__get_module_name(MLDS) },
 		module_name_to_file_name(ModuleName, ".mlds_dump", yes,
 			BaseFileName),
@@ -4108,10 +4115,7 @@
 			[BaseFileName, ".", StageNum, "-", StageName],
 			DumpFile) },
 		mercury_compile__dump_mlds(DumpFile, MLDS),
-
-		{ string__append_list(["_dump.", StageNum, "-", StageName],
-			DumpSuffix) },
-		mlds_to_c__output_mlds(MLDS, DumpSuffix)
+		maybe_write_string(Verbose, "% done.\n")
 	;
 		[]
 	).
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.357
diff -u -d -r1.357 options.m
--- compiler/options.m	23 Feb 2002 07:30:46 -0000	1.357
+++ compiler/options.m	6 Mar 2002 04:19:00 -0000
@@ -130,6 +130,7 @@
 		;	dump_hlds_alias
 		;	dump_hlds_options
 		;	dump_mlds
+		;	verbose_dump_mlds
 		;	generate_schemas
 		;	dump_rl
 		;	dump_rl_bytecode
@@ -631,6 +632,7 @@
 	dump_hlds_alias		-	string(""),
 	dump_hlds_options	-	string(""),
 	dump_mlds		-	accumulating([]),
+	verbose_dump_mlds	-	accumulating([]),
 	dump_rl			-	bool(no),
 	dump_rl_bytecode	-	bool(no),
 	sign_assembly		-	bool(no),
@@ -1121,6 +1123,8 @@
 long_option("dump-hlds-options",	dump_hlds_options).
 long_option("dump-mlds",		dump_mlds).
 long_option("mlds-dump",		dump_mlds).
+long_option("verbose-dump-mlds",	verbose_dump_mlds).
+long_option("verbose-mlds-dump",	verbose_dump_mlds).
 long_option("dump-rl",			dump_rl).
 long_option("dump-rl-bytecode",		dump_rl_bytecode).
 long_option("sign-assembly",		sign_assembly).
@@ -2132,12 +2136,15 @@
 		"\tcorresponding letter occurs in the option argument",
 		"\t(see the Mercury User's Guide for details).",
 		"--dump-mlds <stage number or name>",
-		"\tDump the MLDS (medium level intermediate representation) after",
-		"\tthe specified stage to `<module>.mlds_dump.<num>-<name>',",
-		"\t`<module>.c_dump.<num>-<name>',",
+		"\tDump the MLDS (medium level intermediate representation)",
+		"\tafter the specified stage, as C code,",
+		"\tto`<module>.c_dump.<num>-<name>',",
 		"\tand `<module>.h_dump.<num>-<name>'.",
 		"\tStage numbers range from 1-99.",
 		"\tMultiple dump options accumulate.",
+		"--verbose-dump-mlds <stage number or name>",
+		"\tDump the entire contents of the MLDS, after the specified",
+		"\tstage, to `<module>.mlds_dump.<num>-<name>'.",
 		"--dump-rl",
 		"\tOutput a human readable form of the compiler's internal",
 		"\trepresentation of the generated Aditi-RL code to",
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.297
diff -u -d -r1.297 user_guide.texi
--- doc/user_guide.texi	27 Feb 2002 17:41:11 -0000	1.297
+++ doc/user_guide.texi	6 Mar 2002 04:18:20 -0000
@@ -3972,19 +3972,23 @@
 U - unify and compare predicates.
 
 @sp 1
- at item @var{stage}
- at itemx --dump-mlds @var{stage}
+ at item --dump-mlds @var{stage}
 @findex --dump-mlds
 Dump the MLDS (a C-like intermediate representation) after
-the specified stage number or stage name.  The raw form of the
-MLDS is dumped to
- at file{@var{module}.mlds_dump. at var{num}- at var{name}}.
-The MLDS is also converted to a C source file/header file pair,
+the specified stage number or stage name.
+The MLDS is converted to a C source file/header file pair,
 which is dumped to @file{@var{module}.c_dump. at var{num}- at var{name}}
 and @file{@var{module}.h_dump. at var{num}- at var{name}}.
 Stage numbers range from 1 to 99; not all stage numbers are valid.
 The special stage name @samp{all} causes the dumping of all stages.
 Multiple dump options accumulate.
+
+ at sp 1
+ at item --verbose-dump-mlds @var{stage}
+ at findex --verbose-dump-mlds
+Dump the raw form of the MLDS, after
+the specified stage number or stage name, to
+ at file{@var{module}.mlds_dump. at var{num}- at var{name}}.
 
 @ifset aditi
 @sp 1

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list