Commit graph

11231 commits

Author SHA1 Message Date
Leonardo de Moura
2363fdf544 refactor(library/init/lean/compiler/ir): remove redundant field from FnBody.jdecl
The result type of a join point is always equal to the function return
type. Moreover, the extra bookkeeping introduces extra work, and doesn't
really help.
2019-05-07 12:26:11 -07:00
Leonardo de Moura
0d1a0c8b6e chore(library): toBool ==> decide
We want to define a type class similar to Haskell's `ToBool`.
2019-05-06 14:02:15 -07:00
Sebastian Ullrich
a3935aedcd chore(CMakeLists): fix install 2019-05-05 23:24:24 +02:00
Leonardo de Moura
439ce06a19 refactor(library/init/lean/compiler/ir): move "free variable" code to separate file 2019-05-05 08:04:33 -07:00
Leonardo de Moura
7a5e64e52e chore(library/init/lean/compiler): move IR related files to subdirectory 2019-05-05 07:55:36 -07:00
Leonardo de Moura
04670c4127 fix(library/compiler/struct_cases_on): bug and missing case 2019-05-03 20:03:03 -07:00
Leonardo de Moura
6f971382be chore(stage0): update 2019-05-03 19:01:17 -07:00
Sebastian Ullrich
1aef9ac576 feat(frontends/lean/match_expr): terminate match on dedent between equations 2019-05-03 13:46:10 +02:00
Leonardo de Moura
9b50e9d003 feat(library/compiler/find_jp): locate (and preserve) join points created by user 2019-05-02 17:20:19 -07:00
Leonardo de Moura
8bd0431c19 chore(stage0): update 2019-05-02 16:25:24 -07:00
Leonardo de Moura
2c4811a808 chore(library/init/lean/compiler): remove unnecessary [@export]s 2019-05-02 15:04:28 -07:00
Leonardo de Moura
76a49ec256 chore(library/compiler): add ir::test 2019-05-02 14:40:04 -07:00
Leonardo de Moura
3628b39cb6 feat(library/init/lean/compiler): add simpcase transformation 2019-05-02 12:40:37 -07:00
Leonardo de Moura
81d11db5d2 chore(runtime/object): rename runtime primitives 2019-05-02 10:55:29 -07:00
Leonardo de Moura
3a612bfd8b feat(library/init/lean/compiler): add elimDead transformation 2019-05-02 08:06:45 -07:00
Leonardo de Moura
e52e787ad5 fix(library/init/lean/compiler/pushproj): bug and cleanup 2019-05-01 21:01:03 -07:00
Leonardo de Moura
2991b966e5 featg(library/init/lean/compiler): add pushproj 2019-05-01 17:38:44 -07:00
Leonardo de Moura
af1d521706 feat(library/init/data/array/basic): add Array.swap 2019-05-01 17:38:44 -07:00
Leonardo de Moura
cfec797e69 feat(library/init/lean/compiler/ir): helper functions 2019-05-01 17:38:44 -07:00
Leonardo de Moura
45d09d3044 fix(library/compiler/ir): bug at LLNF -> IR 2019-05-01 17:38:44 -07:00
Leonardo de Moura
ed5e461130 feat(library/init/lean/compiler/ir): add maxVar 2019-05-01 17:38:44 -07:00
Leonardo de Moura
2614b95a8b refactor(library/init/lean/compiler/ir): use Nat instead of Name for local vars 2019-05-01 17:38:44 -07:00
Leonardo de Moura
0c9fa13763 feat(library/init/lean/compiler): convert LLNF into Lean IR 2019-04-30 17:55:43 -07:00
Leonardo de Moura
952eb0f515 feat(library/compiler): C++ API for Lean IR 2019-04-29 18:23:19 -07:00
Leonardo de Moura
8befa9bea5 chore(stage0): update
Make sure Lean IR primitives are available at Stage0.
2019-04-29 17:16:27 -07:00
Leonardo de Moura
a32fcf33c7 feat(util/array_ref): simple wrapper for creating Lean array objects in C++ 2019-04-29 17:10:35 -07:00
Leonardo de Moura
dd5fa4626f chore(runtime/object): style 2019-04-28 09:18:54 -07:00
Leonardo de Moura
79e2abe33f feat(CMakeLists): put configuration options relevant to leanc at config.h 2019-04-27 21:04:41 -07:00
Leonardo de Moura
35317139fd chore(library/compiler/util): style 2019-04-26 16:34:22 -07:00
Leonardo de Moura
e1a84d2f2c fix(library/compiler/struct_cases_on): performance problem exposed by badupdate1.lean 2019-04-26 16:30:19 -07:00
Leonardo de Moura
3c52183e3c fix(library/compiler/struct_cases_on): bug 2019-04-26 15:04:16 -07:00
Leonardo de Moura
5c7849a869 feat(runtime): eager heap initialization 2019-04-25 18:10:36 -07:00
Leonardo de Moura
f222dc7cca feat(library/compiler): destructive updates for {x with ...} expressions 2019-04-22 13:35:11 -07:00
Leonardo de Moura
ee0851921b fix(library/compiler/csimp): missing simplification opportunity 2019-04-22 13:15:08 -07:00
Leonardo de Moura
32f41f60d3 feat(runtime/object): add dbgTraceIfShared primitive for debugging RC reuse issues 2019-04-19 16:26:45 -07:00
Leonardo de Moura
b76deb4f0d fix(tests/playground/parser/syntax): another issue with float let inwards
@kha I keep finding problems with the float `let` inwards
transformation. It is always a nasty interaction between this
transformation and the `reset/reuse` insertion procedure.

