[hackers] [scc] [cc2-qbe] Use copy in or/and operations || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Tue, 20 Sep 2016 12:27:11 +0200 (CEST)

commit 52958e5bbdf55f88a0abaab3b2cb130ba148710a
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Tue Sep 20 12:20:42 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Tue Sep 20 12:20:42 2016 +0200

    [cc2-qbe] Use copy in or/and operations
    
    In the case of or/and operations we have a phi node, and we have
    two possibilities in qbe for this case, the phi instruction or
    the copy instruction. The copy instruction is more similar to
    what were trying (incorrectly) until this moment.

diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h
index 38eafbb..16b7835 100644
--- a/cc2/arch/qbe/arch.h
+++ b/cc2/arch/qbe/arch.h
_AT_@ -144,4 +144,6 @@ enum asmop {
         ASPARE,
         ASALLOC,
         ASFORM,
+
+ ASCOPYW,
 };
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 7b176df..fb60d1b 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -443,11 +443,11 @@ rhs(Node *np, Node *ret)
                 bool(np, true, false);
 
                 setlabel(true);
- assign(&int32type, ret, constnode(&aux2, 1, &int32type));
+ code(ASCOPYW, ret, constnode(&aux2, 1, &int32type), NULL);
                 code(ASJMP, NULL, phi, NULL);
 
                 setlabel(false);
- assign(&int32type, ret, constnode(&aux2, 0, &int32type));
+ code(ASCOPYW, ret, constnode(&aux2, 0, &int32type), NULL);
 
                 setlabel(phi->u.sym);
                 return ret;
diff --git a/cc2/arch/qbe/code.c b/cc2/arch/qbe/code.c
index e6845fd..677c5d6 100644
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
_AT_@ -25,6 +25,8 @@ static struct opdata {
         [ASLDS] = {.fun = unary, .txt = "load", .letter = 's'},
         [ASLDD] = {.fun = unary, .txt = "load", .letter = 'd'},
 
+ [ASCOPYW] = {.fun = unary, .txt = "copy", .letter = 'w'},
+
         [ASSTB] = {.fun = store, .txt = "store", .letter = 'b'},
         [ASSTH] = {.fun = store, .txt = "store", .letter = 'h'},
         [ASSTW] = {.fun = store, .txt = "store", .letter = 'w'},
Received on Tue Sep 20 2016 - 12:27:11 CEST

This archive was generated by hypermail 2.3.0 : Tue Sep 20 2016 - 12:36:13 CEST