Leo -- Here's the simple bench.jako example (again):
const int N = 100; var int q = 1; while (q < N) { var int i, j, w = 1; while (w < N) { i++; j += i; w++; # print("$q, $w\n"); } q++; } I used to work harder in the Jako compiler to track constants and substitute their values, but I figured thats the sort of shared functionality IMCC would either have now or in future. So, I've removed those smarts from jakoc (which has the added benefit, IMO, of leaving symbolic constants symbolic in the ..imc file). Now, I generate the following IMC code for the above Jako code: .sub __MODULE__ .local int N # const int N = 100; N = 100 .local int q # var int q; q = 1 # q = 1; .namespace WHILE_BLOCK _W1_WHILE: _W1_NEXT: ge q, N, _W1_LAST # _W1: while (q < N) { _W1_REDO: .local int i # var int i; i = 1 # i = 1; .local int j # var int j; j = 1 # j = 1; .local int w # var int w; w = 1 # w = 1; .namespace WHILE_BLOCK _W2_WHILE: _W2_NEXT: ge w, N, _W2_LAST # _W2: while (w < N) { _W2_REDO: add i, 1 # i += 1; add j, i # j += i; add w, 1 # w += 1; _W2_CONT: branch _W2_NEXT # } _W2_LAST: .endnamespace WHILE_BLOCK add q, 1 # q += 1; _W1_CONT: branch _W1_NEXT # } _W1_LAST: .endnamespace WHILE_BLOCK end .end (I'm still not making use of all the imcc language features) You can see that as far as the generated IMC is concerned, variables and constants are treated equivalently. I do track the const-ness of the identifier to prevent Jako code from trying to do "N = 5" when N was declared earlier as a constant. The current IMCC converts the above to this: __MODULE__: set I4, 100 set I3, 1 _W1_WHILE: _W1_NEXT: ge I3, I4, _W1_LAST _W1_REDO: set I1, 1 set I2, 1 set I0, 1 _W2_WHILE: _W2_NEXT: ge I0, I4, _W2_LAST _W2_REDO: add I1, 1 add I2, I1 add I0, 1 _W2_CONT: branch _W2_NEXT _W2_LAST: add I3, 1 _W1_CONT: branch _W1_NEXT _W1_LAST: end Which looks pretty good. Here we can see that IMCC does not discover that I4 can be optimized away. Is that something I should be expecting in forthcoming IMCC releases? Or, should I go back to handling it in the Jako compiler? I was thinking it might be nice to be able to do something like this in the .imc file: .local int N 100 # Constant implied by value after name BTW, thanks for producing imcc. I'm very happy I don't have to do register allocation anymore. The Jako compiler is still not a work of art, but imcc is allowing me to incrementally remove complexity (which I'm turning right around and re-adding in other areas... :). And, thanks also for fielding my numerous questions as promptly as you have! Regards, -- Gregor I am that which is not everything else.