The example I used in the new comment can be modified to a
`casesOn` with more than one branch (e.g., `Option.casesOn`).
Suppose we wrote
```
let o : Option Nat := Array.index a i in
let a              := Array.update a i none in
Option.casesOn o
  none
  (fun n, some (Array.update a i (some (n + 1))))
```
In the example above, the compiler will float
`a := Array.update a i none` inwards.
```
let o : Option Nat := Array.index a i in
Option.casesOn o
  none
  (fun n,
   let a := Array.update a i none in
   some (Array.update a i (some (n + 1))))
```
Then, adding reset/reuse:
```
let o : Option Nat := Array.index a i in
Option.casesOn o
  none
  (fun n,
   let o := reset o in
   let a := Array.update a i none in
   let n := n + 1 in
   let o := reuse o (some n)
   some (Array.update a i o))
```
Similarly to the example in the new comment, the `reset o` will fail since
the array `a` would still have a reference to `o`.

Remarks:
- Haskell also implements float `let` inwards.
- I am not sure how important the float `let` inward transformation is.
- I can see other nasty interactions after we implement user-defined
  simplification rules. For example, I guess many users would find the
  following lemma to be a good rewriting rule:
  ```
  (Array.update (Array.update a i v) i w) = (Array.update a i w)
  ```
  However, if we use this lemma in the example above, then `Array.update a i none` will be eliminated,
  and `reset o` will fail.
2019-04-19 14:52:52 -07:00
Leonardo de Moura
d22debefe3 fix(library/compiler/csimp): move to branch optimization
@kha The move `x := val` to `casesOn` branch was producing nasty
problems. I documented the issue, and implemented a simple
and sufficient condition for preventing the problem. The approach is very
similar to the one used at `push_proj_fn` at `llnf.cpp`.
I hope this change will not impact existing benchmarks :)
2019-04-18 16:34:08 -07:00
Leonardo de Moura
35d54c17bd chore(library/compiler): remove [inline2] attribute
We may add it back in the future if we find compelling applications for
it. Right now, we don't have any.
2019-04-18 13:24:20 -07:00
Leonardo de Moura
0ea944ad9f feat(library/compiler/csimp): add transformation to complement eager lambda lifting 2019-04-18 13:12:11 -07:00
Leonardo de Moura
89874edc14 feat(library/compiler/eager_lambda_lifting): lift selected lambdas 2019-04-17 18:10:21 -07:00
Leonardo de Moura
2b4ef62323 fix(library/compiler/eager_lambda_lifting): preserve binding_info
`specialize.cpp` needs this information
2019-04-17 18:07:08 -07:00
Leonardo de Moura
4bbecf93ed fix(library/compiler/eager_lambda_lifting): assertion violation 2019-04-17 18:02:48 -07:00
Leonardo de Moura
c4dc338d7d feat(library/compiler): add eager_lambda_lifting skeleton
The current commit only detects lambda expressions that should be
lifted eagerly.

@kha I added a comment describing why this optimization is useful.
Right now, we are not writing code that benefits from this optimization,
but it seems very useful for implementing combinators that return
a tuple containing functions. I think this is a useful idiom, for
example, the combinator may have two parts: one that is the actual
action, and another that collects "static properties".
Last summer, if I remember correctly, you considered building this
kind of combinator for the new Lean parser, but gave up because we
did not have compiler support for it. In your case, the "static
property" would be the set of tokens. It could also contain the left
most token for initializing the Pratt parser table, etc.
This commit is the first step to make this kind of code efficient.
It will also improve the experiment at `tests/playground/parser/`
2019-04-17 14:18:47 -07:00
Leonardo de Moura
ad2e7a2d60 chore(library/compiler/specialize): remove dead code
In LCNF, a type `ty` at `let x : ty := v in t` must not be irrelevant.
2019-04-17 08:11:39 -07:00
Leonardo de Moura
d662f312df fix(library/compiler/util): loose bvars 2019-04-17 07:57:30 -07:00
Leonardo de Moura
f12e580ac2 chore(library/compiler/csimp): compilation error in debug mode 2019-04-17 07:41:48 -07:00
Leonardo de Moura
32a309c566 fix(library/compiler/specialize): make sure specialize generates valid LCNF 2019-04-17 07:34:42 -07:00
Leonardo de Moura
5e9f2e4e6a chore(library/compiler/specialize): remove leftover that is now a noop 2019-04-17 07:14:35 -07:00
Leonardo de Moura
8612c1ecae chore(library/compiler/util): add debugging helper function 2019-04-16 17:12:09 -07:00
Leonardo de Moura
bfbdddad1a fix(library/compiler/emit_cpp): initialization bug 2019-04-12 08:24:06 -07:00