Shop OBEX P1 Docs P2 Docs Learn Events
Code Optimizer for Spin to Spin? — Parallax Forums

Code Optimizer for Spin to Spin?

Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
edited 2011-06-06 06:20 in Propeller 1
Is there a method of running BST's optimizer and having it return optimized spin code instead of just uploading it to the Propeller? (unused methods)

Thanks
OBC

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2011-06-05 16:04
    I am reading into this you are wanting the optimised source re-output to a file and not the compiled binary.

    Nice idea, but I suspect No. My understanding of the optimiser is that it would know the data being pushed onto the stack is immediately popped from the stack in the next pseudo spin bytecode, so the push/pop may be removed. Brad of course will have to answer. It really depends on the level of optimisation he has done. My presumption is he has done a few tricks of regularly used routines. Because our source is not the spin bytecode is the reason I suspect the middle pass will not be available to output.

    This does raise an interesting observation though. BST can do a listing, so the optimisations could actually be seen. But we are at spin bytecode which is a middle ground. Perhaps we could do a "middle ground" bytecode editor??? Not sure what that would entail at the moment, but a thought worthy of further investigation.

    I would love to have time to investigate a new syntax for spin styled on basic more. A small runtime compiler based on sphinx would permit a small PropDos style computer :)
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-06-06 06:20
    OBC, AFAIK there's no way to get BST to save the optimized Spin code. Of course, there's are a number of tips and tricks for writing Spin code that is as compact and fast as possible, which you probably know. Use the first 8 local and VAR variables as much as possible, and use the assignment operators and auto-increment/decrement operators when possible. It is more efficient to pack as much stuff into one statement versus multiple statements, such as

    x = x * 5
    y = y + 1
    z = z + (x/y)

    versus

    z += (x *= 5) / (++y)
Sign In or Register to comment.