This PR introduces a phase separation to the LCNF IR. This is a preparation for the merge of the old `Lean.Compiler.IR` and the new `Lean.Compiler.LCNF` framework. The change parametrizes all relevant `LCNF` data structures over a `Purity` parameter and additionally carries around proofs that the `Purity` has certain values, depending on what's required. This is done as opposed to indexing the types over `Purity` because we do (almost) never have to store the `Purity` value for phase generic structures this way.
23 lines
621 B
Text
23 lines
621 B
Text
import Lean.Compiler
|
|
import Lean.Compiler.LCNF.Probing
|
|
|
|
open Lean.Compiler.LCNF
|
|
|
|
def f (a : Nat) : Bool :=
|
|
decide (a = 1)
|
|
|
|
-- This is only required until the new code generator is enabled.
|
|
run_meta Lean.Compiler.compile #[``f]
|
|
|
|
def countCalls : Probe (Decl .pure) Nat :=
|
|
Probe.getLetValues .pure >=>
|
|
Probe.filter (fun e => return e matches .const `Decidable.decide ..) >=>
|
|
Probe.count
|
|
|
|
#eval do
|
|
let numCalls <- Probe.runOnDeclsNamed #[`f] (phase := .base) <| countCalls
|
|
assert! numCalls == #[1]
|
|
|
|
#eval do
|
|
let numCalls <- Probe.runOnDeclsNamed #[`f] (phase := .mono) <| countCalls
|
|
assert! numCalls == #[0]
|