[hackers] [scc] [cc2-qbe] Force to have a label in bb || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Fri, 17 Jun 2016 14:02:46 +0200 (CEST)

commit bb663d195fde2e1d89e3700f82899b469cd3fb8c
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Fri Jun 17 13:55:27 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Fri Jun 17 13:55:27 2016 +0200

    [cc2-qbe] Force to have a label in bb
    
    Qbe needs a label at the beginning of every basic block
    so we have to check this condition.

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index a856a35..5216f06 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -304,6 +304,7 @@ writeout(void)
         Symbol *p;
         Type *tp;
         char *sep, *name;
+ int haslabel;
 
         if (curfun->kind == SGLOB)
                 fputs("export ", stdout);
_AT_@ -315,14 +316,21 @@ writeout(void)
                         break;
                 printf("%s%s %s.val", sep, size2asm(&p->type), symname(p));
         }
- puts(")\n{\n_AT_.start");
+ puts(")\n{");
 
         /* emit assembler instructions */
         for (pc = prog; pc; pc = pc->next) {
- if (pc->label)
+ if (pc->label) {
+ haslabel = 1;
                         printf("%s\n", symname(pc->label));
- if (pc->op)
- (*optbl[pc->op].fun)();
+ }
+ if (!pc->op)
+ continue;
+ if (pc->flags&BBENTRY && !haslabel)
+ printf("%s\n", symname(newlabel()));
+ (*optbl[pc->op].fun)();
+ if (!pc->label)
+ haslabel = 0;
         }
 
         puts("}");
_AT_@ -486,7 +494,8 @@ getbblocks(void)
                 case ASCALLL:
                 case ASCALLD:
                 case ASCALL:
- pc->flags |= BBENTRY;
+ if (pc->next)
+ pc->next->flags |= BBENTRY;
                         break;
                 }
         }
Received on Fri Jun 17 2016 - 14:02:46 CEST

This archive was generated by hypermail 2.3.0 : Fri Jun 17 2016 - 14:12:26 CEST