News About Docs Src Emulation Description Language
(Savoury SnaX) 30 Aug 2011

Spectrum

Bit of a slow week, however steady progress has been made. I added support for the <-> (exchange) operator along with ++ & –. ++ & – are not like C, they are used to imply signed rather than unsigned addition & subtraction. They change the way values are promoted in size, so 16bit++8bit would sign extend 8bit to 16bits then do the addition.

I’ve added the remainder of the affactors OVERFLOW,FORCESET,FORCERESET + inverted versions of current ones e.g. NONZERO.

Finally I’ve fixed a number of bugs in the compiler and tweaked the way the disassembly is generated, which helps. Anyway I`ll update the documentation later today.

Oh yeah, also implemented the Z80 in simplified form and added a new example to the examples folder…

Spectrum


(Savoury SnaX) 24 Aug 2011

Instancing and Optimisations

Over the last few days I have been looking into the code generated by the compiler in order to reduce its size further. One area that needed some work is due to the way globals are being used (for instance in holding the current state). LLVM refuses to remove useless loads and stores from these variables, probably because a global is treated as a volatile (although i`m not entirely sure). No amount of fiddling with flags and options would help, so in the end I resorted to writing a custom optimisation pass.

In the case of state variables, I know by design (a single edl file is a black box), that they only change at one point within the code. Which means that if a code block tests to see if its in a state, does some work, then tests if its in a different state, the second test is redundant if we went through the first block. The optimisation pass is trivialy simple, for any given function - it simply removes duplicate loads to the state variable. The normal LLVM optimisation passes can then kick in and do the heavy lifting. It works pretty well, although i had to run the optimisation passes twice due to the inlining passes providing further optimisation possibilities to my own.

I`m still not completely happy with the state code, I think there are further improvements to be had, and there are definately significant improvements to be made in other areas.

The other feature I added was INSTANCEs. They allow an edl file, to utilise other edl files (a little like an import directive in java). At present the compiler will only allow access to the PINs of the INSTANCEd module, in the future functions and globals that are not marked as INTERNAL will also be made visible.

Scoping rules are a little different to normal for INSTANCEs. Essentially non INTERNAL globals/functions/pins are only accessable from the file that includes the INSTANCE. Hopefully the documentation makes a bit more sense of the issue.