[EMAIL PROTECTED] wrote:

Leo --

Here is a simple Jako test program, which exercises the assignment syntax:
Here it is compiled to IMC:

[ Q/A intersparsed in imcc code for clearness ]



.sub __MODULE__ .local int a # var int a;
.local int b # var int b;
.local int c # var int c;
.local float d # var num d;
.local float e # var num e;
.local string f # var str f;
.local string g # var str g;
a = 5 # a = 5;
a = 5 # a = 5;
b = 5 # b = 5;
c = 5 # c = 5;
d = 3.14 # d = 3.14;
d = 3.14 # d = 3.14;

> I don't understand how d and e both become N0,

d is not read beyond this point, so the register N0 gets reused.


                 e =      3.14                      # e = 3.14;
                 f =      "Howdy"                   # f = "Howdy";
                 f =      "Howdy"                   # f = "Howdy";
                 g =      "Howdy"                   # g = "Howdy";

> nor how both f and g become
> S0.

Same her, f ist not used RHS so, S0 gets reused.


                 a =      b                         # a = b;
                 a =      c                         # a = c;
                 b =      c                         # b = c;

> a, b, and c all seem to get their own registers.

Yes, these are used so need there own register.


... Is there some
optimization going on here since in both cases (num and str), the assigns
are from the same constant table location?

No, constant table location doesn't matter.

Is imcc smart enough to realize
that the above transformation doesn't change the semantics of my program,
or is it perhaps a bug?

It's a result of variable lifeness analyses, which is the base for register allocation and definitely no bug ;-)


Regards,

-- Gregor

leo




Reply via email to