Commit graph

263 commits

Author SHA1 Message Date
Leonardo de Moura
b4a002f0f2 feat: abstract interpreter entry point, and missing stuff
TODO: widening to ensure termination
2019-10-03 16:50:47 -07:00
Leonardo de Moura
b316dc24c8 feat: more array goodies and naming convetion 2019-10-03 16:50:23 -07:00
Leonardo de Moura
680ee21161 feat(library/init/lean/compiler/ir): add unreachbranches.lean
New optimization pass for eliminating unreachable branches that occur
very often when using `ExceptT` and `EState`.

The current commit implements an abstract interpreter for computing
an approximation of the kinds of values returned by a function.
TODO:
- Implement `FnBody.jmp`.
- Implement `interpDecl`
- Remove unreachable branches in `FnBody.case`
2019-10-02 19:57:43 -07:00
Leonardo de Moura
45d664ff25 fix(library/init/lean/compiler/ir/livevars): bug at updateLiveVars 2019-10-02 16:50:37 -07:00
Leonardo de Moura
874dd1d55c chore(library/init/lean/compiler/ir/basic): remove unnecessary function 2019-10-02 16:50:37 -07:00
Leonardo de Moura
e9bcbd5b0d fix(library/init/lean/compiler/ir/unboxresult): reject recursive types 2019-10-02 16:50:37 -07:00
Leonardo de Moura
4a219b6bd2 feat(library/init/lean/compiler/ir): add [unbox] attribute 2019-10-02 16:50:37 -07:00
Leonardo de Moura
fdab3b90b9 refactor(library/init/data/array): new name convention for Array functions 2019-10-01 16:46:05 -07:00
Leonardo de Moura
411f397654 refactor(library/init/data/list): new name convention for List functions
cc @dselsam @kha
2019-10-01 15:15:02 -07:00
Leonardo de Moura
6ad9d58b0f fix(library/init/lean/compiler/neverextractattr): auxiliary declarations should inherit @[neverExtract] attribute 2019-10-01 14:57:16 -07:00
Leonardo de Moura
9d2eadc754 chore(library/init/lean/compiler): delete @[effectful] 2019-10-01 14:08:31 -07:00
Leonardo de Moura
80d3ca9d77 feat(library/init/lean/compiler): add @[neverExtract] attribute
It will replace `@[effectful]`

