commit d96672c3e87b42ba8e269bd72386ee2431c3134c
parent 7ceb2bb314fb31bc01ce1781e00be4d29d38b7f3
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 2 Jun 2016 08:14:12 +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.
Diffstat:
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
@@ -317,7 +317,7 @@ writeout(void)
break;
printf("%s%s %s.val", sep, size2asm(&p->type), symname(p));
}
- puts(")\n{");
+ puts(")\n{\n@.start");
/* allocate stack space for parameters */
for (p = locals; p && (p->type.flags & PARF) != 0; p = p->next)
@@ -344,6 +344,8 @@ writeout(void)
if (pc->op)
(*optbl[pc->op].fun)();
}
+ if (!prog)
+ puts("\t\tret");
puts("}");
}