Commit graph

608 commits

Author SHA1 Message Date
Leonardo de Moura
39f45beec0 chore(library/compiler/llnf): fix typo 2019-01-31 17:52:59 -08:00
Leonardo de Moura
0f47787a06 fix(library/compiler/llnf): remove bad optimization
It may destroy boxed value information. Moreover, we want
terminals to be jmp, variable or cases.
2019-01-31 17:52:28 -08:00
Leonardo de Moura
94d7b4e094 fix(library/compiler/emit_cpp): support for _unreachable 2019-01-31 17:05:52 -08:00
Leonardo de Moura
a1b65acf3d fix(library/compiler/builtin): add lean:: prefix
TODO: we will need to revise this for the LLVM backend.
In principle, builtins that are used by LLVM and C++ backends should be
`extern "C"` in a global namespace.
2019-01-31 16:57:25 -08:00
Leonardo de Moura
353d16f5f6 fix(library/compiler/emit_cpp): mpz ==> lean::mpz 2019-01-31 16:57:07 -08:00
Leonardo de Moura
5f29b1003b fix(library/compiler/emit_cpp): missing enf_unreachable case 2019-01-31 16:37:02 -08:00
Leonardo de Moura
4166851574 feat(library/compiler/emit_cpp): emit_box and emit_unbox 2019-01-31 16:16:30 -08:00
Leonardo de Moura
78842d8d03 feat(library/compiler/emit_cpp): emit_proj, emit_sproj, emit_uproj, emit_sset, emit_uset 2019-01-31 15:38:53 -08:00
Leonardo de Moura
80754e84c5 feat(library/compiler/emit_cpp): emit_closure 2019-01-31 15:06:04 -08:00
Leonardo de Moura
74079cb591 feat(library/compiler/emit_cpp): emit_lit 2019-01-31 14:54:43 -08:00
Leonardo de Moura
34256795d7 feat(library/compiler/emit_cpp): emit_reuse 2019-01-31 14:54:35 -08:00
Leonardo de Moura
7c3354f15f feat(library/compiler/emit_cpp): emit_reset 2019-01-31 12:33:17 -08:00
Leonardo de Moura
909a8d7c6d fix(library/compiler/llnf): bug at to_llnf when boxing is enabled 2019-01-30 16:48:04 -08:00
Leonardo de Moura
d63bbb3728 feat(library/compiler/emit_cpp): emit_cnstr 2019-01-30 15:47:38 -08:00
Leonardo de Moura
d2cbf9584f feat(library/compiler/emit_cpp): emit _apply instruction 2019-01-30 14:37:21 -08:00
Leonardo de Moura
efcc459c3b fix(library/compiler/emit_cpp): emit_constant should handle neutral 2019-01-30 14:36:14 -08:00
Leonardo de Moura
1673775c6e fix(library/compiler/cse): make sure cse produces correct result in LLNF expressions
In LLNF, we must take the type of a let-declaration into account. For
example, we cannot merge the following declarations:

```
x_1 : uint8 := _cnstr.0.0.0
x_2 : _obj  := _cnstr.0.0.0
```