cc @kha
2019-10-01 14:00:02 -07:00
Leonardo de Moura
e451c4dc78 feat(library/init/lean/compiler): add @[effectful]
This attribute is used for low-level primitives like unsafeIO
2019-09-30 16:12:41 -07:00
Leonardo de Moura
18e6a106f4 feat(library/init/lean/smap): implement SMap using PHashMap instead of RBMap 2019-09-20 14:22:03 -07:00
Leonardo de Moura
2996d306c9 feat(library/init): add more general modify: modifyGet
This commit also adds a few helper elaboration functions.
2019-09-16 15:14:02 -07:00
Sebastian Ullrich
560e7af128 fix(library/init/lean/compiler/ir/compilerm): borrow annotations on extern decls do not do anything right now 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
9015fc1e34 chore(library/compiler/ir_interpreter): add step-level trace 2019-09-12 18:26:15 +02:00
Sebastian Ullrich
1a99fc5c5d feat(init/lean/compiler): export some internals 2019-09-12 18:22:02 +02:00
Leonardo de Moura
8e47b6396f chore(library/init/lean/compiler/ir): simplify mkCase, the xType field is set by explicitBoxing 2019-09-12 08:55:09 -07:00
Leonardo de Moura
ca54240843 fix(library/init/lean/compiler/ir): the xType field at FnBody.case must be set by explicitBoxing 2019-09-12 08:47:58 -07:00
Leonardo de Moura
0284d4a7a2 chore(library/compiler/ir): use new mkCase 2019-09-12 08:23:29 -07:00
Leonardo de Moura
a16d3f09cf feat(library/init/lean/compiler/ir): store scrutinee type at FnBody.case 2019-09-12 08:07:47 -07:00
Leonardo de Moura
56e0c0efae chore(library/init/lean/compiler/ir/boxing): apply elimDead 2019-09-11 11:55:38 -07:00
Leonardo de Moura
3aeeadd255 chore(library/init/lean/compiler/ir/boxing): cleanup 2019-09-11 11:11:33 -07:00
Leonardo de Moura
f39220ac01 feat(library/init/lean/compiler/ir/boxing): ignore "cheap" cases when caching boxing operations 2019-09-11 10:56:37 -07:00
Leonardo de Moura
61a3ea61c4 perf(library/init/lean/compiler/ir/boxing): create auxiliary constants for caching the value of boxed/unboxed literals and constants
For example, in the new test `qsort64.lean`, the new optimization
prevents the repeated execution of `box UInt64.inhabited`.
On my machine
```
./run.sh qsort64.lean 2000000
```
Goes from 1.22s to 0.355s
2019-09-11 10:37:35 -07:00
Leonardo de Moura
e8cdd2b29f fix(library/init/lean/compiler/ir/default): missing explicitRC 2019-09-09 10:53:34 -07:00
Leonardo de Moura
f7af9a73bd chore(library/init/lean/compiler/ir): move addBoxedVersion to entry point file 2019-09-09 10:35:52 -07:00
Leonardo de Moura
7dfec3c724 feat(library/init/lean/compiler/ir): add persistent field to inc/dec
If `persistent == true`, then object is known to be persistent at
compilation time. `emitc` omits `inc/dec` operations to
persistent objects. The interpreter does not to avoid memory leaks.
2019-09-09 07:42:06 -07:00
Leonardo de Moura
a188bb8497 chore(library/init/lean/compiler/ir): remove emitcpp 2019-09-07 19:46:22 -07:00
Leonardo de Moura
09d8dd536c fix(library/init/lean/compiler/ir/emitc): invisible unicode character 2019-08-24 07:40:55 -07:00
Leonardo de Moura
db83a52748 chore(library/init/lean/compiler/ir/emitc): cleanup 2019-08-24 07:40:55 -07:00
Leonardo de Moura
70f3537a29 feat(runtime): add lean_panic and variants 2019-08-24 07:40:39 -07:00
Leonardo de Moura
5124ab07c0 feat(library/init/lean/compiler/ir/emitcpp): use extern "C" { in generated files 2019-08-24 07:40:38 -07:00
Leonardo de Moura
b020ca3259 feat(library/init/lean/compiler/ir/emitcpp): allow C++ backend to use @[extern c ...] when @[extern cpp ...] is missing 2019-08-24 07:40:38 -07:00
Leonardo de Moura
41a4eaacd3 fix(runtime, library/init/lean/compiler/ir/emitc): missing export, ensure we can compile with C++ compiler 2019-08-24 07:40:38 -07:00
Leonardo de Moura
78d87cf4cd fix(library/init/lean/compiler/ir/emitcpp): add missing lean::
@kha It is unclear why the C++ compilers were accepting our generated
files without `lean::`. I found the issue by accident while working on
the new C backend.
2019-08-21 09:51:01 -07:00
Leonardo de Moura
25481d5cef chore(runtime/object): preparing for implementing object.h using lean.h 2019-08-20 13:00:18 -07:00
Leonardo de Moura
4405b30cc8 fix(library/init/lean/compiler/ir/emitc): lean_inc 2019-08-20 12:19:31 -07:00
Leonardo de Moura
dbabee0711 fix(library/init): missing "extern c" 2019-08-20 12:02:46 -07:00
Leonardo de Moura
98e6e0c09a feat(library/init): add "extern c" attributes 2019-08-20 11:53:46 -07:00
Leonardo de Moura
6d6cb14f9e feat(library/init/lean/compiler/ir/emitc,shell/lean): add --c=<filename> option 2019-08-20 10:13:40 -07:00
Leonardo de Moura
66304d83a0 chore(library/init/lean/compiler): export as C functions 2019-08-17 06:58:36 -07:00
Leonardo de Moura
4429aac0b3 chore(library/compiler/ir): remove box(13) hack 2019-08-16 20:58:30 -07:00
Leonardo de Moura
ec0e74f5f8 chore(library/init/lean): export as C functions 2019-08-16 20:52:10 -07:00
Leonardo de Moura
8a3522c8e5 chore(library/init/lean/compiler/ir/emitcpp): small hack for exporting functions as C functions instead of C++ 2019-08-16 19:26:03 -07:00
Leonardo de Moura
deecda22bd feat(library/init/lean/compiler/ir/emitc): C code emitter
It will eventually replace emitcpp.lean
2019-08-15 20:29:06 -07:00
Leonardo de Moura
dfa9ca5dc5 chore(library/init/lean/compiler/ir/basic): style 2019-08-09 10:19:35 -07:00
Leonardo de Moura
d00019f57e chore(library/init): fix whitspaces before => 2019-08-09 09:13:49 -07:00
Leonardo de Moura
4d913370a7 chore(library/init): eliminate whitespaces using another patch script 2019-08-09 09:01:39 -07:00