I came up with a pretty simple IR that I'm hoping to use for both backends. This was in hope of creating an easier representation to translate to the target. It is simple a vector of IRNode's (see src/ir.rs). Basically the idea is that it should be read from top to bottom to produce code even though it also contains a notion of scope. Anyways, that's not super important, but just some background.
What I'd like to do is to add a command line option --emit that lets you specify which intermediate representations to dump on the way to the final target. This would be similar to how the Rust --emitflag works.
For instance:
rascalc fib.ras -o fib --emit=ir
should dump a representation of the IR to a file. Or --emit=ir,C, should dump both the IR and the C source code. Currently we always dump the C source code, however this shouldn't be the default.
In essence we want to be able to serialize the state.build_stackhere (which is a Vec<IRNode>) into a <outfile>.ir file.
Then after we can produce these representations, we'll want to create the ability to start the compilation directly from the IR file, but thats a follow up for sure.
I came up with a pretty simple IR that I'm hoping to use for both backends. This was in hope of creating an easier representation to translate to the target. It is simple a vector of
IRNode
's (see src/ir.rs). Basically the idea is that it should be read from top to bottom to produce code even though it also contains a notion of scope. Anyways, that's not super important, but just some background.What I'd like to do is to add a command line option
--emit
that lets you specify which intermediate representations to dump on the way to the final target. This would be similar to how the Rust--emit
flag works.For instance:
should dump a representation of the IR to a file. Or
--emit=ir,C
, should dump both the IR and the C source code. Currently we always dump the C source code, however this shouldn't be the default.In essence we want to be able to serialize the
state.build_stack
here (which is aVec<IRNode>
) into a<outfile>.ir
file.Then after we can produce these representations, we'll want to create the ability to start the compilation directly from the IR file, but thats a follow up for sure.