|
|
Author: kjs
Date: Sun Aug 24 06:07:35 2008
New Revision: 30513
Modified:
trunk/compilers/pirc/new/pircompunit.c
trunk/compilers/pirc/new/pircompunit.h
trunk/compilers/pirc/new/pirsymbol.c
Log:
[pirc/new] keep track of number of PASM registers per sub. This will be useful
for an optimizing register allocator, I think. It's a nice statistic anyway.
Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c (original)
+++ trunk/compilers/pirc/new/pircompunit.c Sun Aug 24 06:07:35 2008
@@ -241,20 +241,22 @@
newsub->symbols = NULL;
newsub->flags = 0;
- /* set all "register" tables to NULL */
- for (index = 0; index < 4; index++)
- newsub->registers[index] = NULL;
+ for (index = 0; index < 4; index++) {
+ newsub->registers[index] = NULL; /* set all "register" tables to NULL
*/
+ newsub->regs_used[index] = 0; /* set all register counts to 0 */
+ }
/* link the new sub node into the list of subroutines */
- if (lexer->subs == NULL) { /* no subroutine yet */
+ if (lexer->subs == NULL) { /* no subroutine yet, this is the first one */
lexer->subs = newsub;
newsub->next = newsub; /* set next field to itself, to make the list
circular linked */
}
else { /* there is at least 1 other subroutine */
+
/* lexer->subs points to "end of list", to the last added one */
newsub->next = lexer->subs->next; /* set newsub's next to the
first item in the list */
lexer->subs->next = newsub; /* set current sub's next to the new
sub. */
- lexer->subs = newsub; /* set pointer to current sub to this last
added one */
+ lexer->subs = newsub; /* set pointer to current sub to this
last added one */
}
/* store the subroutine identifier as a global label */
@@ -1913,6 +1915,12 @@
do {
+ printf("# subroutine '%s' register usage\n", subiter->sub_name);
+ printf("# int : %d\n", subiter->regs_used[INT_TYPE]);
+ printf("# num : %d\n", subiter->regs_used[NUM_TYPE]);
+ printf("# string: %d\n", subiter->regs_used[STRING_TYPE]);
+ printf("# pmc : %d\n", subiter->regs_used[PMC_TYPE]);
+
printf(".namespace ");
print_key(subiter->name_space);
puts("");
Modified: trunk/compilers/pirc/new/pircompunit.h
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.h (original)
+++ trunk/compilers/pirc/new/pircompunit.h Sun Aug 24 06:07:35 2008
@@ -277,6 +277,7 @@
struct symbol *symbols; /* symbol table for this subroutine */
struct pir_reg *registers[4]; /* used PIR registers in this sub (1
list for each type) */
+ int regs_used[4]; /* number of PASM registers allocated
for this sub */
struct subroutine *next;
Modified: trunk/compilers/pirc/new/pirsymbol.c
==============================================================================
--- trunk/compilers/pirc/new/pirsymbol.c (original)
+++ trunk/compilers/pirc/new/pirsymbol.c Sun Aug 24 06:07:35 2008
@@ -62,6 +62,7 @@
*/
static int
next_register(struct lexer_state * const lexer, pir_type type) {
+ lexer->subs->regs_used[type]++;
return lexer->curregister[type]++;
}
|
|