[hackers] [scc] [cc2] Add setlabel() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Sun, 24 Apr 2016 17:29:37 +0200 (CEST)

commit 5cbeab763413495a5fe611fcfb2f7c2d6333e649
Author: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
AuthorDate: Sat Apr 23 17:23:05 2016 +0200
Commit: Roberto E. Vargas Caballero <Roberto E. Vargas Caballero>
CommitDate: Sat Apr 23 17:23:05 2016 +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.

diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h
index ffd44cf..e01030d 100644
--- a/cc2/arch/qbe/arch.h
+++ b/cc2/arch/qbe/arch.h
_AT_@ -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
index c5ba26b..1d0e4f4 100644
--- a/cc2/code.c
+++ b/cc2/code.c
_AT_@ -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();
Received on Sun Apr 24 2016 - 17:29:37 CEST

This archive was generated by hypermail 2.3.0 : Sun Apr 24 2016 - 17:36:22 CEST