miden-vm icon indicating copy to clipboard operation
miden-vm copied to clipboard

Assembly IO instruction refactoring

Open bobbinth opened this issue 2 years ago • 3 comments

IO operations are the only ones currently left still use "dot-format" (underscore format). As discussed in #329, it might be good to move them to the underscore format as well. Additionally, I think it might be a good opportunity for a bigger refactoring. Specifically, I'm thinking we could do the following:

  • push operation stays as is now.
  • push.env.sdepth -> sdepth
  • push.env.locaddr -> locaddr
  • push.mem -> mem_load
  • pushw.mem delete
  • loadw.mem -> mem_loadw
  • push.mem -> mem_store
  • popw.mem delete
  • storew.mem -> mem_storew
  • push.local -> loc_load
  • pushw.local delete
  • loadw.local -> loc_loadw
  • pop.local -> loc_store
  • popw.local -> delete
  • storew.local -> loc_storew

The motivation behind removing some operations is that these are expensive operations and frequently their use can be eliminated by more efficient use of load and store operations.

bobbinth avatar Aug 03 '22 20:08 bobbinth

I think this will make instructions look more familiar --- cognitive parsing becomes easier.

itzmeanjan avatar Aug 04 '22 07:08 itzmeanjan

I'm in favor of getting rid of pushw and popw. They both have a big performance penalty that's a bit opaque right now, so it's probably better if people have to explicitly pad the stack & see the cycle cost whenever they need this functionality.

If we're getting rid of pushw/popw, I'd change push/pop for memory & locals to to load/store for the same reason. Otherwise I think the same performance issue is likely to manifest itself in those instructions.

As mentioned in the other issue, I'm also in favor of switching to underscores, and I think the change to the env instructions makes sense here as well.

grjte avatar Aug 04 '22 08:08 grjte

I'd change push/pop for memory & locals to to load/store

Agreed! I've updated the original post.

bobbinth avatar Aug 05 '22 16:08 bobbinth

Closed by #393

bobbinth avatar Sep 16 '22 18:09 bobbinth