[phc-internals] [phc commit] r1138 - in trunk: src/generated
src/generated_src src/pass_manager test/subjects/phc
codesite-noreply at google.com
codesite-noreply at google.com
Thu Apr 3 11:33:37 IST 2008
Author: paul.biggar
Date: Thu Apr 3 03:32:51 2008
New Revision: 1138
Added:
trunk/test/subjects/phc/disable.php
Modified:
trunk/src/generated/cmdline.c
trunk/src/generated/cmdline.h
trunk/src/generated_src/phc.ggo
trunk/src/pass_manager/Pass.h
Log:
Add a disable option. When investingating the performance improvement
of a pass, its much easier to have a means to disable it at the command
line, then to comment it out it phc.cpp and recompile.
Modified: trunk/src/generated/cmdline.c
==============================================================================
--- trunk/src/generated/cmdline.c (original)
+++ trunk/src/generated/cmdline.c Thu Apr 3 03:32:51 2008
@@ -66,6 +66,7 @@
" --list-passes List the passes to be run (default=off)",
" --dont-fail Dont fail on error (after parsing) (default=off)",
" --no-xml-attrs When dumping XML, omit node attributes
\n (default=off)",
+ " --disable=passname Disable the pass named 'passname'",
0
};
@@ -156,6 +157,7 @@
args_info->list_passes_given = 0 ;
args_info->dont_fail_given = 0 ;
args_info->no_xml_attrs_given = 0 ;
+ args_info->disable_given = 0 ;
}
static
@@ -205,6 +207,8 @@
args_info->list_passes_flag = 0;
args_info->dont_fail_flag = 0;
args_info->no_xml_attrs_flag = 0;
+ args_info->disable_arg = NULL;
+ args_info->disable_orig = NULL;
}
@@ -262,6 +266,9 @@
args_info->list_passes_help = gengetopt_args_info_full_help[35] ;
args_info->dont_fail_help = gengetopt_args_info_full_help[36] ;
args_info->no_xml_attrs_help = gengetopt_args_info_full_help[37] ;
+ args_info->disable_help = gengetopt_args_info_full_help[38] ;
+ args_info->disable_min = -1;
+ args_info->disable_max = -1;
}
@@ -415,6 +422,7 @@
free_multiple_string_field (args_info->udump_given,
&(args_info->udump_arg), &(args_info->udump_orig));
free_multiple_string_field (args_info->ddump_given,
&(args_info->ddump_arg), &(args_info->ddump_orig));
free_multiple_string_field (args_info->xdump_given,
&(args_info->xdump_arg), &(args_info->xdump_orig));
+ free_multiple_string_field (args_info->disable_given,
&(args_info->disable_arg), &(args_info->disable_orig));
for (i = 0; i < args_info->inputs_num; ++i)
@@ -515,6 +523,7 @@
write_into_file(outfile, "dont-fail", 0, 0 );
if (args_info->no_xml_attrs_given)
write_into_file(outfile, "no-xml-attrs", 0, 0 );
+ write_multiple_into_file(outfile,
args_info->disable_given, "disable", args_info->disable_orig, 0);
i = EXIT_SUCCESS;
@@ -788,6 +797,9 @@
if (check_multiple_option_occurrences(prog_name,
args_info->xdump_given, args_info->xdump_min, args_info->xdump_max, "'--xdump'"))
error = 1;
+ if (check_multiple_option_occurrences(prog_name,
args_info->disable_given, args_info->disable_min, args_info->disable_max, "'--disable'"))
+ error = 1;
+
/* checks for dependences among options */
@@ -1027,6 +1039,7 @@
struct generic_list * udump_list = NULL;
struct generic_list * ddump_list = NULL;
struct generic_list * xdump_list = NULL;
+ struct generic_list * disable_list = NULL;
int error = 0;
struct gengetopt_args_info local_args_info;
@@ -1090,6 +1103,7 @@
{ "list-passes", 0, NULL, 0 },
{ "dont-fail", 0, NULL, 0 },
{ "no-xml-attrs", 0, NULL, 0 },
+ { "disable", 1, NULL, 0 },
{ NULL, 0, NULL, 0 }
};
@@ -1471,6 +1485,17 @@
goto failure;
}
+ /* Disable the pass named 'passname'. */
+ else if (strcmp (long_options[option_index].name, "disable")
== 0)
+ {
+
+ if (update_multiple_arg_temp(&disable_list,
+ &(local_args_info.disable_given), optarg, 0, 0, ARG_STRING,
+ "disable", '-',
+ additional_error))
+ goto failure;
+
+ }
break;
case '?': /* Invalid option. */
@@ -1516,6 +1541,10 @@
&(args_info->xdump_orig), args_info->xdump_given,
local_args_info.xdump_given, 0 ,
ARG_STRING, xdump_list);
+ update_multiple_arg((void *)&(args_info->disable_arg),
+ &(args_info->disable_orig), args_info->disable_given,
+ local_args_info.disable_given, 0 ,
+ ARG_STRING, disable_list);
args_info->run_given += local_args_info.run_given;
local_args_info.run_given = 0;
@@ -1533,6 +1562,8 @@
local_args_info.ddump_given = 0;
args_info->xdump_given += local_args_info.xdump_given;
local_args_info.xdump_given = 0;
+ args_info->disable_given += local_args_info.disable_given;
+ local_args_info.disable_given = 0;
if (check_required)
{
@@ -1579,6 +1610,7 @@
free_list (udump_list, 1 );
free_list (ddump_list, 1 );
free_list (xdump_list, 1 );
+ free_list (disable_list, 1 );
cmdline_parser_release (&local_args_info);
return (EXIT_FAILURE);
Modified: trunk/src/generated/cmdline.h
==============================================================================
--- trunk/src/generated/cmdline.h (original)
+++ trunk/src/generated/cmdline.h Thu Apr 3 03:32:51 2008
@@ -125,6 +125,11 @@
const char *dont_fail_help; /**< @brief Dont fail on error (after
parsing) help description. */
int no_xml_attrs_flag; /**< @brief When dumping XML, omit node
attributes (default=off). */
const char *no_xml_attrs_help; /**< @brief When dumping XML, omit
node attributes help description. */
+ char ** disable_arg; /**< @brief Disable the pass named 'passname'. */
+ char ** disable_orig; /**< @brief Disable the pass named 'passname'
original value given at command line. */
+ int disable_min; /**< @brief Disable the pass named 'passname''s
minimum occurreces */
+ int disable_max; /**< @brief Disable the pass named 'passname''s
maximum occurreces */
+ const char *disable_help; /**< @brief Disable the pass
named 'passname' help description. */
unsigned int help_given ; /**< @brief Whether help was given. */
unsigned int full_help_given ; /**< @brief Whether full-help was
given. */
@@ -159,6 +164,7 @@
unsigned int list_passes_given ; /**< @brief Whether list-passes was
given. */
unsigned int dont_fail_given ; /**< @brief Whether dont-fail was
given. */
unsigned int no_xml_attrs_given ; /**< @brief Whether no-xml-attrs
was given. */
+ unsigned int disable_given ; /**< @brief Whether disable was given. */
char **inputs ; /**< @brief unamed options (options without names) */
unsigned inputs_num ; /**< @brief unamed options number */
Modified: trunk/src/generated_src/phc.ggo
==============================================================================
--- trunk/src/generated_src/phc.ggo (original)
+++ trunk/src/generated_src/phc.ggo Thu Apr 3 03:32:51 2008
@@ -39,5 +39,6 @@
option "list-passes" - "List the passes to be run" flag off hidden
option "dont-fail" - "Dont fail on error (after parsing)" flag off hidden
option "no-xml-attrs" - "When dumping XML, omit node attributes" flag
off hidden
+option "disable" - "Disable the pass named 'passname'" string
typestr="passname" multiple hidden optional
#option "marked-only" - "When used in conjunction with --dump-ast,
dump only AST nodes that are marked with a comment '//-DOT'" flag off
Modified: trunk/src/pass_manager/Pass.h
==============================================================================
--- trunk/src/pass_manager/Pass.h (original)
+++ trunk/src/pass_manager/Pass.h Thu Apr 3 03:32:51 2008
@@ -26,13 +26,14 @@
virtual void post_process () { }
private:
+ // Passes should not play with this, and should instead use
pass_is_enabled ().
bool enabled;
public:
bool is_enabled (Pass_manager* pm) { return enabled &&
pass_is_enabled (pm); }
void set_enabled (bool e) { enabled = e; }
- // Used for passes should use this
+ // Passes should use this to control their activation
virtual bool pass_is_enabled (Pass_manager* pm) { return true; }
void run_pass (IR* in, Pass_manager* pm)
Added: trunk/test/subjects/phc/disable.php
==============================================================================
--- (empty file)
+++ trunk/test/subjects/phc/disable.php Thu Apr 3 03:32:51 2008
@@ -0,0 +1,8 @@
+<?php
+
+ // check that disabling passes works
+
+ // options :: out_regex :: err_regex :: exit_code :: no subject
+ // { --disable=hir --list-passes:: .*hir\s+\(disabled.* :: :: 0 ::
false }
+
+?>
More information about the phc-internals
mailing list