TritonVM / tasm-lang

Writing tasm with Rust syntax
15 stars 2 forks source link

Constant-folding on generated TASM #47

Open Sword-Smith opened 9 months ago

Sword-Smith commented 9 months ago

Generated TASM can often be simplified before it is executed on the VM. Consider for example

push 14
push 15
add

this can be replaced by

push 29

When we resolve addresses of list items and structs, we generate a lot of TASM code that can be simplified this way.

Optimally, everything that can be calculated at compile-time should be. Such that the VM's trace lengths can be minimized. A good place to start would be to implment TASM-constant-folding for these patterns

Concretely, this optimization step could be implemented as a method on InnerFunctionTasmCode but other interfaces are possible, too.