Leonardo de Moura
b7f194d389
feat(library/init/lean/ir): allow arbitrary C++ identifiers to be assigned to declarations
2018-05-13 11:04:42 -07:00
Leonardo de Moura
cfacb515c1
feat(library/init/lean/ir): add IR simple frontend
2018-05-13 10:45:26 -07:00
Leonardo de Moura
1039951b09
fix(library/init/lean/ir/extract_cpp): typo
2018-05-13 10:33:56 -07:00
Leonardo de Moura
1b6d670ad5
chore(library/init/lean/ir/parser): missing decl
2018-05-13 10:33:34 -07:00
Leonardo de Moura
448f6a9ca4
fix(library/init/lean/ir/ssa_check): arguments are "defined" in first basic block
2018-05-13 10:33:00 -07:00
Leonardo de Moura
5c3cbbf2cd
feat(library/init/lean): add lean.closure_max_args
2018-05-13 08:40:46 -07:00
Leonardo de Moura
1ab4c9f8bf
feat(gen/apply): simplify over-application case and avoid quadratic blowup
...
The over-application doesn't occur very often in practice.
The new version adds an extra "copy" step, but it avoids the quadratic
blowup in code size.
Xavier Leroy reports that only 5% of all calls are over-applications
in his experiments.
In Lean3, 6.59% of all calls performed to compile corelib are "over",
and we did not implement any fancy optimization.
2018-05-12 15:10:26 -07:00
Leonardo de Moura
d02c36df18
chore(gen/apply): style
2018-05-11 18:01:58 -07:00
Leonardo de Moura
1d69493b83
feat(gen/apply): add generator for apply
...
It generates the functions at `util/apply.h` that are used by
the Lean runtime.
2018-05-11 17:54:09 -07:00
Leonardo de Moura
0c785f8ab7
feat(library/init/data): add instances for has_repr (id A) and has_to_string (id A)
2018-05-10 17:37:57 -07:00
Leonardo de Moura
224fdc7a78
refactor(library/init/lean/ir): platform dependent IR
...
Motivation: in 64-bit machines, we can store boxed uint32 values as a
tagged pointer. In 32-bit machines, we need to allocated an object (like
Haskell) to store the uint32 value. So, the generated bytecode is quite
different in each platform.
This change also allow us to simplify the IR. Example: we don't need the
type `sizet` anymore.
Impact: To be able to bootstrap in both platforms,
we will have to store two versions of the generated code: 32 and 64
versions. In principle, we only need to store the 64-bit version,
and use cross-compilation to build the 32-bit version.
2018-05-10 13:15:02 -07:00
Leonardo de Moura
552ca3bb11
feat(library/init/lean/ir): allow uint32 in case instruction
2018-05-10 12:56:55 -07:00
Leonardo de Moura
ad61772c72
feat(library/init/lean/ir): add is_null
...
We will use this instruction for compiling inductive datatypes such as
`option A` where `A` is represented as an `object`.
In this case, we can represent `some a` as `a` (without any extra memory
allocation), and `none` as the null pointer.
2018-05-10 12:47:44 -07:00
Leonardo de Moura
aba3d08372
fix(library/init/lean/ir/extract_cpp): minor fixes
2018-05-10 10:54:43 -07:00
Leonardo de Moura
3ce96ae323
chore(tests/lean/parser1): fix test
2018-05-10 10:30:47 -07:00
Leonardo de Moura
9a261975f7
chore(library/init/lean/ir/extract_cpp): cleanup
2018-05-10 10:28:30 -07:00
Leonardo de Moura
e882d9d7cf
feat(library/init/lean/ir): add array_size, sarray_size and string_len
2018-05-10 10:02:16 -07:00
Leonardo de Moura
68458aa97b
refactor(library/init/lean/ir): array operations
2018-05-10 09:52:00 -07:00
Leonardo de Moura
4862da3fca
feat(library/init/lean/ir): add array_pop and sarray_pop
2018-05-10 09:24:48 -07:00
Leonardo de Moura
f1535121b9
refactor(library/init/lean/ir): combine unary instructions
2018-05-10 09:19:13 -07:00
Leonardo de Moura
655cfbf3b0
refactor(library/init/lean/ir): read and sread instructions are now binop
2018-05-10 08:47:16 -07:00
Leonardo de Moura
7b89a8c910
chore(library/init/lean/ir): copy_array ==> array_copy, copy_sarray ==> sarray_copy
2018-05-10 08:36:33 -07:00
Leonardo de Moura
d2c4918ca3
chore(library/init/lean/ir): shared ==> is_shared, scalar ==> is_scalar
2018-05-10 08:30:28 -07:00
Leonardo de Moura
2e0629133f
feat(library/init/lean/ir): add emit_lit
2018-05-09 18:29:54 -07:00
Leonardo de Moura
fc840eab3f
feat(library/init/lean/ir): add emit_unop
2018-05-09 18:20:46 -07:00
Leonardo de Moura
c7153f7661
chore(library/init/lean/ir/extract_cpp): cleanup
2018-05-09 18:03:00 -07:00
Leonardo de Moura
9345765815
feat(library/init/lean/ir/extract_cpp): start IR => C++ extractor
2018-05-09 17:47:55 -07:00
Leonardo de Moura
60c8ff2472
feat(util/lean_obj): add some missing primitives
2018-05-09 17:43:40 -07:00
Leonardo de Moura
7d196f58c3
chore(library/init/lean/ir): remove ashr
2018-05-09 17:43:25 -07:00
Leonardo de Moura
5baae4724f
feat(library/init/lean/ir): distinguish free and dealloc
2018-05-09 17:43:12 -07:00
Leonardo de Moura
8a6d2125b3
chore(library/init/control/combinators): remove top-level mmap and related combinators
...
The top-level `mmap` should use the `traversable` typeclass that will be
defined in the future.
2018-05-09 15:49:13 -07:00
Leonardo de Moura
3be7540efe
chore(library/init): use mfor instead of mmap'
2018-05-09 15:41:53 -07:00
Leonardo de Moura
63bddd56d6
feat(library/init/data/rbmap,library/init/data/rbtree): add mfold and mfor for rbtree/rbmap
2018-05-09 15:38:57 -07:00
Leonardo de Moura
014735e498
feat(library/init/control/combinators): remove unnecessary universe constraint from list.mmap'
...
This commit also adds the alias `mfor` for `mmap'`
2018-05-09 15:38:35 -07:00
Leonardo de Moura
6368d0c5f6
chore(library/init/lean/name_mangling): allow custom prefix when mangling names
2018-05-09 15:01:12 -07:00
Leonardo de Moura
83415ea44c
feat(library/init/control/except): add instance has_monad_lift (except ε) (except_t ε m)
2018-05-09 12:19:44 -07:00
Leonardo de Moura
d5fd86791d
chore(tests/lean/run/ext_eff*): reduce number of iterations
...
My machine was taking forever to run these tests in debug mode.
2018-05-09 10:52:33 -07:00
Leonardo de Moura
14e19502f0
chore(tests/lean/run/type_class_performance1): remove #exit
2018-05-09 10:24:45 -07:00
Leonardo de Moura
f8cedb33e7
fix(library/type_context): bug introduced at d85c30fde1
2018-05-09 10:18:53 -07:00
Leonardo de Moura
d05e93f763
test(tests/lean/run/name_mangling): add tests for name mangling
2018-05-09 10:10:00 -07:00
Leonardo de Moura
0c0972f317
feat(library/init/lean): name mangling
2018-05-09 09:19:32 -07:00
Leonardo de Moura
3f883bd949
chore(library/init/lean/parser/parser): add monad_fail instance
2018-05-09 09:19:14 -07:00
Leonardo de Moura
874f9caf13
feat(library/init/control/state): modify monad_run instance for state_t
...
@Kha, I was having to use `(run ...).1` in many places
in my code. So, I changed the instance
```
instance (σ m out) [monad_run out m] : monad_run (λ α, σ → out (α × σ)) (state_t σ m) :=
⟨λ α x, run ∘ (λ σ, x.run σ)⟩
```
to
```
instance (σ : Type u) (m out : Type u → Type v) [functor m] [monad_run out m] : monad_run (λ α, σ → out α) (state_t σ m) :=
⟨λ α x, run ∘ (λ σ, prod.fst <$> (x.run σ))⟩
```
If we want to get the resultant state in an action `act`, we can just
use `run (act >> get) init_state`.
2018-05-08 17:32:54 -07:00
Leonardo de Moura
b0641ba770
feat(frontends/lean/elaborator): add support for definitions such as monad_run.run
...
cc @Kha
2018-05-08 17:14:52 -07:00
Leonardo de Moura
b77cd740a8
test(tests/lean/run/display_hw_term_hack_deps): add helper function for displaying functions that use wf_term_hack
2018-05-08 16:28:42 -07:00
Leonardo de Moura
ab39ef261d
refactor(library/init/lean/ir/ssa_check): use format instead of blockid_error
2018-05-08 15:47:02 -07:00
Leonardo de Moura
60a275a464
chore(library/init/lean/ir/elim_phi): use idiom: define run for every monad
2018-05-08 15:46:30 -07:00
Leonardo de Moura
7f85f0893c
refactor(library/init/lean/ir): cleanup
2018-05-08 15:38:43 -07:00
Leonardo de Moura
4f75e49da8
feat(library/init/control/except): add monad_except _ except instance
2018-05-08 15:38:20 -07:00
Leonardo de Moura
00147df082
chore(library/init/lean/ir/ssa_check): use format for error messages
2018-05-08 14:50:58 -07:00