scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 52958e5bbdf55f88a0abaab3b2cb130ba148710a
parent b9f8c19467f09236a38525bf45ddfea4ae8b240d
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 20 Sep 2016 12:20:42 +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.

Diffstat:
Mcc2/arch/qbe/arch.h | 2++
Mcc2/arch/qbe/cgen.c | 4++--
Mcc2/arch/qbe/code.c | 2++
3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/cc2/arch/qbe/arch.h b/cc2/arch/qbe/arch.h @@ -144,4 +144,6 @@ enum asmop { ASPARE, ASALLOC, ASFORM, + + ASCOPYW, }; diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c @@ -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 @@ -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'},