ref: b7f42e58b25d64fa8a03e8ac06a5f5e5e92c552a
parent: 2d13ffabb84f581ac246d0b754e5d8ebabe6ec41
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Sep 20 08:20:42 EDT 2016
[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.
--- a/cc2/arch/qbe/arch.h
+++ b/cc2/arch/qbe/arch.h
@@ -144,4 +144,6 @@
ASPARE,
ASALLOC,
ASFORM,
+
+ ASCOPYW,
};
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
@@ -443,11 +443,11 @@
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;
--- a/cc2/arch/qbe/code.c
+++ b/cc2/arch/qbe/code.c
@@ -25,6 +25,8 @@
[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'},