Commit graph

45 commits

Author SHA1 Message Date
Henrik Böving
a47eb31076
chore: remove the LCNF testing framework (#12207)
This PR removes the LCNF testing framework. Unfortunately it never got
used much and porting it to
the extended LCNF structure now would be a bit of effort that would
ultimately be in vain.
2026-01-28 10:09:30 +00:00
Henrik Böving
dc70d0cc43
feat: split up the compiler SCC after lambda lifting (#12003)
This PR splits up the SCC that the compiler manages into (potentially)
multiple ones after
performing lambda lifting. This aids both the closed term extractor and
the elimDeadBranches pass as
they are both negatively influenced when more declarations than required
are within one SCC.
2026-01-14 18:36:25 +00:00
Henrik Böving
52b1b342ab
feat: zero cost BaseIO (#10625)
This PR implements zero cost `BaseIO` by erasing the `IO.RealWorld`
parameter from argument lists and structures. This is a **major breaking
change for FFI**.

Concretely:
- `BaseIO` is defined in terms of `ST IO.RealWorld`
- `EIO` (and thus `IO`) is defined in terms of `EST IO.RealWorld`
- The opaque `Void` type is introduced and the trivial structure
optimization updated to account for it. Furthermore, arguments of type
`Void s` are removed from the argument lists of the C functions.
- `ST` is redefined as `Void s -> ST.Out s a` where `ST.Out` is a pair
of `Void s` and `a`

This together has the following major effects on our generated code:
- Functions that return `BaseIO`/`ST`/`EIO`/`IO`/`EST` now do not take
the dummy world parameter anymore. To account for this FFI code needs to
delete the dummy world parameter from the argument lists.
- Functions that return `BaseIO`/`ST` now return their wrapped value
directly. In particular `BaseIO UInt32` now returns a `uint32_t` instead
of a `lean_object*`. To account for this FFI code might have to change
the return type and does not need to call `lean_io_result_mk_ok` anymore
but can instead just `return` values right away (same with extracting
values from `BaseIO` computations.
- Functions that return `EIO`/`IO`/`EST` now only return the equivalent
of an `Except` node which reduces the allocation size. The
`lean_io_result_mk_ok`/`lean_io_result_mk_error` functions were updated
to account for this already so no change is required.

Besides improving performance by dropping allocation (sizes) we can now
also do fun new things such as:
```lean
@[extern "malloc"]
opaque malloc (size : USize) : BaseIO USize
```
2025-10-22 10:55:12 +02:00
Joachim Breitner
232a0495b0
chore: remove public section from end of files (#10684)
This PR removes `public section` lines from end of files; they look a
bit silly there.
2025-10-06 13:30:48 +00:00
Sebastian Ullrich
ff1d3138bf
refactor: module-ize Lean (#9330) 2025-07-25 12:02:51 +00:00
Markus Himmel
781c94f2cf
chore: test that there are no orphaned modules (#8082)
This PR adds a test that makes sure that there are no orphaned modules.
2025-04-24 11:55:07 +00:00
Cameron Zwarich
7530fd6955
chore: remove Lean.Compiler.LCNF.ForEachExpr (#6313)
Co-authored-by: Cameron Zwarich <cameron@lean-fro.org>
2024-12-13 23:58:42 +00:00
Henrik Böving
23e49eb519 perf: add prelude to all Lean modules 2024-02-18 14:55:17 -08:00
Leonardo de Moura
defd544d5d feat: add collectUsedParams 2022-10-16 14:20:32 -07:00
Leonardo de Moura
eeb98d9cf4 refactor: rename FixedArgs => FixedParams 2022-10-09 12:10:11 -07:00
Leonardo de Moura
79683c4bf6 chore: missing imports 2022-10-07 18:11:19 -07:00
Leonardo de Moura
b172ba8a34 feat: add toMono pass
It has to activate by default yet.
2022-10-05 10:39:41 -07:00
Leonardo de Moura
190a1331bd feat: add toMonoType 2022-10-01 20:44:31 -07:00
Leonardo de Moura
b4454902c1 feat: LCNF Code.forEachExpr and Decl.forEachExpr 2022-09-29 15:50:49 -07:00
Leonardo de Moura
002c7d2f22 feat: configuration options for the code generator 2022-09-27 16:26:49 -07:00
Leonardo de Moura
236885e72e chore: remove Stage1 2022-09-25 13:17:50 -07:00
Leonardo de Moura
aa17641f18 chore: LCNF imports 2022-09-23 07:05:57 -07:00
Leonardo de Moura
44c67f72c1 feat: add LCNF/SpecInfo.lean 2022-09-11 20:19:44 -07:00
Leonardo de Moura
e78820e6a5 feat: add mkFixedArgMap 2022-09-11 20:19:44 -07:00
Leonardo de Moura
1953f5953f chore: dangling file 2022-09-10 13:23:14 -07:00
Leonardo de Moura
3a2758a59b refactor: new LCNF frontend 2022-08-24 11:40:37 -07:00
Leonardo de Moura
df89717ae3 perf: custom isTypeFormerType for toLCNF translation 2022-08-21 12:45:37 -07:00
Leonardo de Moura
36cca3ebdd perf: add toLCNFType cache 2022-08-19 18:49:33 -07:00
Leonardo de Moura
0b2d013beb chore: remove leftover 2022-08-18 17:39:29 -07:00
Leonardo de Moura
18c95e8322 fix: bug at toLCNF cache 2022-08-17 17:16:13 -07:00
Leonardo de Moura
daa833d5c9 feat: preserve internal let-declaration binder names 2022-08-16 18:23:49 -07:00
Leonardo de Moura
e876d81692 fix: missing withRoot true 2022-08-16 18:23:49 -07:00
Leonardo de Moura
327442a85c feat: add mkFreshBinderName and use it to normalize internal names 2022-08-15 19:47:37 -07:00
Leonardo de Moura
e931c6b5b5 fix: bug at toLCNF 2022-08-15 12:59:36 -07:00
Leonardo de Moura
4f79d2caa0 feat: improve toLCNF
Preserve type formers only if they are application arguments
2022-08-15 09:53:48 -07:00
Leonardo de Moura
6c5638d85b fix: bug at toLCNF 2022-08-13 15:22:22 -07:00
Leonardo de Moura
9b1db198af fix: bug at toLCNF 2022-08-13 10:30:12 -07:00
Leonardo de Moura
0a423b3699 fix: ensure the the terminal expression in let-declaration block is not a lambda 2022-08-13 09:47:59 -07:00
Leonardo de Moura
77735e62f5 chore: remove leftovers 2022-08-11 18:40:13 -07:00
Leonardo de Moura
5dbb907b56 feat: new toLCNF 2022-08-11 18:40:13 -07:00
Leonardo de Moura
6a67c13044 feat: generalize helper functions 2022-08-11 18:40:13 -07:00
Leonardo de Moura
3d79581f6b feat: basic LCNF conversion 2022-08-11 18:40:13 -07:00
Leonardo de Moura
e67a43ab01 refactor: disable old LCNF and TerminalCases
TODO: finish porting them to the new format.
2022-08-10 20:25:59 -07:00
Leonardo de Moura
3c6c395e44 feat: add TerminalCases.lean 2022-08-07 22:05:19 -07:00
Leonardo de Moura
7359f95088 refactor: treat casesOn and matcher applications uniformly 2022-08-07 18:04:38 -07:00
Leonardo de Moura
c16bec6e30 refactor: move auxiliary let declaration support to CompilerM.lean 2022-08-07 17:27:40 -07:00
Leonardo de Moura
ee70805c35 feat: add LCNF missing cases 2022-08-06 20:23:29 -07:00
Leonardo de Moura
c5b5a1c6f9 chore: generate auxiliary variable names manually at LCNF.lean 2022-08-06 20:20:50 -07:00
Leonardo de Moura
bf59ad0efc feat: add new compiler entry point function 2022-08-06 08:05:07 -07:00
Leonardo de Moura
9a16d4afce feat: add CompilerM.lean and LCNF.lean 2022-08-05 21:14:39 -07:00