ref: 89fc1db118a0ab6e3b65f29074db76085a1587cc
parent: 2abe6624ece4d3033742aac950ee949c47d94927
author: Roberto E. Vargas Caballero <[email protected]>
date: Sat Apr 23 13:23:05 EDT 2016
[cc2] Add setlabel() Setlabel() is the function that must be called from the targets for every statement, and in case of being some label associated to the statment then an assembler instruction with opcode 0 (nop) will be added and the label will be registered at that point.
--- a/cc2/arch/qbe/arch.h
+++ b/cc2/arch/qbe/arch.h
@@ -5,6 +5,7 @@
#define TSIZE unsigned long
enum asmop {
+ ASNOP = 0,
ASSTB,
ASSTH,
ASSTW,
--- a/cc2/code.c
+++ b/cc2/code.c
@@ -47,6 +47,15 @@
}
void
+setlabel(Symbol *sym)
+{
+ if (!sym)
+ return;
+ code(0, NULL, NULL, NULL);
+ pc->label = sym;
+}
+
+void
code(int op, Node *to, Node *from1, Node *from2)
{
nextpc();