[hackers] [scc] [cc2-qbe] Add initial label for qbe || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 2 Jun 2016 08:35:26 +0200 (CEST)

commit d96672c3e87b42ba8e269bd72386ee2431c3134c
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jun 2 08:14:12 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Jun 2 08:14:12 2016 +0200

    [cc2-qbe] Add initial label for qbe
    
    Qbe needs a label at the beginning of every basic block,
    but when we don't have any code inside of a function we
    does not generate any basic block. This code forces to
    have at least one basic block composed of a label and
    a jump statement.

diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index 2f213c5..6e23894 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -317,7 +317,7 @@ writeout(void)
                         break;
                 printf("%s%s %s.val", sep, size2asm(&p->type), symname(p));
         }
- puts(")\n{");
+ puts(")\n{\n_AT_.start");
 
         /* allocate stack space for parameters */
         for (p = locals; p && (p->type.flags & PARF) != 0; p = p->next)
_AT_@ -344,6 +344,8 @@ writeout(void)
                 if (pc->op)
                         (*optbl[pc->op].fun)();
         }
+ if (!prog)
+ puts("\t\tret");
 
         puts("}");
 }
Received on Thu Jun 02 2016 - 08:35:26 CEST

This archive was generated by hypermail 2.3.0 : Thu Jun 02 2016 - 08:36:14 CEST