Closed zu2 closed 3 weeks ago
I tried to modify gen_direct() for optimize constant assignment. This reduces 9-10 bytes per long/float assignment.
There is also room for improvement in pushing arguments when calling functions. This change is dirty, so a common framework is needed.
--- ../Fuzix-Compiler-Kit/be-codegen-6800.c 2024-11-01 00:40:37 +++ be-codegen-6800.c 2024-11-02 00:04:07 @@ -1236,6 +1356,8 @@ return 0; case T_EQ: /* Our left is the address */ case T_EQPLUS: + if((l->type&FLOAT)!=(r->type&FLOAT)) + return 0; v = n->value; if (can_load_r_simple(l, 0)) { if (r->op == T_CONSTANT && nr && r->value == 0) { @@ -1243,6 +1365,15 @@ we don't also need the value */ v += load_x_with(l, 0); uniop_on_ptr("clr", v, s); + return 1; + } + if (cpu == 6800 && nr && s == 4 && r->op == T_CONSTANT && n->op == T_EQ){ + printf("; gen_shortcut T_EQ T_CONSTANT %08x\n",r->value); + v += load_x_with(l, 0); + load_d_const((r->value)&0xffff); + op16_on_ptr("st", "st", v+2); + load_d_const((r->value)>>16); + op16_on_ptr("st", "st", v); return 1; } codegen_lr(r);
sample program.
int main(int argc, char **argv) { long a = 0x87654321; }
from:
ldaa #135 ldab #101 staa @hireg stab @hireg+1 ldaa #67 ldab #33 tsx stab 3,x staa 2,x psha ldaa @hireg+1 staa 1,x ldaa @hireg staa 0,x pula
to:
tsx ldaa #67 ldab #33 stb 3,x sta 2,x ldaa #135 ldab #101 stb 1,x sta 0,x
+ if((l->type&FLOAT)!=(r->type&FLOAT)) + return 0;
Seems to make no sense. The rest does. Applied but slightly modified so it also improves 6803/6303
I tried to modify gen_direct() for optimize constant assignment. This reduces 9-10 bytes per long/float assignment.
There is also room for improvement in pushing arguments when calling functions. This change is dirty, so a common framework is needed.
sample program.
from:
to: