docs(design): add graph ir repr and explain a bit

This commit is contained in:
MultisampledNight 2024-01-10 21:10:05 +01:00
commit bebf2a97a4
No known key found for this signature in database
GPG key ID: C81EF9B053977241
4 changed files with 202 additions and 8 deletions

View file

@ -1,5 +1,6 @@
#import "../template.typ": conf
#import "graphics.typ"
#import graphics: arrow
#show: conf.with(title: [iOwO design], subtitle: [don't worry, we're just dreaming])
@ -30,7 +31,7 @@
// at which point `query` doesn't find anything anymore
#let terms = (
"source",
"ast",
"AST",
"graph IR",
"runtime",
@ -85,18 +86,29 @@
- algebraic enums
- traits (`Numeric`...)
#pagebreak()
= Execution stages
#graphics.stages-overview
iOwO operates in stages. This has a number of benefits and implications:
- One can just work on one aspect of the stages without having to know about the rest.
- Bugs are easier to trace down to one stage.
- Stages are also replacable, pluggable and usable somewhere else.
- For example, one could write a Just-In-Time compiler to replace the runtime stage, while preserving the source #arrow() graph IR step.
However, this also makes the architecture somewhat more complicated. So here we try our best to describe how each stage looks like. If you have any feedback, feel free to drop it on #link("https://forge.katzen.cafe/katzen-cafe/iowo/issues")[the issues in the repository]!
== Source <source>
```iowo
open base.png >|
open stencil.png >|
mask
|> show12
|> (invert | show)
|> show
```
Functional and pipeline-based.
@ -151,8 +163,8 @@ To handle each output of a streamer individually, they can be _split_:
```iowo
mask
|> invert -- would invert the unmasked part
|> show -- would show the masked part
|> invert -- would invert the unmasked part
```
==== Combination <combination>
@ -193,16 +205,22 @@ Done with any of `--` or `//`.
== Graph IR
#graphics.graph-example
The parsed representation of the source, and also what the runtime operates on.
In a way, this is the AST, except that it's not a tree.
It is represented in iOwO using adjacencies, where essentially the vertices#footnote[Nodes or commands in this case.] and their edges#footnote[Connections or pipes in this case.] are stored separately.
=== Optimizer
Merges and simplifies commands in the graph IR.
== Runtime
Runs through all commands in the graph IR. It does not have any significantly other representation, and despite its name there's _no_ bytecode involved.
=== Scheduler
Looks at the graph IR and decides when the VM should execute what.