BigEd / atalan

Automatically exported from code.google.com/p/atalan
MIT License
1 stars 0 forks source link

Optimizer in proc call a'la Action #51

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Action there is special case, when up to three bytes are passed to procedure 
(or returned). They are passed in a,x,y registers (or less, in that order) This 
could save many bytes in every procedure/function invocation.

Is it easy or rather difficult to do?

I think it is not the part of optimiser, because tracking of procedure call 
protocol and  changes to the procedure itself are very hard to do. Direct 
optimizations made by semantic analysis are not.

Original issue reported on code.google.com by jakub.hu...@gmail.com on 17 Jan 2011 at 3:00

GoogleCodeExporter commented 9 years ago
I already considered this optimization. It should not be too hard.
However, care must be taken, when arguments to function are more complex.
Computation of an argument alone will use the the registers, so anything loaded 
in advance would be lost.

So basically we need to:

1. compute every argument and store it to temporary variable
2. load some parameters into registers
3. call the function

This could however create unnecessary temporary variables, so first we need to 
program algorithm for reuse of dead temporary variables.

Original comment by rudla.ku...@gmail.com on 17 Jan 2011 at 8:56

GoogleCodeExporter commented 9 years ago

Original comment by rudla.ku...@gmail.com on 17 Jan 2011 at 8:57

GoogleCodeExporter commented 9 years ago

Original comment by rudla.ku...@gmail.com on 17 Jan 2011 at 8:57

GoogleCodeExporter commented 9 years ago
It cound be a simpler version for the start point.

When there are three or less bytes of arguments (car and byte for ex.) there is 
the other kind of procedule call protocol. Else switch to the default protocol.

Original comment by jakub.hu...@gmail.com on 18 Jan 2011 at 11:39

GoogleCodeExporter commented 9 years ago
Dead temporary reuse is not done yet.
However I decided it should not pose so big problems, as most load/stores to 
those temporaries will be removed by optimizer anyways.

Original comment by rudla.ku...@gmail.com on 24 Jan 2011 at 4:35