aboutsummaryrefslogtreecommitdiff
path: root/c67-gen.c
diff options
context:
space:
mode:
authorThomas Preud'homme <robotux@celest.fr>2013-12-31 23:51:20 +0800
committerThomas Preud'homme <robotux@celest.fr>2014-01-04 21:10:05 +0800
commiteda2c756edc4dca004ba217d5bf361235dd9de1f (patch)
tree9370d81f4a5a3c18dc12e76b77c8db133af33032 /c67-gen.c
parentc634c797c5211a044bc76c4419abef7872a98918 (diff)
downloadtinycc-eda2c756edc4dca004ba217d5bf361235dd9de1f.tar.gz
tinycc-eda2c756edc4dca004ba217d5bf361235dd9de1f.tar.bz2
Move logic for if (int value) to tccgen.c
Move the logic to do a test of an integer value (ex if (0)) out of arch-specific code to tccgen.c to avoid code duplication. This also fixes test of long long value which was only testing the bottom half of such values on 32 bits architectures.
Diffstat (limited to 'c67-gen.c')
-rw-r--r--c67-gen.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/c67-gen.c b/c67-gen.c
index 1189dbb..df4b5d3 100644
--- a/c67-gen.c
+++ b/c67-gen.c
@@ -2103,7 +2103,7 @@ int gtst(int inv, int t)
C67_NOP(5);
t = ind1; //return where we need to patch
- } else if (v == VT_JMP || v == VT_JMPI) {
+ } else { /* VT_JMP || VT_JMPI */
/* && or || optimization */
if ((v & 1) == inv) {
/* insert vtop->c jump list in t */
@@ -2129,37 +2129,6 @@ int gtst(int inv, int t)
t = gjmp(t);
gsym(vtop->c.i);
}
- } else {
- if (is_float(vtop->type.t)) {
- vpushi(0);
- gen_op(TOK_NE);
- }
- if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
- /* constant jmp optimization */
- if ((vtop->c.i != 0) != inv)
- t = gjmp(t);
- } else {
- // I think we need to get the value on the stack
- // into a register, test it, and generate a branch
- // return the address of the branch, so it can be
- // later patched
-
- v = gv(RC_INT); // get value into a reg
- ind1 = ind;
- C67_MVKL(C67_A0, t); //r=reg to load, constant
- C67_MVKH(C67_A0, t); //r=reg to load, constant
-
- if (v != TREG_EAX && // check if not already in a conditional test reg
- v != TREG_EDX && v != TREG_ST0 && v != C67_B2) {
- C67_MV(v, C67_B2);
- v = C67_B2;
- }
-
- C67_IREG_B_REG(inv, v, C67_A0); // [!R] B.S2x A0
- C67_NOP(5);
- t = ind1; //return where we need to patch
- ind1 = ind;
- }
}
vtop--;
return t;