Permalink
Browse files

[imcc] enable -O[12p] options again

Rename imcc_set_debug_api() to imcc_set_flags_api() to set
verbosity, debug flags and optimizer flags at once.

Remove unused internal imcc->IMCC_DEBUG flags.

-v prints now also the optimizer_level.

Document internal imcc_set_verbosity() as unused.

Makefile: add testOp, disable testexec (unused)

Add missing documentation to docs/running.pod and docs/binaries/parrot.pod
which is essentially the same. docs/running.pod should include more high-level
info. Remove gcdebug runcore documentation (unused).

Fix enabling parrot --imcc-debug flags.

Add Parrot_imcc_dflags and Parrot_imcc_opt_flags enums to include/imcc/api.h
for the frontends.

Mark t/op/calling.t test 63 as failing with -O1. (TODO)
This is a bad test, assuming an unoptimized layout.
  • Loading branch information...
1 parent 4d02cc7 commit 4758059e51c985b95f80ca6c035dfa5f4a1def98 Reini Urban committed Feb 26, 2014
View
@@ -205,8 +205,11 @@ imcc_preprocess_file_api(Parrot_PMC interp_pmc, Parrot_PMC compiler,
/*
-=item C<Parrot_Int imcc_set_debug_api(Parrot_PMC interp_pmc, Parrot_PMC
-compiler, Parrot_Int imccflags)>
+=item C<Parrot_Int imcc_set_flags_api(Parrot_PMC interp_pmc, Parrot_PMC
+compiler, Parrot_Int debug, Parrot_Int opt)>
+
+Public interface to imcc_set_verbosity, imcc_set_optimization_level and
+imcc_set_debug_mode. Overwrites the imcc flags.
=cut
@@ -215,17 +218,17 @@ compiler, Parrot_Int imccflags)>
PARROT_EXPORT
PARROT_WARN_UNUSED_RESULT
Parrot_Int
-imcc_set_debug_api(Parrot_PMC interp_pmc, Parrot_PMC compiler,
- Parrot_Int imccflags)
+imcc_set_flags_api(Parrot_PMC interp_pmc, Parrot_PMC compiler,
+ Parrot_Int debug, Parrot_Int opt)
{
- ASSERT_ARGS(imcc_set_debug_api)
+ ASSERT_ARGS(imcc_set_flags_api)
IMCC_API_CALLIN(interp_pmc, interp)
imc_info_t * imcc = (imc_info_t *)VTABLE_get_pointer(interp, compiler);
- if (imccflags & PARROT_IMCC_VERBOSE)
+ if (debug & PARROT_IMCC_VERBOSE)
imcc_set_verbosity(imcc, 1);
- /* >> 16 translates public PARROT_IMCC_* flags to internal imcc->debug flags. */
- imcc_set_debug_mode(imcc, imccflags >> 16, imccflags & PARROT_IMCC_PARSER);
+ imcc_set_debug_mode(imcc, debug, debug & PARROT_IMCC_DEBUG_PARSER); /* i.e. yydebug */
+ imcc->optimizer_level = opt;
IMCC_API_CALLOUT(interp_pmc, interp)
}
View
@@ -385,11 +385,11 @@ SymReg* get_pasm_reg(ARGMOD(imc_info_t * imcc), ARGIN(const char *name))
typedef enum _enum_opt {
OPT_NONE,
- OPT_PRE,/* 0x001 */
+ OPT_PRE, /*0x001 */
OPT_CFG = 0x002,
OPT_SUB = 0x004,
- OPT_PASM = 0x100,
- OPT_J = 0x200
+ OPT_PASM = 0x100
+ /* OPT_J = 0x200 */
} enum_opt_t;
struct nodeType_t;
@@ -483,7 +483,6 @@ struct _imc_info_t {
AsmState asm_state;
SymHash ghash;
jmp_buf jump_buf; /* The jump for error handling */
- int IMCC_DEBUG;
int cnr;
int debug;
int dont_optimize;
@@ -5061,7 +5061,8 @@ determine_input_file_type(ARGMOD(imc_info_t * imcc), ARGIN(STRING *sourcefile))
}
if (imcc->verbose) {
- IMCC_info(imcc, 1, "debug = 0x%x\n", imcc->debug);
+ IMCC_info(imcc, 1, "debug = 0x%x, optim = 0x%x\n", imcc->debug,
+ imcc->optimizer_level);
IMCC_info(imcc, 1, "Reading %Ss\n", sourcefile);
}
View
@@ -238,6 +238,8 @@ imcc_set_verbosity(ARGMOD(imc_info_t *imcc), INTVAL verbose)
Set the optimization level. C<opts> is a string with character code flags.
+Unused.
+
=cut
*/
@@ -2379,17 +2379,21 @@ testj : test_prep
testr : test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS) -r $(RUNCORE_TEST_FILES)
-# normal core, optimization level 1
+# normal core, optimization level 1 (one error)
testO1 : test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS) -O1 $(RUNCORE_TEST_FILES)
# optimization level 2 has some errors
testO2 : test_prep
$(PERL) t/harness $(EXTRA_TEST_ARGS) -O2 $(RUNCORE_TEST_FILES)
-# test the EXEC stuff
-testexec: test_prep
- $(PERL) t/harness $(EXTRA_TEST_ARGS) --run-exec $(RUNCORE_TEST_FILES)
+# -Op: -O2 for PASM
+testOp : test_prep
+ $(PERL) t/harness $(EXTRA_TEST_ARGS) -Op $(RUNCORE_TEST_FILES)
+
+# test --run-exec
+#testexec: test_prep
+# $(PERL) t/harness $(EXTRA_TEST_ARGS) --run-exec $(RUNCORE_TEST_FILES)
# Test that need to be compiled by the C-compiler
src_tests : test_prep
View
@@ -70,12 +70,12 @@ information about these options, I<see> the "About runcores" section in F<docs/r
Select the runcore. The following cores are available in Parrot, but not all
may be available on your system:
- slow, bounds bounds checking core (default)
+ fast bare-bones core without bounds-checking or
+ context-updating (default)
- fast bare-bones core without bounds-checking or
- context-updating
+ slow, bounds bounds checking core
- trace bounds checking core with trace info
+ trace bounds checking core with trace info
(see 'parrot --help-debug')
profiling see F<docs/dev/profiling.pod>
@@ -185,6 +185,28 @@ number of OS threads. Minimum number: 2
=over 4
+=item B<-O>[level]
+
+Valid optimizer levels: C<-O>, C<-O1>, C<-O2>, C<-Op>
+
+-O1 enables the pre_optimizer, runs before control flow graph (CFG) is built.
+It includes strength reduction and rewrites certain if/branch/label constructs.
+
+-O2 runs afterwards, handles constant propagation, jump optimizations,
+removal of unused labels and dead code.
+
+-Op> applies -O2 to pasm files also.
+
+The old options -Op, -Oc and -Oj are currently ineffective.
+
+-O defaults to -O1.
+
+=item B<-d>[=HEXFLAGS]
+
+=item B<--imcc-debug>[=HEXFLAGS]
+
+Turn on compiler debug flags. I<See> C<parrot --help-debug> for available flag bits.
+
=item B<-E>
=item B<--pre-process-only>
@@ -229,6 +251,10 @@ primarily, for tests.
=item B<--yydebug> Turn on yydebug in F<yacc>/F<bison>.
+=item B<-v>
+
+=item B<--verbose> Turn on compiler verbosity.
+
=back
=head2 <file>
View
@@ -35,10 +35,30 @@ Turn on the I<--gc-debug> flag.
=head1 OPTIONS
-=head2 Assembler options
+=head2 Assembler/compiler options
=over 4
+=item -O[level]
+
+Valid optimizer levels: C<-O>, C<-O1>, C<-O2>, C<-Op>, C<-Oc>
+
+=item B<-O>[level]
+
+Valid optimizer levels: C<-O>, C<-O1>, C<-O2>
+
+C<-O1> enables the pre_optimizer, runs before control flow graph (CFG) is built.
+It includes strength reduction and rewrites certain if/branch/label constructs.
+
+C<-O2> runs afterwards, handles constant propagation, jump optimizations,
+removal of unused labels and dead code.
+
+C<-Op> applies C<-O2> to pasm files also.
+
+The old options C<-Oc> and C<-Oj> are currently ineffective.
+
+C<-O> defaults to C<-O1>.
+
=item -a, --pasm
Assume PASM input on stdin.
@@ -76,6 +96,16 @@ disc and run. This is mainly needed for tests.
Turn on yydebug in F<yacc>/F<bison>.
+=item -v, --verbose
+
+Turn on compiler verbosity.
+
+=item B<-d>[=HEXFLAGS]
+
+=item B<--imcc-debug>[=HEXFLAGS]
+
+Turn on compiler debug flags. I<See> C<parrot --help-debug> for available flag bits.
+
=item -V, --version
Print version information and exit.
@@ -101,12 +131,18 @@ debugging. See L<About runcores> for details.
Select the runcore. The following cores are available in Parrot, but not all
may be available on your system:
- slow, bounds bounds checking core (default)
- gcdebug performs a full GC run before every op dispatch (good for
- debugging GC problems)
+ fast bare-bones core without bounds-checking or
+ context-updating (default)
+
+ slow, bounds bounds checking core
+
trace bounds checking core w/ trace info (see 'parrot --help-debug')
+
profiling see F<docs/dev/profilling.pod>
+ subprof subroutine-level profiler
+ (see POD in F<src/runcore/subprof.c>)
+
The C<jit>, C<switch-jit>, and C<cgp-jit> options are currently aliases for the
C<fast>, C<switch>, and C<cgp> options, respectively. We do not recommend
their use in new code; they will continue working for existing code per our
@@ -203,15 +239,15 @@ no single runcore will perform optimally on all architectures (or even for all
problems on a given architecture), and partly because some of the runcores have
specific debugging and tracing capabilities.
-In the default "slow" runcore, each opcode is a separate C function.
+In the "slow" or "bounds" runcore, each opcode is a separate C function.
That's pretty easy in pseudocode:
slow_runcore( op ):
while ( op ):
op = op_function( op )
check_for_events()
-The GC debugging runcore is similar:
+The old GC debugging runcore was similar:
gcdebug_runcore( op ):
while ( op ):
@@ -250,6 +286,6 @@ full bounds checking, and also printing runtime information to stderr.
=head1 FILES
-F<main.c>
+F<frontend/parrot/main.c>
=cut
View
@@ -39,7 +39,8 @@ struct init_args_t {
Parrot_Int have_pasm_file;
Parrot_Int turn_gc_off;
Parrot_Int preprocess_only;
- Parrot_Int imccflags;
+ Parrot_Int imcc_dflags;
+ Parrot_Int imcc_opts;
};
extern int Parrot_set_config_hash(Parrot_PMC interp_pmc);
@@ -260,9 +261,10 @@ run_imcc(Parrot_PMC interp, Parrot_String sourcefile, ARGIN(struct init_args_t *
imcc_get_pasm_compreg_api(interp, 1, &pasm_compiler)))
show_last_error_and_exit(interp);
if (flags->preprocess_only) {
- if (flags->imccflags) {
- r = imcc_set_debug_api(interp, pir_compiler, flags->imccflags);
- if (!r) exit(EXIT_FAILURE);
+ if (flags->imcc_dflags || flags->imcc_opts) {
+ if (!imcc_set_flags_api(interp, pir_compiler, flags->imcc_dflags,
+ flags->imcc_opts))
+ exit(EXIT_FAILURE);
}
r = imcc_preprocess_file_api(interp, pir_compiler, sourcefile);
exit(r ? EXIT_SUCCESS : EXIT_FAILURE);
@@ -272,9 +274,9 @@ run_imcc(Parrot_PMC interp, Parrot_String sourcefile, ARGIN(struct init_args_t *
const Parrot_PMC compiler = pasm_mode ? pasm_compiler : pir_compiler;
Parrot_PMC pbc;
- if (flags->imccflags) {
- r = imcc_set_debug_api(interp, compiler, flags->imccflags);
- if (!r) exit(EXIT_FAILURE);
+ if (flags->imcc_dflags || flags->imcc_opts) {
+ if (!imcc_set_flags_api(interp, compiler, flags->imcc_dflags, flags->imcc_opts))
+ exit(EXIT_FAILURE);
}
if (!imcc_compile_file_api(interp, compiler, sourcefile, &pbc))
show_last_error_and_exit(interp);
@@ -758,7 +760,8 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
args->outfile = NULL;
args->sourcefile = NULL;
args->preprocess_only = 0;
- args->imccflags = 0;
+ args->imcc_dflags = 0;
+ args->imcc_opts = 0;
if (argc == 1) {
usage(stderr);
@@ -794,24 +797,25 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
break;
case 'd':
if (opt.opt_arg && is_all_hex_digits(opt.opt_arg))
- args->imccflags = (Parrot_Int)(strtoul(opt.opt_arg, NULL, 16) << 16);
+ args->imcc_dflags = (Parrot_Int)strtoul(opt.opt_arg, NULL, 16);
else
- args->imccflags = PARROT_IMCC_VERBOSE;
+ args->imcc_dflags = PARROT_IMCC_VERBOSE;
break;
case 'O':
if (!opt.opt_arg || !*opt.opt_arg || opt.opt_arg[0] == '0') {
- args->imccflags |= PARROT_IMCC_OPT1;
+ args->imcc_opts |= PARROT_IMCC_OPT_PRE;
break;
}
if (strchr(opt.opt_arg, 'p'))
- args->imccflags |= PARROT_IMCC_OPT1;
+ args->imcc_opts |= PARROT_IMCC_OPT_PASM;
if (strchr(opt.opt_arg, 'c'))
- args->imccflags |= PARROT_IMCC_OPT2;
+ args->imcc_opts |= PARROT_IMCC_OPT_SUB;
if (strchr(opt.opt_arg, '1'))
- args->imccflags |= PARROT_IMCC_OPT1;
+ args->imcc_opts |= PARROT_IMCC_OPT_PRE;
if (strchr(opt.opt_arg, '2'))
- args->imccflags |= (PARROT_IMCC_OPT1|PARROT_IMCC_OPT2);
+ args->imcc_opts |= (PARROT_IMCC_OPT_PRE|PARROT_IMCC_OPT_CFG);
break;
+
case '.': /* Give Windows Parrot hackers an opportunity to
* attach a debuggger. */
fgetc(stdin);
@@ -858,7 +862,7 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
args->have_pbc_file = 1;
break;
case OPT_GC_DEBUG:
-#if DISABLE_GC_DEBUG
+#if 0 && DISABLE_GC_DEBUG
Parrot_warn(interp, 0xFFFF,
"PARROT_GC_DEBUG is set but the binary was compiled "
"with DISABLE_GC_DEBUG.");
@@ -885,10 +889,10 @@ parseflags(Parrot_PMC interp, int argc, ARGIN(const char *argv[]),
args->preprocess_only = 1;
break;
case 'v': /* same as -d */
- args->imccflags |= PARROT_IMCC_VERBOSE;
+ args->imcc_dflags |= PARROT_IMCC_VERBOSE;
break;
- case 'y': /* same as -d400 */
- args->imccflags |= PARROT_IMCC_PARSER;
+ case 'y': /* same as -d4 */
+ args->imcc_dflags |= PARROT_IMCC_DEBUG_PARSER;
break;
default:
/* languages handle their arguments later (after being initialized) */
Oops, something went wrong.

0 comments on commit 4758059

Please sign in to comment.