develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r33975 - trunk/compilers/pirc/new

From:
kjs
Date:
December 16, 2008 11:28
Subject:
[svn:parrot] r33975 - trunk/compilers/pirc/new
Message ID:
20081216192813.A7F40CBA12@x12.develooper.com
Author: kjs
Date: Tue Dec 16 11:28:12 2008
New Revision: 33975

Modified:
   trunk/compilers/pirc/new/pir.y
   trunk/compilers/pirc/new/pircompunit.c
   trunk/compilers/pirc/new/pircompunit.h
   trunk/compilers/pirc/new/pirparser.c
   trunk/compilers/pirc/new/pirsymbol.h

Log:
[pirc] the previous commit removed a lot of tests for whether a <target> node was a <symbol> or <register>; now that mess has been cleaned up, code duplications and struct definitions can be cleaned up. This patch does exactly that.

Modified: trunk/compilers/pirc/new/pir.y
==============================================================================
--- trunk/compilers/pirc/new/pir.y	(original)
+++ trunk/compilers/pirc/new/pir.y	Tue Dec 16 11:28:12 2008
@@ -3299,43 +3299,21 @@
 write_signature(NOTNULL(expression * const iter), NOTNULL(char *instr_writer)) {
     switch (iter->type) {
         case EXPR_TARGET:
-            if (TEST_FLAG(iter->expr.t->flags, TARGET_FLAG_IS_REG))
-                *instr_writer++ = type_codes[iter->expr.t->info->type];
-            else
-                *instr_writer++ = type_codes[iter->expr.t->info->type];
+            *instr_writer++ = type_codes[iter->expr.t->info->type];
 
             if (iter->expr.t->key) {
                 *instr_writer++ = '_';
                 *instr_writer++ = 'k';
-                /* XXX fix this mess. */
+
                 if ((iter->expr.t->key->expr->type == EXPR_TARGET)
-                    &&
-                    (  (iter->expr.t->key->expr->expr.t->flags & TARGET_FLAG_IS_REG)
-                     ?
-                       (iter->expr.t->key->expr->expr.t->info->type == PMC_TYPE)
-                     :
-                       (iter->expr.t->key->expr->expr.t->info->type == PMC_TYPE)
-                    )
-                   ) {
+                &&  (iter->expr.t->key->expr->expr.t->info->type == PMC_TYPE)) {
                     /* the key is a target, and its type is a PMC. In that case, do not
                      * print the signature; 'kp' is not valid.
                      */
                 }
                 else {
-                    if (
-                       (iter->expr.t->key->expr->type == EXPR_TARGET)
-                       &&
-
-
-                       (
-                       (iter->expr.t->key->expr->expr.t->flags & TARGET_FLAG_IS_REG)
-                       ?
-                       (iter->expr.t->key->expr->expr.t->info->type == INT_TYPE)
-                       :
-                       (iter->expr.t->key->expr->expr.t->info->type == INT_TYPE)
-                       )
-                       )
-
+                    if ((iter->expr.t->key->expr->type == EXPR_TARGET)
+                    &&  (iter->expr.t->key->expr->expr.t->info->type == INT_TYPE))
                     {
                        *instr_writer++ = 'i';
                     }

Modified: trunk/compilers/pirc/new/pircompunit.c
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.c	(original)
+++ trunk/compilers/pirc/new/pircompunit.c	Tue Dec 16 11:28:12 2008
@@ -518,9 +518,8 @@
 target *
 target_from_symbol(lexer_state * const lexer, symbol * const sym) {
     target *t  = new_target(lexer);
-    /* t->s.sym   = sym; *//* set a pointer from target to symbol */
-    t->flags   = sym->flags; /* copy the flags */
 
+    t->flags   = sym->flags; /* copy the flags */
     t->info    = &sym->info;
 
     return t;
@@ -1863,10 +1862,7 @@
 
             switch (argvalue->type) {
                 case EXPR_TARGET:
-                    if (TEST_FLAG(argvalue->expr.t->flags, TARGET_FLAG_IS_REG))
-                        flag |= argvalue->expr.t->info->type;
-                    else
-                        flag |= argvalue->expr.t->info->type;
+                    flag |= argvalue->expr.t->info->type;
                     break;
                 case EXPR_CONSTANT:
                     flag |= argvalue->expr.c->type;

Modified: trunk/compilers/pirc/new/pircompunit.h
==============================================================================
--- trunk/compilers/pirc/new/pircompunit.h	(original)
+++ trunk/compilers/pirc/new/pircompunit.h	Tue Dec 16 11:28:12 2008
@@ -195,15 +195,7 @@
  * return values, it's a local variable (or register).
  */
 typedef struct target {
-
-    /*
-    union sym_union {
-        struct symbol  *sym;
-        struct pir_reg *reg;
-    } s;
-    */
-
-    struct syminfo *info;
+    struct syminfo *info;           /* pointer to symbol/pir_reg's information */
     target_flag     flags;          /* flags like :slurpy etc. */
     char const     *alias;          /* if this is a named parameter, this is the alias */
     char const     *lex_name;       /* if this is a lexical, this field contains the name */

Modified: trunk/compilers/pirc/new/pirparser.c
==============================================================================
--- trunk/compilers/pirc/new/pirparser.c	(original)
+++ trunk/compilers/pirc/new/pirparser.c	Tue Dec 16 11:28:12 2008
@@ -5988,43 +5988,21 @@
 write_signature(NOTNULL(expression * const iter), NOTNULL(char *instr_writer)) {
     switch (iter->type) {
         case EXPR_TARGET:
-            if (TEST_FLAG(iter->expr.t->flags, TARGET_FLAG_IS_REG))
-                *instr_writer++ = type_codes[iter->expr.t->info->type];
-            else
-                *instr_writer++ = type_codes[iter->expr.t->info->type];
+            *instr_writer++ = type_codes[iter->expr.t->info->type];
 
             if (iter->expr.t->key) {
                 *instr_writer++ = '_';
                 *instr_writer++ = 'k';
-                /* XXX fix this mess. */
+
                 if ((iter->expr.t->key->expr->type == EXPR_TARGET)
-                    &&
-                    (  (iter->expr.t->key->expr->expr.t->flags & TARGET_FLAG_IS_REG)
-                     ?
-                       (iter->expr.t->key->expr->expr.t->info->type == PMC_TYPE)
-                     :
-                       (iter->expr.t->key->expr->expr.t->info->type == PMC_TYPE)
-                    )
-                   ) {
+                &&  (iter->expr.t->key->expr->expr.t->info->type == PMC_TYPE)) {
                     /* the key is a target, and its type is a PMC. In that case, do not
                      * print the signature; 'kp' is not valid.
                      */
                 }
                 else {
-                    if (
-                       (iter->expr.t->key->expr->type == EXPR_TARGET)
-                       &&
-
-
-                       (
-                       (iter->expr.t->key->expr->expr.t->flags & TARGET_FLAG_IS_REG)
-                       ?
-                       (iter->expr.t->key->expr->expr.t->info->type == INT_TYPE)
-                       :
-                       (iter->expr.t->key->expr->expr.t->info->type == INT_TYPE)
-                       )
-                       )
-
+                    if ((iter->expr.t->key->expr->type == EXPR_TARGET)
+                    &&  (iter->expr.t->key->expr->expr.t->info->type == INT_TYPE))
                     {
                        *instr_writer++ = 'i';
                     }
@@ -6235,9 +6213,8 @@
 
             if (sym) {
                 operand->expr.t        = new_target(lexer);
-                //operand->expr.t->s.sym = sym;  /* target's pointer set to symbol */
-                operand->expr.t->info  =
-                &sym->info;
+                /* operand->expr.t->s.sym = sym;  */ /* target's pointer set to symbol */
+                operand->expr.t->info  = &sym->info;
                 operand->type          = EXPR_TARGET; /* convert operand node into EXPR_TARGET */
             }
             else { /* it must be a label */

Modified: trunk/compilers/pirc/new/pirsymbol.h
==============================================================================
--- trunk/compilers/pirc/new/pirsymbol.h	(original)
+++ trunk/compilers/pirc/new/pirsymbol.h	Tue Dec 16 11:28:12 2008
@@ -37,15 +37,7 @@
 /* structure to represent a declared local variable or parameter */
 typedef struct symbol {
     syminfo        info;
-    /*
-    int            color;
-    pir_type       type;
-    live_interval *interval;
-    char const    *name;
-    */
-
     target_flag    flags;
-
     struct symbol *next;
 
 } symbol;
@@ -54,13 +46,6 @@
 /* structure to represent a PIR register. */
 typedef struct pir_reg {
     syminfo         info;
-    /*
-    int             color;
-    pir_type        type;
-    live_interval  *interval;
-    int             regno;
-    */
-
     struct pir_reg *next;
 
 } pir_reg;



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About