ControlCplusControlV / Scribe

Minimal Yul Transpilation to the Miden VM
GNU General Public License v3.0
51 stars 4 forks source link

Lifetime Management #47

Open ControlCplusControlV opened 1 year ago

ControlCplusControlV commented 1 year ago

Lifetime Management

Test Cases

  1. Input Yul
    
    {
    let a := 700
    let b := 100
    let c := 200
    let d := add(a, c)
    }

1. Assembly Output
```clike=

// a gets pushed to the stack
// b gets pushed to the stack
// The stack is full, so the top value will attempt to save to memory
//Since b is the top value, the optimizer will check if b is used later
//if so, b gets saved to memory, if not, b gets dropped
//then c gets pushed to the stack
//a and c are added
  1. Input Yul
    
    let c = 1000
    let b = 15
    let a = 6

let d = mul(a, b) let e = mul(d, a)


2. Assembly Output
```clike=
// Assembly output should not put d back on the stack,
//  because it is immediately used after, since in 
//  multiplication the intermediate value 
//  must be stored in memory.