-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: relaxed reset/reuse in the code generator
closes #4089
- Loading branch information
1 parent
883a3e7
commit a18e517
Showing
3 changed files
with
116 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
set_option trace.compiler.ir.reset_reuse true | ||
|
||
def f : Nat × Nat → Nat × Nat | ||
| (a, b) => (b, a) | ||
|
||
def Sigma.toProd : (_ : α) × β → α × β | ||
| ⟨a, b⟩ => (a, b) | ||
|
||
def foo : List (Nat × Nat) → List Nat | ||
| [] => [] | ||
| x :: xs => match x with | ||
| (a, _) => a :: foo xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
[reset_reuse] | ||
def f (x_1 : obj) : obj := | ||
case x_1 : obj of | ||
Prod.mk → | ||
let x_2 : obj := proj[0] x_1; | ||
let x_3 : obj := proj[1] x_1; | ||
let x_5 : obj := reset[2] x_1; | ||
let x_4 : obj := reuse x_5 in ctor_0[Prod.mk] x_3 x_2; | ||
ret x_4 | ||
[reset_reuse] | ||
def Sigma.toProd._rarg (x_1 : obj) : obj := | ||
case x_1 : obj of | ||
Sigma.mk → | ||
let x_2 : obj := proj[0] x_1; | ||
let x_3 : obj := proj[1] x_1; | ||
let x_5 : obj := reset[2] x_1; | ||
let x_4 : obj := reuse x_5 in ctor_0[Prod.mk] x_2 x_3; | ||
ret x_4 | ||
def Sigma.toProd (x_1 : ◾) (x_2 : ◾) : obj := | ||
let x_3 : obj := pap Sigma.toProd._rarg; | ||
ret x_3 | ||
[reset_reuse] | ||
def foo (x_1 : obj) : obj := | ||
case x_1 : obj of | ||
List.nil → | ||
let x_2 : obj := ctor_0[List.nil]; | ||
ret x_2 | ||
List.cons → | ||
let x_3 : obj := proj[0] x_1; | ||
case x_3 : obj of | ||
Prod.mk → | ||
let x_4 : obj := proj[1] x_1; | ||
let x_9 : obj := reset[2] x_1; | ||
let x_5 : obj := proj[0] x_3; | ||
let x_6 : obj := foo x_4; | ||
let x_7 : obj := reuse x_9 in ctor_1[List.cons] x_5 x_6; | ||
ret x_7 |