cvsuser 03/02/08 06:41:36
Modified: languages/imcc ChangeLog TestCompiler.pm cfg.c debug.c imc.c
imc.h instructions.c main.c optimizer.c
languages/imcc/t harness
Log:
imcc-cfg #2 - s. ChangeLog
Revision Changes Path
1.10 +8 -0 parrot/languages/imcc/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/ChangeLog,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- ChangeLog 7 Feb 2003 17:04:13 -0000 1.9
+++ ChangeLog 8 Feb 2003 14:41:28 -0000 1.10
@@ -1,3 +1,11 @@
+- 2003-02-08 leo
+ * version 0.0.9.13
+ * pass -Ox on to tests
+ * remove dead code
+ * remove branch to next ins
+ * fix use_count for invoke and .local vars
+ * don't remove unused global labels
+
- 2003-02-07 leo
* first step for bsr handling in the CFG
local bsrs (target in the same compilation unit) can
1.4 +1 -0 parrot/languages/imcc/TestCompiler.pm
Index: TestCompiler.pm
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/TestCompiler.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- TestCompiler.pm 27 Jan 2003 17:06:45 -0000 1.3
+++ TestCompiler.pm 8 Feb 2003 14:41:28 -0000 1.4
@@ -78,6 +78,7 @@
my $TEST_PROG_ARGS = $ENV{TEST_PROG_ARGS} || '';
if ($gen_pasm) {
+ $TEST_PROG_ARGS =~ s/-O.//;
system("./imcc ${TEST_PROG_ARGS} $opt -o $out_f $by_f");
}
elsif ($TEST_PROG_ARGS =~ /-c/) {
1.14 +6 -0 parrot/languages/imcc/cfg.c
Index: cfg.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/cfg.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- cfg.c 7 Feb 2003 17:04:13 -0000 1.13
+++ cfg.c 8 Feb 2003 14:41:28 -0000 1.14
@@ -277,6 +277,12 @@
ins = curr;
}
}
+ /* invoke implicitely uses P0, so mark it doin so */
+ else if (!strcmp(ins->op, "invoke")) {
+ SymReg * p0 = mk_pasm_reg("P0");
+ add_instruc_reads(ins, p0);
+ p0->use_count++;
+ }
}
if (IMCC_DEBUG & DEBUG_CFG) {
debug(DEBUG_CFG, "\nAfter propagate_alias\n");
1.10 +9 -5 parrot/languages/imcc/debug.c
Index: debug.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/debug.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -r1.9 -r1.10
--- debug.c 7 Feb 2003 14:05:51 -0000 1.9
+++ debug.c 8 Feb 2003 14:41:28 -0000 1.10
@@ -71,12 +71,12 @@
int pc;
fprintf(stderr, "\nDumping the instructions
status:\n-------------------------------\n");
- fprintf(stderr, "n\tblock\tdepth\tflags\ttype\topnum\tsize\tpc\top\n");
+ fprintf(stderr, "n\tblock\tdepth\tflags\ttype opnum\tsize\tpc\tins\n");
for (pc = 0, ins = instructions; ins; ins = ins->next) {
bb = bb_list[ins->bbindex];
if (bb) {
- fprintf(stderr, "%i\t%d\t%d\t%x\t%x\t%d\t%d\t%d\t",
+ fprintf(stderr, "%i\t%d\t%d\t%x\t%8x %d\t%d\t%d\t",
ins->index, bb->index, bb->loop_depth,
ins->flags, ins->type, ins->opnum, ins->opsize, pc);
}
@@ -133,15 +133,18 @@
}
+extern int n_comp_units;
void dump_symreg() {
int i;
if (!reglist)
return;
fprintf(stderr,
- "\nSymbols:\n----------------------------------------------\n");
+ "\nSymbols: n_comp_units %d"
+ "\n----------------------------------------------\n",
+ n_comp_units);
fprintf(stderr, "name\tfirst\tlast\t1.blk\t-blk\tset col tscore\t"
- "used\tlhs_use\tus flgs\n"
+ "used\tlhs_use\tregp\tus flgs\n"
"----------------------------------------------\n");
for(i = 0; i <n_symbols; i++) {
SymReg * r = reglist[i];
@@ -149,13 +152,14 @@
continue;
if(!r->first_ins)
continue;
- fprintf(stderr, "%s\t%d\t%d\t%d\t%d\t%c %2d %d\t%d\t%d\t%x\n",
+ fprintf(stderr, "%s\t%d\t%d\t%d\t%d\t%c %2d %d\t%d\t%d\t%s\t%x\n",
r->name,
r->first_ins->index, r->last_ins->index,
r->first_ins->bbindex, r->last_ins->bbindex,
r->set,
r->color, r->score,
r->use_count, r->lhs_use_count,
+ r->reg ? r->reg->name : "",
r->usage
);
}
1.31 +7 -0 parrot/languages/imcc/imc.c
Index: imc.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imc.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -w -r1.30 -r1.31
--- imc.c 7 Feb 2003 14:05:51 -0000 1.30
+++ imc.c 8 Feb 2003 14:41:28 -0000 1.31
@@ -314,6 +314,13 @@
if (rw)
r->lhs_use_count++;
r->use_count++;
+ /* if this symbol is used in a different scope
+ * assume usage
+ */
+ if (r->reg) {
+ r->lhs_use_count++;
+ r->use_count++;
+ }
}
}
/* TODO score high if r is a array/hash key */
1.25 +0 -2 parrot/languages/imcc/imc.h
Index: imc.h
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/imc.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -w -r1.24 -r1.25
--- imc.h 7 Feb 2003 14:05:51 -0000 1.24
+++ imc.h 8 Feb 2003 14:41:28 -0000 1.25
@@ -1,8 +1,6 @@
#ifndef __IMC_H
#define __IMC_H
-#define IMCC_VERSION "0.0.9.12"
-
#include <stdio.h>
#include <stdlib.h>
1.22 +5 -1 parrot/languages/imcc/instructions.c
Index: instructions.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/instructions.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -w -r1.21 -r1.22
--- instructions.c 8 Feb 2003 11:50:34 -0000 1.21
+++ instructions.c 8 Feb 2003 14:41:28 -0000 1.22
@@ -36,7 +36,7 @@
} comp_unit_t;
static comp_unit_t *comp_unit;
-static int n_comp_units;
+int n_comp_units;
void
open_comp_unit(void)
@@ -96,6 +96,10 @@
SymReg *new = mk_ident(str_dup(p->name), p->set);
new->type |= VT_REGP;
new->reg = p;
+ /* link in both dirs, so that usage can be determined */
+ p->reg = new;
+ debug(DEBUG_LEXER, "found outer scope sym '%s'\n",
+ p->name);
return new;
}
return p;
1.14 +1 -0 parrot/languages/imcc/main.c
Index: main.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/main.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -r1.13 -r1.14
--- main.c 7 Feb 2003 14:05:51 -0000 1.13
+++ main.c 8 Feb 2003 14:41:28 -0000 1.14
@@ -19,6 +19,7 @@
#include "pbc.h"
#include "parser.h"
+#define IMCC_VERSION "0.0.9.13"
static int run_pbc, write_pbc;
extern FILE *yyin;
1.12 +8 -0 parrot/languages/imcc/optimizer.c
Index: optimizer.c
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/optimizer.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -r1.11 -r1.12
--- optimizer.c 8 Feb 2003 11:50:34 -0000 1.11
+++ optimizer.c 8 Feb 2003 14:41:28 -0000 1.12
@@ -198,6 +198,13 @@
break;
}
}
+ /* if we have compile/eval, we don't know, if this
+ * label might be used
+ */
+ else if (!strcmp(ins2->op, "compile")) {
+ used = 1;
+ break;
+ }
}
if (!used && last) {
ostat.deleted_labels++;
@@ -226,6 +233,7 @@
if (!r)
continue;
if (r->use_count == 1 && r->lhs_use_count == 1) {
+ debug(DEBUG_OPT2, "used once �%s� deleted\n", ins_string(ins));
delete_ins(ins, 1);
ostat.deleted_ins++;
ostat.used_once++;
1.4 +10 -5 parrot/languages/imcc/t/harness
Index: harness
===================================================================
RCS file: /cvs/public/parrot/languages/imcc/t/harness,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -w -r1.3 -r1.4
--- harness 27 Jan 2003 17:06:56 -0000 1.3
+++ harness 8 Feb 2003 14:41:36 -0000 1.4
@@ -1,5 +1,5 @@
#! perl -w
-# $Id: harness,v 1.3 2003/01/27 17:06:56 leo Exp $
+# $Id: harness,v 1.4 2003/02/08 14:41:36 leo Exp $
#Blatantly stolen from parrot/t/harness by Mike Lambert
#Then blatantly stolen from perl6/t/harness by leo ;-)
@@ -14,21 +14,26 @@
use Getopt::Std;
my %opts;
-getopts('gjPbvdc?h', \%opts);
+getopts('gjPbvdc?hO:', \%opts);
if ($opts{'?'} || $opts{h}) {
print <<"EOF";
perl t/harness [options] [testfiles]
- -g ... diable CGoto
+ -g ... disable CGoto
-j ... run JIT
- -P ... run Prederef
+ -P ... run Prederef or CGP
-b ... run bounds checked
-v ... run verbose
-d ... run debug
-c ... assemble to PBC run PBC
+ -O[012] optimize
EOF
exit;
}
-$ENV{TEST_PROG_ARGS} = join(' ', map { "-$_" } keys %opts );
+
+my $args = join(' ', map { "-$_" } keys %opts );
+$args =~ s/-O/-O$opts{O}/ if ($opts{O});
+
+$ENV{TEST_PROG_ARGS} = $args;
$ENV{PARROT_QUICKTEST} = grep $_ eq 'quick', @ARGV;
@ARGV = grep $_ ne 'quick', @ARGV;