scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 5cbeab763413495a5fe611fcfb2f7c2d6333e649
parent 25458d1f56c528c6838f840c289b0cd91301cd19
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
Date:   Sat, 23 Apr 2016 17:23:05 +0200

[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.

Diffstat:
Mcc2/arch/qbe/arch.h | 1+
Mcc2/code.c | 9+++++++++
2 files changed, 10 insertions(+), 0 deletions(-)

diff --git 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, diff --git a/cc2/code.c b/cc2/code.c @@ -47,6 +47,15 @@ addr(Node *np, Addr *addr) } 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();