ir+eval: Rework of instruction architecture #8
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Status quo
#6 implemented a rather hacky match on providing the inputs and processing the outputs of each instruction, and namely doesn't even handle instructions with multiple outputs at the moment.
Goal
An architecture for instructions that seperates the code of the individual instructions, and allows the instructions in
ir::instructionto list their inputs and outputs coherently and type-safely (such that we can make the inner values of the IDs inir::idprivate/pub(super)).Suggestion
irNot sure at all. Maybe we just need a bit of macro magic on
ir::instruction::Kindwhich allows specifying inputs and outputs as well as some helpful docs. Possible example, which would require movingVariantout ofeval(which is likely necessary for a type system anyway):which would then expand into an enum
Kindholding all those variants, and form additional methods returningevalPossibly a trait
Instructionineval::debugwould be beneficial, with a signature of somewhat like this:Then there'd need to be some kind of glue to make writing instructions actually easy, since
Variants themselves are quite tedious to extract. Maybe something like this (where theinstrmacro automatically extracts the individual types from theVariantand returns an error/panics if they do not match what's expected:Those could then be mapped somewhere in the debug evaluator:
Other things
ir::instruction::Kind, a generic overview of what instructions they are and what types they accept and returneval::kind::debug::Instruction, a specific implementation of a specific instructioneval::kind::debug::instr, which helps implementingeval::kind::debug::Instructionby mapping the types appropiatelyeval::kind::debugits own crate in order to allow parallel compilation to other evaluators, and make the module paths less complicated when referring to the debug evaluator and its children modules.