Tinyrossa is pure-Smalltalk (very) experimental compiler backend based on Testarossa Intermediate Language, ArchC and MachineArithmetic.
...that "nothing works!"
At the moment, this is just an experiment, a result of couple afternoons of hacking to see what it might look like and to get initial feedback from the community. Pretty much every part is either incomplete or plain wrong and the API is not great either.
However, it is - in my opinion - enough to demonstrate some of the core ideas.
| compilation builder |
"Create a compilation object:"
compilation := TRCompilation new.
"Create IL builder and build IL representation of :"
builder := compilation builder.
builder ireturn:
{ builder iconst: 42 }.
"Indicate we're done building the IL."
compilation buildFinished.
"To inspect the IL, evaluate and inspect:"
compilation il.
"Run IL-level optimizer"
compilation optimize.
"Compile IL to machine code. This includes
instruction selection, register allocation and
branch relocation."
compilation compile.
"Once compiled, the code buffer contains the actual
machine code."
compilation codeBuffer.
For more examples, see class TRCompilationExamples
.
The easiest way to try out Tinyrossa is to use provided makefile that automatically downloads all the dependencies (including Smalltalk/X) and loads them into running environment:
git clone --recurse-submodules https://github.com/janvrany/Tinyrossa.git
cd Tinyrossa
make -C stx run
NOTE: The following instructions assume you have a recent Smalltalk/X jv-branch, i.e., a version newer than 2022-06-01.
Clone the repository into some directory (say /where/you/cloned/it/Tinyrossa
)
git clone --recurse-submodules https://github.com/janvrany/Tinyrossa.git /where/you/cloned/it/Tinyrossa
Install / clone dependencies:
Load MachineArithmetic. Follow instructions in README.md
Load Pharo-ArchC. Follow instructions in README.md
In Smalltalk/X, execute:
"/ Tell Smalltalk/X where to look for Tinyrossa packages
Smalltalk packagePath add: '/where/you/cloned/it/Tinyrossa'.
"/ Load Tinyrossa
Smalltalk loadPackage: 'BaselineOfTinyrossa'.
The easiest way to try out Tinyrossa is to use provided makefile that automatically downloads all the dependencies (including Pharo) and builds an image with everything loaded:
git clone --recurse-submodules https://github.com/janvrany/Tinyrossa.git
cd Tinyrossa/pharo
make