We were producing incorrect C++ code for
library/init/lean/parser/token.lean because of this bug.
2019-01-30 13:52:43 -08:00
Leonardo de Moura
69eea3d225 fix(library/compiler/emit_cpp): missing collect_dependencies 2019-01-29 16:41:32 -08:00
Leonardo de Moura
38172c8f1c feat(library/compiler/emit_cpp): use if statement when cases has only 2 cases 2019-01-29 16:32:23 -08:00
Leonardo de Moura
e4c4eab48e fix(library/compiler/emit_cpp): collect_dependencies was not handling _closure instruction 2019-01-29 16:31:29 -08:00
Leonardo de Moura
20641731e3 feat(library/compiler/emit_cpp): add emit_instr skeleton 2019-01-29 16:04:50 -08:00
Leonardo de Moura
706f4cb01b fix(library/compiler/builtin): incorrect builtin type 2019-01-29 16:04:02 -08:00
Leonardo de Moura
48b03672cc feat(library/compiler/emit_cpp): emit terminals 2019-01-29 15:15:05 -08:00
Leonardo de Moura
9f8760d936 fix(library/compiler/llnf): LLNF terminal is variable, jmp, or cases 2019-01-29 14:59:12 -08:00
Leonardo de Moura
61e51ba402 fix(library/compiler/llnf): adjust code, now type must match arity
We recently modified the type of closures in LLNF.
This commit fixes a mismatch.
2019-01-28 15:55:01 -08:00
Leonardo de Moura
0e8067e191 fix(library/compiler/compiler): ensure_arity bug 2019-01-28 15:42:23 -08:00
Leonardo de Moura
371baf2002 fix(library/compiler/compiler): typo 2019-01-28 15:34:58 -08:00
Leonardo de Moura
1f3201dca1 feat(library/compiler): add emit_fn_fn skeleton 2019-01-28 15:04:56 -08:00
Leonardo de Moura
d3756fd915 feat(library/compiler): add _void type for LLNF format 2019-01-28 13:06:25 -08:00
Leonardo de Moura
274aeed30f fix(library/compiler/compiler): make sure that the type of functions that return closures match their arity
Before this commit, we could have a LLNF function `f` of arity 0 and
type `_obj -> _obj`. Now, this kind of function has type `_obj`.
2019-01-25 15:40:25 -08:00
Leonardo de Moura
dd30cac8aa feat(library/compiler/emit_cpp): emit module initialization function 2019-01-25 15:24:55 -08:00
Leonardo de Moura
5bed81078a feat(library/compiler/emit_cpp): generate function skeletons 2019-01-25 14:26:32 -08:00
Leonardo de Moura
b36b4f0d80 feat(library/compiler/emit_cpp): emit function headers 2019-01-25 14:26:32 -08:00
Leonardo de Moura
2016e1bce5 feat(library/compiler/llnf): unique names for lambda arguments 2019-01-25 14:26:32 -08:00
Leonardo de Moura
4b66b442c9 chore(library/compiler/emit_cpp): just store a list of decls 2019-01-25 14:26:32 -08:00
Leonardo de Moura
bb9e7aceb3 feat(library/compiler/emit_cpp): add environment extension for emit_cpp 2019-01-24 16:04:31 -08:00
Leonardo de Moura
70bb89b213 feat(library/compiler): add [cppname] attribute 2019-01-24 14:40:12 -08:00
Leonardo de Moura
eace1bacb3 refactor(library/compiler): move name mangling procedures to separate file
We will need them to implement the LLVM IR backend.
2019-01-24 13:57:13 -08:00
Leonardo de Moura
f5f6a7f85e feat(library/compiler/emit_cpp): take module name and (direct) dependencies as arguments 2019-01-23 16:34:04 -08:00
Leonardo de Moura
02849a3cf6 feat(library/compiler/emit_cpp): add name mangling functions 2019-01-23 14:46:04 -08:00
Leonardo de Moura
8bcc965dc0 feat(library/compiler): make sure we emit bytecode and C++ 2019-01-23 14:13:04 -08:00
Leonardo de Moura
320917cca5 feat(library/compiler): add emit_cpp skeleton 2019-01-23 14:01:43 -08:00
Leonardo de Moura
afd30d73c1 chore(library/compiler/compiler): generate Lean IR with explicit boxing and RC instructions
This is just for testing. These two steps are not used by `emit_bytecode`,
but they will be used to generate C++ code.
We can now compile the whole corelib in debug mode with these two extra
transformation without any assertion violation.
2019-01-18 16:01:47 -08:00
Leonardo de Moura
fe68547086 fix(library/compiler/llnf): missing instruction _uproj at explicit_rc_fn 2019-01-18 16:00:08 -08:00
Leonardo de Moura
1293d976f7 fix(library/compiler/util): usize case was missing at to_uint_type 2019-01-18 15:50:14 -08:00
Leonardo de Moura
a001806996 feat(library/compiler/compiler): generate boxed version of builtin constants 2019-01-18 15:43:06 -08:00
Leonardo de Moura
aaf1966a87 fix(library/compiler/llnf): explicit boxing should treat variables with function type (e.g., _obj -> _obj) as _obj 2019-01-18 15:07:01 -08:00
Leonardo de Moura
9ea7b77fe0 fix(library/compiler/llnf): typo 2019-01-17 17:10:52 -08:00
Leonardo de Moura
1d0d17d4ae fix(library/compiler/llnf): bug at explicit boxing transformation 2019-01-17 16:58:22 -08:00
Leonardo de Moura
1b59fed1d9 fix(library/compiler/llnf): bug at x := _proj y
We must increment `x`'s RC before (if needed) we decrement `y`'s RC
2019-01-17 15:23:52 -08:00