Open hackaugusto opened 5 months ago
Well, I just realized we have some of this functionality already:
But we never use it because that is less efficient, because the counter goes to the stack, and we usually write code with a hardcoded constants. I guess we have a few alternatives:
pipe_to_memory_2
/ pipe_to_memory_4
/ pipe_to_memory_6
, where the number in the procedure is the number of words read from the advice stack to memoryexport.pipe_to_memory_even(count)
repead.@count
adv_pipe hperm
end
end
Where the @count
would be replaced by the assembler, similar to a preprocessor.
The idea of using constant seems to have an issue of its own: https://github.com/0xPolygonMiden/miden-vm/issues/297
- Extend the assembly syntax to allow for constant arguments to procedures, something like:
export.pipe_to_memory_even(count) repead.@count adv_pipe hperm end end
This is a bit tricky because for every value of @count
, we'd have a different MAST root. This means that we won't be able to compile this function to MAST without knowing the calling context. The way the assembler is structured now, I believe something like that won't be possible, and also it won't be possible once we transition to MAST-based libraries. But overall, I agree, this would be a nice way to avoid some code duplication.
We often have to write code that does the following:
N
words from the advice stack to memory, and run a permute after each readI think steps 1 through 3 should have a procedure, and step the another one for steps 1 through 4.