Compare commits

...

429 Commits
ep3 ... master

Author SHA1 Message Date
Sameer Rahmani c1917e56fa
Simplify the Nix toolchain 2024-05-17 18:27:36 +01:00
Sameer Rahmani 4b38dbb145
Reformat the cmake files 2024-05-17 18:20:17 +01:00
Sameer Rahmani f377e0d4d5
nix: Move the overlayes to a module and lock nixpkgs 2024-04-07 22:32:36 +01:00
Sameer Rahmani b59e4ab315
nix: Add git-hooks to the flake file 2024-04-06 22:40:08 +01:00
Sameer Rahmani 45b2a7805b
Migrate to llvm18 2024-04-06 20:05:01 +01:00
Sameer Rahmani 8f46ca7744
Add latex and math setup to flake.nix 2024-01-28 22:01:19 +00:00
Sameer Rahmani eeb858aec8
Remove the builder script 2024-01-26 20:21:15 +00:00
Sameer Rahmani 9b377a0a3a
Break up the builder script and add the math shell 2024-01-26 20:20:46 +00:00
Sameer Rahmani 99586477e0
Break up dependencies in different groups 2024-01-16 17:23:26 +00:00
Sameer Rahmani b238c69288
Clean up the builder script to replace functionalities with nix 2024-01-16 11:23:09 +00:00
Sameer Rahmani 2e230b9474
Remove redundant bash script from 'scripts' dir 2024-01-16 00:15:54 +00:00
Sameer Rahmani 7c62a58271
Update the license header to 2024 2024-01-15 23:53:22 +00:00
Sameer Rahmani 46d5893733
nix: Remove our version of llvm 2024-01-14 22:00:26 +00:00
Sameer Rahmani 3f87aecff9
nix: Clean up the flake file 2024-01-14 21:47:50 +00:00
Sameer Rahmani 675dced870
Create a flake with all the required dependencies to build Serene 2024-01-14 19:58:43 +00:00
Sameer Rahmani 8aebc244f6
Create a big llvm package that contains everything 2024-01-10 18:21:36 +00:00
Sameer Rahmani 35fe40f5d0
nix: Build libcxx, libcxxabi and libunwind 2023-12-21 22:51:47 +00:00
Sameer Rahmani 75c3fff58e
Add the serene_llvm package as the default toolchain 2023-12-03 22:03:33 +00:00
Sameer Rahmani 5797bc2615
Create a LLVM based stdenv 2023-12-03 19:00:20 +00:00
Sameer Rahmani 9622dc8382
Add a flake.nix to replace our current dev environment
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-11-25 21:18:22 +00:00
Sameer Rahmani 3e2aaea218
Replace catch2 with google test 2023-08-15 21:50:16 +01:00
Sameer Rahmani 97c1b3e7c1
move ast related files to its directory
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-08-13 20:12:07 +01:00
Sameer Rahmani 6cfe47b6d6
Clean up the source manager 2023-08-12 20:54:07 +01:00
Sameer Rahmani 9d894b662b
Implement a simpler error model
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-08-11 22:41:20 +01:00
Sameer Rahmani b1cca14433
Move over namespace, ast, and the reader
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-08-08 22:32:29 +01:00
Sameer Rahmani 47c52d0488
Update the CI script to match the new woodpecker changes
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-08-04 00:31:19 +01:00
Sameer Rahmani d54835a961
Remove the old libserene implementations
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
ci/woodpecker/manual/docs Pipeline failed Details
ci/woodpecker/manual/build Pipeline failed Details
2023-07-30 15:12:56 +01:00
Sameer Rahmani 1ef8a5f0ca
jit: Remove LLLazyJIT and LLJIT variant. Stick to LLJIT for now 2023-07-29 15:16:19 +01:00
Sameer Rahmani 6ec0a26a51
Make C++20 the default 2023-07-29 15:11:52 +01:00
Sameer Rahmani 28c98e585b
Fix the JIT_LOG macro's name 2023-07-25 22:34:50 +01:00
Sameer Rahmani 4886a9644b
Remove the deprecated BOM check from precommit hook
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-07-25 22:30:57 +01:00
Sameer Rahmani 9c3228fffc
Add two useful links to the list of resources
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-07-25 22:28:41 +01:00
Sameer Rahmani 48e97095c7
Remove the old bash based include fixer with a better python version
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-07-25 22:24:26 +01:00
Sameer Rahmani 7fb2125c4b
Move triples to the Options class 2023-07-25 22:23:37 +01:00
Sameer Rahmani e9012b7583
Move the functionality of the old SereneContext to JIT itself 2023-07-23 20:10:04 +01:00
Sameer Rahmani 7a4e76fe08
Move over the SereneContext and a base JIT implementanio
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
ci/woodpecker/manual/build Pipeline was successful Details
ci/woodpecker/manual/docs Pipeline was successful Details
2023-07-21 23:23:16 +01:00
Sameer Rahmani 839125eb18
Add a couple of links for Curry-Howard correspondence
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-07-11 18:33:23 +01:00
Sameer Rahmani 752be41a9d
Update the readme with no to github badge
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-07-11 18:30:00 +01:00
Sameer Rahmani 51a5d4c0b9
docs: Add the missing getting started markdown file
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-05-27 22:13:58 +01:00
Sameer Rahmani 25852a5f3f
docs: Move the getting started guide to the docs
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-05-27 22:06:11 +01:00
Sameer Rahmani 3cdaaebff2
docs: Disable the light mode (who needs it?)
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-05-27 20:17:07 +01:00
Sameer Rahmani 83e3744362
Convert the read me to markdown
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-05-27 20:10:45 +01:00
Sameer Rahmani 3cdc4e6f80
docs: Fix the edit link of the articles
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-05-27 19:55:24 +01:00
Sameer Rahmani 3379abb0dc
ci: Add a pipeline to build and deploy the docs
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/docs Pipeline was successful Details
2023-05-27 19:36:21 +01:00
Sameer Rahmani 01fd49524b
docs: Move the mkdocs pages to docs/pages
ci/woodpecker/push/build Pipeline was successful Details
2023-05-27 17:15:12 +01:00
Sameer Rahmani 38a9481f04
docs: Move some of the development resources to the docs
ci/woodpecker/push/build Pipeline was successful Details
2023-05-24 23:11:16 +01:00
Sameer Rahmani 6610a05b82
docs: Finalize the mkdocs setup
ci/woodpecker/push/build Pipeline was successful Details
2023-05-19 19:19:30 +01:00
Sameer Rahmani db58f73d7c
docs: Add a very basic mkdocs setup
ci/woodpecker/push/build Pipeline was successful Details
2023-05-18 00:43:19 +01:00
Sameer Rahmani cd1c675b51
docs: Remove the sphinx setup 2023-05-17 23:48:33 +01:00
Sameer Rahmani 6919c02ada
Add the skeleton of th subcommand system
ci/woodpecker/push/build Pipeline was successful Details
2023-05-17 23:12:03 +01:00
Sameer Rahmani 990de49c23
Move back the llvm setup to the main cmake config as suggested by llvm itself 2023-05-17 21:27:15 +01:00
Sameer Rahmani 66da4b5401
ci: Fix the notify step conditions for wpnext
ci/woodpecker/push/build Pipeline was successful Details
2023-05-15 21:56:10 +01:00
Sameer Rahmani 09e16bd43e
ci: Move to v13 of CI image 2023-05-14 22:44:50 +01:00
Sameer Rahmani b66ed56a01
ci: Add the mailer step to notify pipeline
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/notify unknown status Details
2023-05-14 11:13:33 +01:00
Sameer Rahmani 263e3f7384
Add bunch of resources to the devs.org
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/notify unknown status Details
2023-05-14 11:11:13 +01:00
Sameer Rahmani 4409f117b2
ci: Upgrade build to tag 10 2023-05-14 11:11:08 +01:00
Sameer Rahmani fb7f010f7d
ci: Remove the on success condition on notify
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/notify unknown status Details
ci/woodpecker/manual/build Pipeline failed Details
ci/woodpecker/manual/lint Pipeline was successful Details
ci/woodpecker/manual/notify unknown status Details
2023-05-13 21:51:12 +01:00
Sameer Rahmani 68a7c1da58
ci: Remove the 'evaluate' syntax from notify
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/notify Pipeline was successful Details
2023-05-13 21:48:28 +01:00
Sameer Rahmani b22a2bd0b6
ci: Add the notify pipeline 2023-05-13 21:44:32 +01:00
Sameer Rahmani 476e17f5d9
ci: Disable ccache on the ci
ci/woodpecker/push/build Pipeline was successful Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-05-12 20:04:22 +01:00
Sameer Rahmani 963fc89f64
ci: Build again with a (cmake/ninja)less toolchain
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline failed Details
2023-05-12 19:55:17 +01:00
Sameer Rahmani e74e3b583b
Add the ci link to the readme
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-05-12 19:15:57 +01:00
Sameer Rahmani 4ae7e0e0d5
ci: Clean up the volume
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-05-12 19:13:04 +01:00
Sameer Rahmani 280ecb4be4
ci: Update the build workflow
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-05-12 19:04:09 +01:00
Sameer Rahmani 16bcbd4945
Update the read me file with the new build instructions
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-05-12 18:59:55 +01:00
Sameer Rahmani 280cd9b7da
Remove the redundant deps.sh
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-05-12 18:41:20 +01:00
Sameer Rahmani 8d0e979b5f
builder: Add support for automatic toolchain setup 2023-05-12 18:41:06 +01:00
Sameer Rahmani 59f54b5678
Clean up main cmake scripts 2023-05-12 18:38:58 +01:00
Sameer Rahmani a011bb330a
Clean up the source tree from toolchain building scripts
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-05-12 18:34:24 +01:00
Sameer Rahmani 9c9a925a52
Update the toolchain.sh script to pull down and unpack the toolchain
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-05-09 22:01:36 +01:00
Sameer Rahmani e2bed17c0d
toolchain: Create a build script for stage0 compiler and runtimes 2023-03-16 23:12:49 +00:00
Sameer Rahmani 036c767cbd
Fix the lto setup for the serene build script 2023-03-09 11:10:10 +00:00
Sameer Rahmani 639d340f46
builder: Setup the cache file for serene binary 2023-03-08 20:54:30 +00:00
Sameer Rahmani a98065c2f9
deps: Fix musl installer script 2023-03-08 20:52:13 +00:00
Sameer Rahmani 892117b010
toolchain: make lld the default linker 2023-03-08 20:51:35 +00:00
Sameer Rahmani 1d26409923
builder: Add the cache file for the development version 2023-03-07 13:40:33 +00:00
Sameer Rahmani a8d8de611a
toolchain: Fallback on a single stage toolchain without LTO 2023-03-07 11:47:04 +00:00
Sameer Rahmani a8e938eab2
toolchain: Save the progress to move it to single stage toolchain 2023-03-05 18:01:31 +00:00
Sameer Rahmani 674543e797
toolchain: setup the correct triple for stage1 compiler 2023-03-04 16:31:28 +00:00
Sameer Rahmani 41078cba61
toolchain: Find the proper flags for stage2 build (dirty) 2023-03-04 15:46:44 +00:00
Sameer Rahmani eb72c2d075
[WIP] Add the placeholder for the new statically linked serene
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-25 11:27:35 +00:00
Sameer Rahmani 365f49368b
[WIP] builder: Add the scripts to build a musl and libc++ based toolchain
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-25 11:26:19 +00:00
Sameer Rahmani 157869a43a
dev.org: Add the resources on toolchain and crosscompilation 2023-02-25 11:22:00 +00:00
Sameer Rahmani 99cd012e13
builder: Add musl to the list of dependencies 2023-02-21 16:20:15 +00:00
Sameer Rahmani 034db2ec0c
builder: Use the builder script to hold the version of dependencies 2023-02-21 14:44:25 +00:00
Sameer Rahmani a371c5e7fa
deps: Remove all the submodules to try subtrees 2023-02-20 22:55:58 +00:00
Sameer Rahmani 65a6f1aba9
deps: Remove the incorrect git modules 2023-02-20 22:45:28 +00:00
Sameer Rahmani 4ec2e35ed8
builder: Add a dummy linux toolchain file
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-10 19:58:23 +00:00
Sameer Rahmani 4d5027d13d
builder: Add to new cmake vars to control libcxx usage
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-10 17:42:12 +00:00
Sameer Rahmani fe8b1763a3
deps: Change the iwyu repo to our own fork 2023-02-10 17:40:56 +00:00
Sameer Rahmani ba575d6899
deps: Run various LLVM tests as part of the build process 2023-02-10 17:39:57 +00:00
Sameer Rahmani 5284ea4d92
deps: Update iwyu to our own patch to fix Triple.h path 2023-02-10 17:39:19 +00:00
Sameer Rahmani 5d1c7d8e23
Fix the Triple.h include in iwyu 2023-02-08 15:04:28 +00:00
Sameer Rahmani b9af5cff77
llvm: Update the llvm version 2023-02-08 14:38:06 +00:00
Sameer Rahmani 2cfc1e8c09
builder: Add libc++ as the standard cpp lib
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-06 18:08:25 +00:00
Sameer Rahmani 36f8e59c2b
builder: Unset the 'x' parameter 2023-02-06 18:01:31 +00:00
Sameer Rahmani c59aa96ca5
builder: Fix the bug with CC and an env with no compiler
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-06 18:00:33 +00:00
Sameer Rahmani dc61b42d57
Fix the license header for 2023
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-06 17:40:45 +00:00
Sameer Rahmani 87d227ac6f
Fix all the conversion warnings 2023-02-06 17:11:20 +00:00
Sameer Rahmani dc746f7a8c
Enable more warning flags
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-06 15:44:19 +00:00
Sameer Rahmani 8842dd4ebb
Fix all IWUY warnings 2023-02-06 15:44:19 +00:00
Sameer Rahmani 72c3b0ce16
builder: Fix the bug with compiler selection
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-06 13:37:24 +00:00
Sameer Rahmani 852071c229
llvm: Update llvm to recent master 2023-02-05 21:23:12 +00:00
Sameer Rahmani 9fdde72496
jit: Fix a couple of warning in the JIT
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-05 21:02:18 +00:00
Sameer Rahmani 7993e6ac1c
builder: Give up on automatically setup the dev env
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-05 19:17:31 +00:00
Sameer Rahmani d8721ec5e6
Remove CXX flags from setup_env
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-05 17:35:16 +00:00
Sameer Rahmani 0bbb996e4a
CI: Enable libc++
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-04 21:16:05 +00:00
Sameer Rahmani 1bbdb054b3
CI: Enable libc++
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-04 21:13:14 +00:00
Sameer Rahmani a43e2032ae
CI: Add an inspect statement to the builder
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-04 21:01:28 +00:00
Sameer Rahmani ea0660acbd
CI: Add a failure step
ci/woodpecker/push/build Pipeline failed Details
ci/woodpecker/push/lint Pipeline was successful Details
2023-02-04 20:57:15 +00:00
Sameer Rahmani 45cc991891
Stop trying to automate the dependency activation
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-04 20:33:27 +00:00
Sameer Rahmani 90c59443bf
deps: Replace the 'describe' base version to commit sha 2023-02-04 20:32:55 +00:00
Sameer Rahmani abf3c912f5
Remove the unrelible activate script 2023-02-04 20:30:07 +00:00
Sameer Rahmani 1205146349
CI: Updathe the image to v9
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-04 01:23:41 +00:00
Sameer Rahmani 80f074e70d
CI: Updathe the image to v8
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-04 01:10:34 +00:00
Sameer Rahmani ec692c6ccd
CI: Updathe the image to v7
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-04 00:59:32 +00:00
Sameer Rahmani 15d4449c26
CI: Add debug statements in the activate script
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-04 00:48:18 +00:00
Sameer Rahmani 7ee1cda15e
CI: Avoid cloning the submodules for the linter pipeline 2023-02-04 00:45:09 +00:00
Sameer Rahmani a2862bb667
CI: Fix the build pipeline's file name
ci/woodpecker/push/lint Pipeline failed Details
ci/woodpecker/push/build Pipeline failed Details
2023-02-04 00:36:13 +00:00
Sameer Rahmani 74358a372a
CI: Trigger Pipeline 2023-02-04 00:33:49 +00:00
Sameer Rahmani 7f280e463c
CI: Split the pipeline into build and lint 2023-02-04 00:31:41 +00:00
Sameer Rahmani d3dc844e9a
Fix the get_version function to include the full commit sha 2023-02-04 00:22:26 +00:00
Sameer Rahmani 154ab2573f
deps: Disbale quiet mode of http_pull
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 23:58:51 +00:00
Sameer Rahmani 23aff71e2a
CI: Updathe the image to v6
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 23:47:45 +00:00
Sameer Rahmani 2bfe70dd51
deps: Fail the process as soon as http_pull fails
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 23:33:46 +00:00
Sameer Rahmani 60b1e67e91
CI: Update the image to v5 2023-02-03 23:33:15 +00:00
Sameer Rahmani 5deb5b4e03
builder: Add a initialization step
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 23:19:43 +00:00
Sameer Rahmani 3ba23f708f
CI: Add the build step
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 23:10:49 +00:00
Sameer Rahmani 1cdf4336d1
CI: Update the CI image to 4 and attach the serene volume 2023-02-03 22:16:30 +00:00
Sameer Rahmani 475cb725b4
builder: Remove any reference to CC, CXX from builder
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 22:05:35 +00:00
Sameer Rahmani 4d9c6f3971
CI: Update the ci image tag to v3
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 20:57:17 +00:00
Sameer Rahmani 8153f7884e
CI: Update the ci image tag
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 20:44:51 +00:00
Sameer Rahmani 9bc8086f06
CI: Update the images to use our custom image
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 20:39:06 +00:00
Sameer Rahmani 798077ee63
CI: Install bash in the prepare step
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 19:09:15 +00:00
Sameer Rahmani d760e0538b
CI: Fix the typo in the pipeline
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 18:59:55 +00:00
Sameer Rahmani 34366a31ad
CI: Disable the manual clone step
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 18:48:53 +00:00
Sameer Rahmani 8d10dbce26
deps: Mark all the submodules to be shallowly cloned
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 18:32:30 +00:00
Sameer Rahmani d19929aa50
deps: Update the submodules urls to use https
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 18:18:53 +00:00
Sameer Rahmani 0002272335
CI: Try to override the submodule urls
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 18:16:05 +00:00
Sameer Rahmani 4edab6b7b3
CI: Add a manual clone step to avoid submodules
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 18:07:29 +00:00
Sameer Rahmani 0ecaa634cd
CI: Add a dumb ci configuration just to setup the CI
ci/woodpecker/push/woodpecker Pipeline failed Details
2023-02-03 17:54:20 +00:00
Sameer Rahmani 4cf4b043f3
CI: Add a dumb ci configuration just to setup the CI 2023-02-03 17:44:47 +00:00
Sameer Rahmani f61005cc8e
Fix some of the shellcheck issues in ./scripts 2023-02-03 17:40:30 +00:00
Sameer Rahmani e1a115e85a
Remove the old .env.example and .ci file 2023-02-03 17:30:17 +00:00
Sameer Rahmani 861ff7ed38
deps: Fix the packaging issues of dependencies 2023-02-03 17:27:22 +00:00
Sameer Rahmani b632d0a0e9
Fix serveral grammer issue in the README 2023-02-03 16:12:50 +00:00
Sameer Rahmani 42ec574484
Update the readme file for the new builder sub commands 2023-02-03 15:56:26 +00:00
Sameer Rahmani 71aac7ec33
Remove DEPS_BUILD_DIR_NAME env var 2023-02-03 01:20:05 +00:00
Sameer Rahmani b3cc33d9c8
Add the environment activation script 2023-02-03 00:47:26 +00:00
Sameer Rahmani 889248aa68
deps: Update iwyu to fix the Optional removal bug 2023-02-03 00:46:44 +00:00
Sameer Rahmani cdabcdebe7
builder: Remove the build existance check from deps.sh build 2023-02-03 00:46:06 +00:00
Sameer Rahmani cff8fb2f39
builder: replace the clean step with build dir removal 2023-02-03 00:41:50 +00:00
Sameer Rahmani 2347b06ab4
builder: Add the functionality to pull the prebuilt dependencies 2023-02-03 00:05:21 +00:00
Sameer Rahmani e0e0a1dea1
builder: Finish up the dependency management functions 2023-02-02 01:33:21 +00:00
Sameer Rahmani 19d19a0c12
Add the deps.sh file to manage the build process of dependencies 2023-02-01 23:50:38 +00:00
Sameer Rahmani 998444e945
Add the conifg file as a mean to tune the builder 2023-02-01 23:26:40 +00:00
Sameer Rahmani b4a47565a5
Add the dependencies as submodules 2023-02-01 23:26:05 +00:00
Sameer Rahmani 636e64825d
Fix the deprecated llvm::Optional issue 2023-01-31 23:07:13 +00:00
Sameer Rahmani 94b9479c29 Update the logo for dark backgrounds 2023-01-26 12:57:29 +00:00
Sameer Rahmani 9673782242 Upgrade llvm version on the builder 2023-01-19 15:14:27 +00:00
Sameer Rahmani d87e3922ec Move to the llvm 7240436c94bd02762a723a2e3551528d16c8efdb commit 2022-09-13 19:30:13 +01:00
Sameer Rahmani 0ae52e36d5 Extract the packer related functions out of the JIT 2022-07-24 20:56:40 +01:00
Sameer Rahmani 1d2eebe680 Create a PoC to setup the stdlib calls via serene.core 2022-07-23 11:09:15 +01:00
Sameer Rahmani 605ac1569a Add the conversation around jit and libasan to dev.org for the future reference 2022-07-22 20:12:58 +01:00
Sameer Rahmani b8483a1601 Refactore the compiler/linker options to add asan only on executables 2022-07-22 20:11:46 +01:00
Sameer Rahmani 8ed4cc43a9 Add the spec around loading Serene libs vs generic libs (not completed) 2022-07-12 00:35:32 +01:00
Sameer Rahmani 2f64811aa0 Add the build-in-devfs command to builder 2022-07-12 00:34:30 +01:00
Sameer Rahmani fa6273f0bf Leave the -shared-libasan from global compiler/linker options 2022-07-12 00:21:54 +01:00
Sameer Rahmani 4d3624505e Fix all the linter warnings 2022-07-10 07:52:15 +01:00
Sameer Rahmani 14a833f841 Fix minor bugs in the images creation and container setup process 2022-07-10 07:42:08 +01:00
Sameer Rahmani 34fab627c4 Create a bare minimum devfs container image 2022-07-10 02:36:07 +01:00
Sameer Rahmani 394f7827c1 Make a PoC of loading the core ns as an object 2022-07-10 02:35:32 +01:00
Sameer Rahmani 42cd4e259e Create different namespace loaders for different sources 2022-07-06 21:37:31 +01:00
Sameer Rahmani 6ec040f2d4 Setup the core library to be an object lib 2022-07-06 21:35:33 +01:00
Sameer Rahmani ba566cd452 Move lto out of default flags 2022-07-06 21:34:59 +01:00
Sameer Rahmani 6f6be3dde1 Add .tmp to gitignore 2022-07-06 21:33:51 +01:00
Sameer Rahmani 3a9b69b9d2 Update the readme to add boehm and debug instructions for it 2022-07-06 20:04:39 +01:00
Sameer Rahmani 05d39d367d Add the static library loader to the engine 2022-07-04 22:42:44 +01:00
Sameer Rahmani e2873780b8 Add two basic modules to core in order to test ir unification of clang 2022-07-03 11:24:01 +01:00
Sameer Rahmani 1ad61adb5a Fix the issue with the notImplemented helper function 2022-07-02 22:43:25 +01:00
Sameer Rahmani b66e92fb1f Add basic namespace loader template funections to the jit 2022-07-02 22:17:12 +01:00
Sameer Rahmani 1e8c820fb6 Add a fs namespace with bunch of utility functions to work with filesystems 2022-07-02 22:14:33 +01:00
Sameer Rahmani c2a06ee961 create a basic setup to develop the jit and the linker 2022-07-02 00:25:43 +01:00
Sameer Rahmani 783f4e65b2 Add a debugger entry to the builder script 2022-07-01 22:36:42 +01:00
Sameer Rahmani 489cb9610e Add sync mode to the builder's elisp function 2022-07-01 22:33:28 +01:00
Sameer Rahmani 3d1353dee4 Add a devonly function to the engine to load ir from files 2022-07-01 22:30:49 +01:00
Sameer Rahmani 5bec18b327 Add BDW gc and change the JIT interface to use raw pointers 2022-07-01 18:17:50 +01:00
Sameer Rahmani 482a410b11 Moving the jitdylib storage to the jit engine 2022-06-28 22:28:42 +01:00
Sameer Rahmani a9a8bb9fde Update the readme to include the correct llvm version 2022-06-28 22:24:35 +01:00
Sameer Rahmani ebec2562bf Add basic types and the storage for them on the jit engine 2022-06-19 13:17:58 +01:00
Sameer Rahmani a90c61b6ff Clean up the main cmake file 2022-06-18 11:11:08 +01:00
Sameer Rahmani 055df07ab9 Add LLVM_USE_PERF option to account for the same flag in target llvm 2022-06-18 11:05:54 +01:00
Sameer Rahmani 31cbbb9f71 Add debug info to the ARM build 2022-06-18 10:52:17 +01:00
Sameer Rahmani 9b5de91861 Add debug info to the ARM build 2022-06-18 10:49:39 +01:00
Sameer Rahmani fb7097565d Try to conditional link the pref lib 2022-06-18 10:47:32 +01:00
Sameer Rahmani b1858524e1 Set LLVM_USE_PERF to 0 on hally.cpp as a hacky fix for llvm's apt bug on ARM 2022-06-18 10:42:07 +01:00
Sameer Rahmani 114d60999d Temporary debug statements for 'LLVM_USE_PERF' on arm 2022-06-18 10:35:02 +01:00
Sameer Rahmani d0dc85e8f9 Use LLVM_USE_PERF to detect presence of createPerfJITEventListener 2022-06-17 08:44:03 +01:00
Sameer Rahmani cd84454f1a Add ExecutionEngine to the list of dependencies 2022-06-16 15:25:26 +01:00
Sameer Rahmani 703c0fdc96 Try LLVM_TARGETS_TO_BUILD var to cover all the targets 2022-06-16 15:17:54 +01:00
Sameer Rahmani c4cf536820 Replcing arch dependant targets with arch target themselves 2022-06-16 15:14:33 +01:00
Sameer Rahmani 85621103c1 Revert back to llvm's way for debugging purposes 2022-06-16 15:02:03 +01:00
Sameer Rahmani 4260aef3ce Temporarily point to specific version of llvm-config 2022-06-16 14:40:29 +01:00
Sameer Rahmani 6daab9a3e6 replace llvm's way of components resolution with a custom approach 2022-06-16 14:33:24 +01:00
Sameer Rahmani 7cb8884bde Iterate through llvm targets and append the components in cmake 2022-06-16 10:39:29 +01:00
Sameer Rahmani 266f16079f Move the llvm components to the main cmake file 2022-06-15 23:13:49 +01:00
Sameer Rahmani 64f0b31b81 Remove direct dependencies from libserene 2022-06-15 22:42:31 +01:00
Sameer Rahmani 4a23fe4e39 Add support for AArch64 in a dumb way 2022-06-15 12:21:20 +01:00
Sameer Rahmani b71701a640 Setup the CLI options around the JIT and make it the context owner 2022-06-14 18:03:11 +01:00
Sameer Rahmani c2fb6bf8cb Move and strip the jit engine to the v1 2022-06-14 15:56:57 +01:00
Sameer Rahmani cf71fcde38 Fix the shellcheck issues in the builder 2022-06-13 22:30:35 +01:00
Sameer Rahmani 3aa8745354 Remove iwyu from the ci steps 2022-06-13 22:26:23 +01:00
Sameer Rahmani 592d7c4fb0 Remove unnecessary code from context 2022-06-13 22:24:19 +01:00
Sameer Rahmani 3cc5da9789 Apply clang format 2022-06-13 22:19:58 +01:00
Sameer Rahmani c42ad11bd0 Move over SereneContext and remove the old bits 2022-06-13 22:18:58 +01:00
Sameer Rahmani c0ad467c87 Fix the compile_commands.json path on the CI 2022-06-13 21:09:11 +01:00
Sameer Rahmani f98eaabbc4 Add support for libc++ and compiler-rt 2022-06-13 21:07:51 +01:00
Sameer Rahmani 8553b5f43f Move the old libserene aside and start a new one 2022-06-13 20:34:55 +01:00
Sameer Rahmani 8a32489500 End of Part1 2022-06-13 18:26:14 +01:00
Sameer Rahmani 6362b28492 Revert videos.org from ep19 2022-06-13 12:45:06 +01:00
Sameer Rahmani c8ded04356 Disable clang-tidy since it's too much for a pi 2022-06-12 23:12:06 +01:00
Sameer Rahmani 3d31d01bc5 Add include-fixer to pre-commit 2022-06-12 22:34:12 +01:00
Sameer Rahmani 02b3674436 Use pre-commit as a step in CI 2022-06-12 21:44:49 +01:00
Sameer Rahmani 71c1e1731e Fix the broken bash array to str process in the builder 2022-06-12 20:40:36 +01:00
Sameer Rahmani 098b3ebdc4 Try to fix the cmake 2.23 bug 2022-06-12 18:43:06 +01:00
Sameer Rahmani 70995c2908 Fix the builder script to go with the CI 2022-06-12 18:07:06 +01:00
Sameer Rahmani 8c5804b360 Fix the missing step name 2022-06-12 17:35:49 +01:00
Sameer Rahmani 413c26b298 Setup the CI images and try the first drone build 2022-06-12 17:35:12 +01:00
Sameer Rahmani edc35978fd Set the pipeline platform to arm64 2022-06-12 11:54:10 +01:00
Sameer Rahmani 0ca8f3e42f Set the pipeline platform to arm64 2022-06-12 10:51:00 +01:00
Sameer Rahmani 10b33e9372 Add example drone yaml file 2022-06-12 10:08:38 +01:00
Sameer Rahmani c2364640dc Add shellcheck to pre-commit 2022-06-11 18:44:46 +01:00
Sameer Rahmani 182c87a046 Add pre-commit utility 2022-06-11 18:33:35 +01:00
Sameer Rahmani 05fdd9f1b2 Add the 'core' static lib that will contain the std libs 2022-06-11 18:11:00 +01:00
Sameer Rahmani b922284a39 Fix the broken include in types.cpp 2022-06-11 18:07:09 +01:00
Sameer Rahmani e9708f0690 Update the README file with the new LLVM SHA 2022-06-11 18:02:33 +01:00
Sameer Rahmani f436d6cee4 Moving to the a JIT first design
I realized that focusing on SLIR at this stage is wrong. I need
to finish up the JIT first and use the JIT to implement `read`,
`eval` and `print` functions by linking their C++ implementations
via a static library to the target code and then focus on SLIR
or any alternative that might come next.

This is the finish linke for the `0.x` version series.
2022-06-10 21:49:11 +01:00
Sameer Rahmani 3f025a1a85 Add Ptr type and constrain and break types/ops out of dialect file 2022-06-05 00:02:25 +01:00
Sameer Rahmani 57f71ec4f2 Fix the type names and add PtrType to type_converter 2022-06-05 00:01:52 +01:00
Sameer Rahmani 4015fd6b7e Add the `registerType` function to the dialect to break types into their own file 2022-06-04 23:59:27 +01:00
Sameer Rahmani ea403d444d Simplify string type to just contain a length 2022-06-02 17:32:59 +01:00
Sameer Rahmani d64910e9cc Lower serene.symbol to llvm struct type 2022-06-02 17:20:53 +01:00
Sameer Rahmani bbebc449dd Lower the `symbol` op to create static symbols 2022-06-02 15:36:05 +01:00
Sameer Rahmani 9348335959 Add a very basic string type to SLIR 2022-06-02 15:35:46 +01:00
Sameer Rahmani 5d3420a099 Add `convert` and `define_constant` operations to SLIR 2022-06-02 15:33:35 +01:00
Sameer Rahmani b6200a869b Add a type converter to convert serene types to LLVM dialect types 2022-06-02 15:31:01 +01:00
Sameer Rahmani bb49b7755d Add the depedancy list to the SereneDialect definition 2022-06-02 15:30:32 +01:00
Sameer Rahmani 1325185d4f Add proper depedencies to the LowerSLIR pass 2022-06-02 15:29:49 +01:00
Sameer Rahmani 7c868325b3 Add the fold functoin for value op 2022-06-02 15:24:27 +01:00
Sameer Rahmani 47a5def820 Migrate to LLVM 15-dev 2022-06-02 15:23:42 +01:00
Sameer Rahmani 31c98d2b3b Load llvm dialect in SereneContext 2022-06-02 15:19:31 +01:00
Sameer Rahmani 7b5ba7797d Add few constants to config.h to avoid magic numbers 2022-06-02 15:17:42 +01:00
Sameer Rahmani e326964bdb Add a glossary section to the spec.org 2022-06-02 15:07:01 +01:00
Sameer Rahmani 571691598d Revert the slir example to use module instead of ns 2022-06-02 15:04:10 +01:00
Sameer Rahmani 6cfa669eba Add llvm dialect to slir-opt 2022-06-02 15:00:54 +01:00
Sameer Rahmani b693472f51 Update gitignore patterns 2022-06-02 15:00:26 +01:00
Sameer Rahmani 97b31e8cb0 Add the NsOp to represent namespaces 2022-04-27 21:49:57 +01:00
Sameer Rahmani 0d7f51da8a Add the 'call' operation to slir 2022-04-20 21:24:01 +01:00
Sameer Rahmani 6abc125e6e Add the RetrunOp 'ret' to slir 2022-04-08 11:39:48 +01:00
Sameer Rahmani fe181755e7 Add fn,def and value operations to slir 2022-04-08 11:02:46 +01:00
Sameer Rahmani aa7cd548cf Add fn,def and value operations to slir 2022-04-08 10:34:47 +01:00
Sameer Rahmani 3a3e3a4da4 Rename the old ops of slir to mark them for removal 2022-04-08 10:30:09 +01:00
Sameer Rahmani 12c2d1d455 Fix the slir-opt tool to use slir and few builtin IRs 2022-04-05 00:05:27 +01:00
Sameer Rahmani b7af46cdde Upgrade to LLVM15 dev 2022-04-04 23:03:48 +01:00
Sameer Rahmani d9c4322ad1 Fix standardops to funcops headers 2022-04-04 22:50:08 +01:00
Sameer Rahmani 5508a8e3c3 Add devtools utility set 2022-04-04 22:43:12 +01:00
Sameer Rahmani 628598ad8b Add devtools utility set 2022-04-04 22:42:56 +01:00
Sameer Rahmani 92f7616ed1 Finish up ep number 18 2022-03-29 19:56:48 +01:00
Sameer Rahmani 7ee22721f7 Try different approach alternative to llvm::Error 2022-03-29 19:56:13 +01:00
Sameer Rahmani 7050e7d53d Clean up the halley files 2022-03-29 19:55:42 +01:00
Sameer Rahmani b9496b429e Fix the builder paths for top level binaries 2022-03-29 19:49:56 +01:00
Sameer Rahmani a215eb6cd9 Rename to and remove cleanup the source tree for errors 2022-03-10 19:48:33 +00:00
Sameer Rahmani 4605e22e68 Refactor the error handling system to have only one llvm error with many variants 2022-03-10 19:31:48 +00:00
Sameer Rahmani 1cd5824608 Add a test case for errors::getMessage 2022-03-08 17:38:02 +00:00
Sameer Rahmani 1e8d23b8ef Add tests for symbol and numbers 2022-03-08 15:58:02 +00:00
Sameer Rahmani df2300498b Clean up the reader's test cases 2022-03-08 14:20:15 +00:00
Sameer Rahmani d52b2bedd2 Fix the remaning license headers from the MIT era 2022-03-08 13:32:10 +00:00
Sameer Rahmani 2860e570da Refactor the error-backend and setup the test file for it 2022-03-08 13:19:34 +00:00
Sameer Rahmani 7d7293aa32 Change the storage type in Environment to StringMap 2022-03-05 16:03:19 +00:00
Sameer Rahmani 500f366bab Setup the Environment test cases 2022-03-05 14:28:37 +00:00
Sameer Rahmani 6f4c6b3398 Finish the review of SereneContext 2022-03-02 18:26:39 +00:00
Sameer Rahmani 644cf11c89 Finish ep17 and address trivial TODOs in the context 2022-02-27 19:10:30 +00:00
Sameer Rahmani 6eaba7dbe8 Panic if can't make a JIT while creating a context 2022-02-23 12:51:54 +00:00
Sameer Rahmani 840a7c565c [context] Replace the targetTriple string with a Triple object 2022-02-22 18:50:42 +00:00
Sameer Rahmani 578afc30a4 Remove the llvmContext member in SereneContext in favor of getLLVMContext 2022-02-20 20:59:57 +00:00
Sameer Rahmani da59a46f73 Add few tests for SereneContext to pin down the behaviour 2022-02-20 18:30:24 +00:00
Sameer Rahmani e0c1aaa7a6 Add tests for getSharedPtrNS and withCurrentNS functions 2022-02-19 22:49:31 +00:00
Sameer Rahmani 2eb29e859f Add the setup step for libserene's tests 2022-02-19 22:02:57 +00:00
Sameer Rahmani bbdf5c4491 Disable the test cases of libserene and prepare them for refactoring 2022-02-19 14:54:51 +00:00
Sameer Rahmani 8dde04d6ce Fix the unchecked Expected<T> in the context class 2022-02-19 14:54:03 +00:00
Sameer Rahmani bf0e24d75e Fetch content catch2 v3 globally 2022-02-19 14:53:24 +00:00
Sameer Rahmani c1fdfd0f82 Disable serenec and serene-repl tests temporarily for refactoring 2022-02-19 14:52:47 +00:00
Sameer Rahmani a7d432aa5c Remove unwanted backup files 2022-02-19 14:49:37 +00:00
Sameer Rahmani 40e5f5a034 doxygen + sphinx proved to be not good for us 2022-02-19 14:49:08 +00:00
Sameer Rahmani bb60d83dc6 Fix the shellchecker issues in the builder 2022-02-19 14:46:38 +00:00
Sameer Rahmani 55dd688e17 Add install targets to install the entire serene package 2022-02-17 22:49:16 +00:00
Sameer Rahmani eadd198b89 Move the src/tests to libserene/tests 2022-02-17 15:37:15 +00:00
Sameer Rahmani b109c3a975 Move out serene-repl and serenec outside of src 2022-02-17 15:34:33 +00:00
Sameer Rahmani 58274835b1 Mov out libserene and serene-tblgen to the root 2022-02-17 15:02:08 +00:00
Sameer Rahmani 7afbbb5112 Add builder task to serve the docs 2022-02-17 11:32:20 +00:00
Sameer Rahmani 328d1b50ea Fix the docker build issue with propagating errors to builder 2022-02-16 20:28:20 +00:00
Sameer Rahmani 8de69baa1c Fix the missing MLIR header issue after pulling llvm 2022-02-16 20:01:38 +00:00
Sameer Rahmani 49e3f16901 Add the builder tasks to build and release docker images 2022-02-15 21:34:29 +00:00
Sameer Rahmani bcbf49c1a1 Setup Sphinx and doxygen in CMake for the docs 2022-02-15 21:33:11 +00:00
Sameer Rahmani 00592d6af1 Add new doxygen setup 2022-02-12 22:25:22 +00:00
Sameer Rahmani b210e3a349 Clean up the diagnostocs header file 2022-02-12 21:06:59 +00:00
Sameer Rahmani bc3908a958 Refactor the builder script 2022-02-09 19:08:31 +00:00
Sameer Rahmani f663ba0c25 Fix the license header 2022-02-08 17:56:15 +00:00
Sameer Rahmani 7dc587ecbc Setup the dockerfiles necessary to build serene in a container 2022-02-08 17:43:29 +00:00
Sameer Rahmani 2da5b1dedf Add the context options to the makeSereneContext function 2022-02-06 21:15:13 +00:00
Sameer Rahmani 008ba402f0 Migrate to llvm::5372160a18 2022-02-06 18:37:44 +00:00
Sameer Rahmani 96438bf90b Migrate to llvm::Error 2022-02-05 11:59:00 +00:00
Sameer Rahmani 64ee59fbc8 Finish up the errors-backend and migrate serene's errs to llvm: 2022-02-04 22:47:01 +00:00
Sameer Rahmani 95e9edf61e Add the notes for episode 16 2022-01-30 20:01:32 +00:00
Sameer Rahmani 51a412d56d Fix the generated errors in tbl-srn 2022-01-28 11:46:40 +00:00
Sameer Rahmani 935634b7c8 Update the license header for 2022 2022-01-27 11:44:44 +00:00
Sameer Rahmani cff5c28c95 Add tbl-srn generator to the cmake pipeline 2022-01-27 11:29:58 +00:00
Sameer Rahmani 7638c631ed Fix the complexity of errors-backeds run 2022-01-23 15:08:38 +00:00
Sameer Rahmani 1c935928e5 Create a bare minimum error backend for tbl-srn 2022-01-22 22:16:52 +00:00
Sameer Rahmani c7e6e8d9a5 Create a very basic tablegen instance 2022-01-22 19:10:57 +00:00
Sameer Rahmani a085f0b7ea Create a tablegen instance for Serene to be used locally 2022-01-22 17:56:45 +00:00
Sameer Rahmani cfa4f54b5a Setup the symbol type in SLIR 2022-01-22 11:31:04 +00:00
Sameer Rahmani 656adafd7e Add the symbol type to SLIR 2022-01-18 19:45:30 +00:00
Sameer Rahmani c63425485c Add addAST function to the JIT 2022-01-18 19:45:08 +00:00
Sameer Rahmani 8c85dd4bbe Finish the slides for episode 15 2022-01-09 11:55:34 +00:00
Sameer Rahmani fd668bbb34 Fix the linking issue with llvm dev version 2022-01-05 16:18:32 +00:00
Sameer Rahmani 37f6798c5e Add jit related todos to dev.org 2022-01-03 16:57:31 +00:00
Sameer Rahmani 95e7e37071 Add the compiled notify callback to spit out debug info on Halley 2022-01-03 16:08:01 +00:00
Sameer Rahmani afc6873c64 Add basic LLLazyJIT support to Halley 2022-01-03 14:08:47 +00:00
Sameer Rahmani 851595ca7d Change the current namespace lookup behavior
* Change the way namespace creation works. We should create new
  namespaces via the context so we can insert them in the contenxt

* Change the way setting the current namespace works. `withCurrentNS`
  method gets a function as input param and a ns name and runs the
  function with the ns set as the current NS and restore the state
  after that

* Change the way Dylibs register with the context and namespaces
  and lookup the dylibs will use the context to use the most recent
  dylib of a namespace.
2022-01-02 18:57:36 +00:00
Sameer Rahmani 28baf8fb9a Add the JITDylib registery on SereneContext and addNS in Halley 2022-01-01 22:15:30 +00:00
Sameer Rahmani 0863a2561f Remove output logs from the JIT 2021-12-31 12:06:49 +00:00
Sameer Rahmani 3bacfe59aa Setup the function packing on the JIT 2021-12-31 12:02:25 +00:00
Sameer Rahmani c41c91b335 Add the Halley JIT and migrate to it 2021-12-30 13:52:33 +00:00
Sameer Rahmani 123a3e8d4f Add the more resouces about JIT to dev.org 2021-12-29 13:12:36 +00:00
Sameer Rahmani 6d34e58665 Fix the wrong constant opretation 2021-12-24 16:52:43 +00:00
Sameer Rahmani aca81f8d61 Finalize EP14 2021-12-19 21:45:49 +00:00
Sameer Rahmani 4c07544141 Add the supporters file 2021-12-17 15:23:05 +00:00
Sameer Rahmani 8558b2e57b Change the freenode name to libera 2021-12-17 15:11:32 +00:00
Sameer Rahmani 3e82b71903 Fix the compatiblity issues with llvm version aff028f7d8322c625422febd3d8b9794746cdc5b 2021-12-15 17:26:08 +00:00
Sameer Rahmani 76a9106559 update the slides for ep13 2021-11-27 17:49:24 +00:00
Sameer Rahmani e825367f95 Add the notes for episode 13 2021-11-26 15:43:47 +00:00
Sameer Rahmani b6ac7f3f5f Add the ast layer to the jit 2021-11-19 00:41:28 +00:00
Sameer Rahmani 5a57f7c98b Add the idea of destructure types 2021-11-18 10:03:41 +00:00
Sameer Rahmani b1ce34db75 Fix the assert condition on getRootEnv 2021-11-17 17:50:09 +00:00
Sameer Rahmani b3d1151a8b Refactor the semantic analyzer to use the analysis state
* Refactor the semantic analyzer to use the new state struct
  which is just bunch of refs to the current ns and current env

* Add the `environments` vector to ns to store the environments
  and few helper functions to use it

* Add the `symbolList` (need a better name) to keep track of what
  symbols might be added to the namespace after calling `addTree`.
2021-11-17 17:37:45 +00:00
Sameer Rahmani 800105dbea Merge jit2 branch 2021-11-12 16:28:34 +00:00
Sameer Rahmani 3da6d2d1fc Fix the lookup process on the new jit 2021-11-12 16:20:22 +00:00
Sameer Rahmani 86a6b985e4 Remove the namespace name from the symbol look up in JIT 2021-11-12 11:49:45 +00:00
Sameer Rahmani b4f31984c4 Update the dev.org to add a new todo 2021-11-11 15:37:23 +00:00
Sameer Rahmani 981e5171b2 Setup the base none lazy jit 2021-11-10 19:40:51 +00:00
Mary 55780103f4 Merge reader.cpp and location.cpp 2021-11-09 22:30:47 +00:00
Sameer Rahmani 1dfc353fa4 Add the NSLayer to the jit 2021-11-06 21:23:37 +00:00
Sameer Rahmani 556db28a99 Add a note to show case code generation on ep13 2021-11-04 00:59:38 +00:00
Sameer Rahmani 2911ead7a9 Add the compile on demand layer to the jit 2021-11-04 00:57:00 +00:00
Sameer Rahmani 0895a09db0 Revome the old clang driver approach for code generation 2021-11-03 18:27:20 +00:00
Sameer Rahmani 69e8782c67 finalize ep 12 2021-11-03 14:06:45 +00:00
Sameer Rahmani 5622b4de0c Prepare for ep 12 2021-11-02 22:05:34 +00:00
Sameer Rahmani 34d3513426 Start the new jit 2021-11-01 15:09:11 +00:00
Sameer Rahmani fc11896c28 Add the read and print functionality to the repl 2021-10-24 23:34:28 +01:00
Sameer Rahmani 3fb6fb3740 Change the reader interface to return errors instead of emiting them
* Change the `Result` interface to let the compiler use the concrete
  type in place of a `Result`
2021-10-24 12:34:20 +01:00
Sameer Rahmani 3725d15521 Add the clang-tidy configurations 2021-10-17 22:23:15 +01:00
Sameer Rahmani cbb0b0428e Hide the clang-tidy behind a build option 2021-10-17 22:22:49 +01:00
Sameer Rahmani fd66e47cd7 Fix all the tidy issues 2021-10-17 20:12:17 +01:00
Sameer Rahmani 55e0788bae Fix all the tidy issues on src 2021-10-17 16:06:52 +01:00
Sameer Rahmani 737226dbae Fix the reader tidy issues 2021-10-17 14:57:17 +01:00
Sameer Rahmani 54aa50f020 Fix the exprs dir's tidy issues 2021-10-17 14:33:16 +01:00
Sameer Rahmani bedaaba46f Fix namespace and src mgr tidy issues 2021-10-17 12:14:04 +01:00
Sameer Rahmani 1bdc8aa9e9 Fix context's tidy issues 2021-10-17 11:19:12 +01:00
Sameer Rahmani b79f7a62c1 Fix the clang tidy's issues in serenec 2021-10-17 02:12:19 +01:00
Sameer Rahmani 9850b99607 Add the serene-dev.el to ease the development on the mighty Emacs 2021-10-17 00:24:22 +01:00
Sameer Rahmani 895ff27a51 Remove useless null checks from the passes 2021-10-16 20:48:14 +01:00
Sameer Rahmani 4b03316d81 Add include_what_you_use to the cmake files 2021-10-16 16:16:18 +01:00
Sameer Rahmani e5c5a68128 Clean up the slir lowering impl 2021-10-16 16:15:56 +01:00
Sameer Rahmani 5a9c256325 Add the panic function to diag and change getCurrentNS to return a ref 2021-10-13 11:27:54 +01:00
Sameer Rahmani c6e5bddf10 Move the linenoise to a serene dir to mark it as a local header 2021-10-13 09:49:50 +01:00
Sameer Rahmani c05d42107f Setup the serene-repl target with a basic REPL loop 2021-10-12 22:50:08 +01:00
Sameer Rahmani f473d1122b Change the license to GPL2 2021-10-12 20:51:03 +01:00
Sameer Rahmani 43dd4ac48d Add the RPATH posix fix support to libserene target 2021-10-12 14:45:46 +01:00
Sameer Rahmani e3fde6dfc1 Add link_what_you_use support to the build setup 2021-10-10 22:28:50 +01:00
Sameer Rahmani 7a456e2d54 Add support for a shared libserene and make it the default behaviour 2021-10-10 21:34:14 +01:00
Sameer Rahmani 54d85eac94 Fix the memory leak on pass failure in the namespace generate function 2021-10-06 21:07:56 +01:00
Sameer Rahmani 10015683f5 Refactor the passes name for slir lowering 2021-10-06 18:48:48 +01:00
Sameer Rahmani 2634fdb5f4 Clean up the src/ cmakefiles 2021-09-28 17:45:59 +01:00
Sameer Rahmani 2dca8e812e Fixed the pre-commit hook name 2021-09-28 17:16:15 +01:00
Sameer Rahmani a174a3a342 Refactor the cmake script and move the binary into its own package 2021-09-28 17:11:50 +01:00
Sameer Rahmani 5802e87121 Add CCache support to cmake list 2021-09-27 15:25:06 +01:00
Sameer Rahmani 225ff6bba1 Refactor the main cmake list file and fix the unused warns 2021-09-27 13:05:15 +01:00
Sameer Rahmani 6ef69d329a Move the semantic analysis process into the namespace 2021-09-25 16:18:33 +01:00
Sameer Rahmani dc051797ee Fix the fn slir generation proccess 2021-09-23 19:24:51 +01:00
Sameer Rahmani 00869e6c8d Replace some of the Result types with llvm::Optional 2021-09-19 10:27:13 +01:00
Sameer Rahmani 3c19cace5f Add more logs to the pre commit hook 2021-09-17 13:51:30 +01:00
Sameer Rahmani ba77f9bc99 Fix the readNamespace in the serenec 2021-09-17 13:49:55 +01:00
Sameer Rahmani a00ba492e6 Remove the old pre commit hook 2021-09-16 18:02:51 +01:00
Sameer Rahmani 3aa2e3291d Add the git add fn to the pre commit hook 2021-09-16 18:02:00 +01:00
Sameer Rahmani 8ee7634782 Fix the precommit hook issue 2021-09-16 18:00:24 +01:00
Sameer Rahmani 60b8347eca Mark the precommit hook as executable 2021-09-16 17:56:51 +01:00
Sameer Rahmani 03926b3d22 Mark the precommit hook as executable 2021-09-16 17:56:12 +01:00
Sameer Rahmani 845cdfa7d5 Mark the precommit hook as executable 2021-09-16 17:47:35 +01:00
Sameer Rahmani fe63407aed Create a new and simpler pre-commit hook 2021-09-16 17:46:30 +01:00
Sameer Rahmani 2aacd0a0e5 Improve the git precommit hook to fix the includes 2021-09-16 17:30:16 +01:00
Sameer Rahmani 5ff52c277a Clean up the source manager 2021-09-15 15:04:11 +01:00
Sameer Rahmani 91aa0148d6 Create a basic print function for the diagnostic class 2021-09-12 20:31:12 +01:00
Sameer Rahmani 766cf2dfed Add the error code to the diagnostic 2021-09-12 20:31:12 +01:00
Sameer Rahmani b285172597 Finalize the new approach to reading chars in the reader 2021-09-12 20:31:12 +01:00
Sameer Rahmani 70df6f4368 Remove the ungetChar method from reader 2021-09-12 20:31:12 +01:00
Sameer Rahmani 5491660261 Add our own dianostic engine 2021-09-12 20:31:12 +01:00
Sameer Rahmani 800e3c5fc8 Introduce the notion of ns and filename in the reader and location 2021-09-12 20:31:11 +01:00
Sameer Rahmani f357b5e9d3 Add the a source manger and integrate the reader with it 2021-09-12 20:31:10 +01:00
Sameer Rahmani f980da8e4e Finish up the episode 8 slides 2021-09-05 19:40:18 +01:00
Sameer Rahmani 7410ca3d59 Upgrade to llvm 13rc2 2021-08-28 18:01:48 +01:00
Sameer Rahmani 6f218d8cab Add a todo for another assertion 2021-08-22 11:09:30 +01:00
Sameer Rahmani 36b95fe1e5 Tidy up the target files for episode 7 2021-08-21 18:46:49 +01:00
Sameer Rahmani a1d3ae8c9c Finish up the wiring of the very basic JIT implementation. 2021-08-17 09:57:26 +01:00
Sameer Rahmani aba81bfcae Move over a modified version of MLIR jit. Add the pch 2021-08-17 09:57:26 +01:00
Sameer Rahmani 8af6452457 Fix the serenec to use the new ns api 2021-08-17 09:57:26 +01:00
Sameer Rahmani 3ace6ec260 Chaneg the namespace to generate modules instead of owning them 2021-08-17 09:57:26 +01:00
Sameer Rahmani ae2e6a74a0 Add the vector logo 2021-08-15 12:08:35 +01:00
Sameer Rahmani 06ed3b0c69 Add several TODOs for the asserts we need to remove 2021-08-07 21:09:18 +01:00
Sameer Rahmani 32b406fdad Prepare tho source tree for episode number 6 2021-08-07 17:41:19 +01:00
Sameer Rahmani 54b4458a8d Cleanup the exprs namespace for the episode 5 2021-07-30 12:17:41 +01:00
Sameer Rahmani e00156b9e7 Add the 'target' emit action as a temporary action to generate target code 2021-07-27 19:13:19 +01:00
Sameer Rahmani f8b66934a1 Remove the unused 'toString' member function for readar classes 2021-07-19 15:50:59 +01:00
Sameer Rahmani 5b5e40c012 update the video.org for episode 4 2021-07-19 15:44:39 +01:00
Sameer Rahmani ea0bc28f01 Fix the test cases to use reader::read instead of the Reader#read 2021-07-19 09:38:07 +01:00
Sameer Rahmani cb5ea22081 Clean up the reader namespace code 2021-07-17 19:39:56 +01:00
Sameer Rahmani 5beffbc604 Fix the test cases of traits 2021-07-17 16:40:02 +01:00
Sameer Rahmani a117572ce5 Add the ns-paths todo to dev.org 2021-07-15 10:27:17 +01:00
Sameer Rahmani ab54e7f5be [PoC] Use clang driver to link the object files 2021-07-12 23:39:29 +01:00
205 changed files with 12679 additions and 11990 deletions

View File

@ -15,4 +15,20 @@ AlignConsecutiveBitFields: Consecutive
AlignEscapedNewlines: Left
AlwaysBreakTemplateDeclarations: Yes
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^"'
Priority: 1
SortPriority: 1
CaseSensitive: true
- Regex: '^<(llvm|llvm-c|clang|clang-c|mlir)/'
Priority: 3
SortPriority: 3
CaseSensitive: true
- Regex: '<[[:alnum:].]+>'
Priority: 5
- Regex: '.*'
Priority: 2
SortPriority: 0
SortIncludes: true
SortUsingDeclarations: true
...

237
.clang-tidy Normal file
View File

@ -0,0 +1,237 @@
---
Checks: '-*,clang-diagnostic-*,clang-analyzer-*,cert-*,-cert-err58-cpp,concurrency-*,llvm-*,performance-*,readability-*,-readability-identifier-length*'
WarningsAsErrors: '-*,clang-diagnostic-*,clang-analyzer-*,cert-*,-cert-err58-cpp,concurrency-*,llvm-*,performance-*,readability-*,-readability-identifier-length*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: file
User: lxsameer
CheckOptions:
- key: performance-unnecessary-copy-initialization.ExcludedContainerTypes
value: ''
- key: readability-suspicious-call-argument.PrefixSimilarAbove
value: '30'
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: performance-move-const-arg.CheckTriviallyCopyableMove
value: 'true'
- key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold
value: '3'
- key: readability-function-size.VariableThreshold
value: '4294967295'
- key: readability-simplify-subscript-expr.Types
value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array'
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-dcl51-cpp.AggressiveDependentMemberLookup
value: 'false'
- key: readability-identifier-naming.GetConfigPerFile
value: 'true'
- key: cert-err61-cpp.MaxSize
value: '0'
- key: cert-sig30-c.AsyncSafeFunctionSet
value: POSIX
- key: readability-inconsistent-declaration-parameter-name.Strict
value: 'false'
- key: readability-suspicious-call-argument.DiceDissimilarBelow
value: '60'
- key: cert-dcl37-c.AllowedIdentifiers
value: ''
- key: readability-function-size.NestingThreshold
value: '4294967295'
- key: llvm-namespace-comment.ShortNamespaceLines
value: '1'
- key: llvm-namespace-comment.SpacesBeforeComments
value: '1'
- key: readability-function-size.ParameterThreshold
value: '4294967295'
- key: readability-suspicious-call-argument.Equality
value: 'true'
- key: readability-function-cognitive-complexity.IgnoreMacros
value: 'false'
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: 'false'
- key: readability-identifier-naming.AggressiveDependentMemberLookup
value: 'false'
- key: readability-redundant-smartptr-get.IgnoreMacros
value: 'true'
- key: cert-err61-cpp.WarnOnLargeObjects
value: 'false'
- key: cert-err09-cpp.WarnOnLargeObjects
value: 'false'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: readability-suspicious-call-argument.JaroWinklerDissimilarBelow
value: '75'
- key: readability-suspicious-call-argument.SuffixSimilarAbove
value: '30'
- key: readability-suspicious-call-argument.Suffix
value: 'true'
- key: cert-oop57-cpp.MemSetNames
value: ''
- key: performance-type-promotion-in-math-fn.IncludeStyle
value: llvm
- key: readability-function-cognitive-complexity.DescribeBasicIncrements
value: 'true'
- key: readability-suspicious-call-argument.MinimumIdentifierNameLength
value: '3'
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: readability-inconsistent-declaration-parameter-name.IgnoreMacros
value: 'true'
- key: performance-no-automatic-move.AllowedTypes
value: ''
- key: readability-suspicious-call-argument.SubstringDissimilarBelow
value: '40'
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: 'false'
- key: readability-identifier-naming.IgnoreFailedSplit
value: 'false'
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: readability-qualified-auto.AddConstToQualified
value: 'true'
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: 'false'
- key: readability-else-after-return.WarnOnConditionVariables
value: 'true'
- key: readability-uppercase-literal-suffix.IgnoreMacros
value: 'true'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: cert-dcl59-cpp.HeaderFileExtensions
value: ';h;hh;hpp;hxx'
- key: readability-suspicious-call-argument.SuffixDissimilarBelow
value: '25'
- key: performance-unnecessary-copy-initialization.AllowedTypes
value: ''
- key: llvm-header-guard.HeaderFileExtensions
value: ';h;hh;hpp;hxx'
- key: readability-suspicious-call-argument.LevenshteinSimilarAbove
value: '66'
- key: readability-suspicious-call-argument.Levenshtein
value: 'true'
- key: readability-suspicious-call-argument.JaroWinkler
value: 'true'
- key: readability-suspicious-call-argument.Prefix
value: 'true'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: 'false'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: 'false'
- key: cert-err09-cpp.CheckThrowTemporaries
value: 'true'
- key: cert-dcl51-cpp.Invert
value: 'false'
- key: readability-function-size.LineThreshold
value: '4294967295'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: readability-suspicious-call-argument.PrefixDissimilarBelow
value: '25'
- key: performance-inefficient-vector-operation.EnableProto
value: 'false'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: 'true'
- key: performance-for-range-copy.AllowedTypes
value: ''
- key: readability-redundant-string-init.StringNames
value: '::std::basic_string_view;::std::basic_string'
- key: readability-magic-numbers.IgnoreBitFieldsWidths
value: 'true'
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
- key: readability-suspicious-call-argument.LevenshteinDissimilarBelow
value: '50'
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: readability-redundant-declaration.IgnoreMacros
value: 'true'
- key: performance-inefficient-string-concatenation.StrictMode
value: 'false'
- key: concurrency-mt-unsafe.FunctionSet
value: any
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: 'false'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: readability-else-after-return.WarnOnUnfixable
value: 'true'
- key: cert-dcl51-cpp.AllowedIdentifiers
value: ''
- key: cert-oop57-cpp.MemCpyNames
value: ''
- key: readability-suspicious-call-argument.SubstringSimilarAbove
value: '50'
- key: readability-suspicious-call-argument.Substring
value: 'true'
- key: readability-magic-numbers.IgnoreAllFloatingPointValues
value: 'false'
- key: readability-suspicious-call-argument.Abbreviations
value: 'arr=array;cnt=count;idx=index;src=source;stmt=statement;cpy=copy;dest=destination;dist=distancedst=distance;ptr=pointer;wdth=width;str=string;ln=line;srv=server;attr=attribute;ref=reference;buf=buffer;col=column;nr=number;vec=vector;len=length;elem=element;val=value;i=index;var=variable;hght=height;cl=client;num=number;pos=position;lst=list;addr=address'
- key: readability-uppercase-literal-suffix.NewSuffixes
value: ''
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: performance-unnecessary-value-param.AllowedTypes
value: ''
- key: readability-uniqueptr-delete-release.PreferResetCall
value: 'false'
- key: cert-oop57-cpp.MemCmpNames
value: ''
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: readability-function-cognitive-complexity.Threshold
value: '25'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: 'true'
- key: cert-err61-cpp.CheckThrowTemporaries
value: 'true'
- key: performance-faster-string-find.StringLikeClasses
value: '::std::basic_string;::std::basic_string_view'
- key: readability-function-size.BranchThreshold
value: '4294967295'
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: 'false'
- key: readability-function-size.StatementThreshold
value: '800'
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 'false'
- key: llvm-qualified-auto.AddConstToQualified
value: 'false'
- key: cert-str34-c.CharTypdefsToIgnore
value: ''
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: llvm-else-after-return.WarnOnConditionVariables
value: 'false'
- key: cert-msc51-cpp.DisallowedSeedTypes
value: 'time_t,std::time_t'
- key: readability-suspicious-call-argument.DiceSimilarAbove
value: '70'
- key: readability-suspicious-call-argument.Dice
value: 'true'
- key: readability-suspicious-call-argument.Abbreviation
value: 'true'
- key: cert-dcl37-c.Invert
value: 'false'
- key: cert-dcl37-c.AggressiveDependentMemberLookup
value: 'false'
- key: performance-inefficient-vector-operation.VectorLikeClasses
value: '::std::vector'
- key: readability-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
value: 'false'
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
value: 'false'
- key: readability-suspicious-call-argument.JaroWinklerSimilarAbove
value: '85'
- key: cert-dcl16-c.IgnoreMacros
value: 'true'
- key: performance-unnecessary-value-param.IncludeStyle
value: llvm
- key: llvm-else-after-return.WarnOnUnfixable
value: 'false'
- key: cert-msc32-c.DisallowedSeedTypes
value: 'time_t,std::time_t'
...

2
.dockerignore Normal file
View File

@ -0,0 +1,2 @@
./resources/

11
.gitignore vendored
View File

@ -23,3 +23,14 @@ bin/serenec_CXX_cotire.cmake
/config.h
docs/Doxyfile.docs
.ccache/
docs/spec.tex
docs/spec.pdf
.tmp
.env
.tex
.pdf
docs/overall_picture.png
.direnv/
.pre-commit-config.yaml
.envrc

View File

@ -1 +1 @@
#leak:mlir::Region::emplaceBlock
#leak:mlir::Region::emplaceBlock

55
.woodpecker/build.yml Normal file
View File

@ -0,0 +1,55 @@
pipeline:
Linters:
group: build
image: lxsameer/serene_ci:13
commands:
- export SERENE_CI=true
- ./builder setup
- export FILES="$(git diff --name-only HEAD HEAD~1)"
- pre-commit run --files "$FILES"
Build:
group: build
image: lxsameer/serene_ci:13
commands:
# Uncomment this when running with a new toolchain for the
# first time to save up space
# - rm -rf /root/.serene/*
- ./builder build -DSERENE_DISABLE_CCACHE=ON
volumes:
- serene_config:/root/.serene/
ChatNotify:
image: lxsameer/notify:3
settings:
matrix_room_id:
from_secret: matrix_room
matrix_access_token:
from_secret: matrix_token
matrix_user:
from_secret: matrix_user
matrix_msg: "[${CI_REPO}][Build] Job #${CI_BUILD_NUMBER} <b>failed</b> for branch <b>${CI_COMMIT_BRANCH}</b>. ${CI_BUILD_LINK}"
secrets: [ matrix_room, matrix_token, matrix_user ]
when:
- status: [failure]
MailNotify:
image: lxsameer/woodpecker_mailer:4
settings:
from: ci@serene-lang.org
user:
from_secret: mailer_user
password:
from_secret: mailer_password
to: ${CI_COMMIT_AUTHOR_EMAIL}
subject: "[${CI_REPO}][Build] JOB #${CI_BUILD_NUMBER} failed for branch '${CI_COMMIT_BRANCH}'."
text: |
BUILD: ${CI_BUILD_LINK}
COMMIT: ${CI_COMMIT_LINK}
when:
- status: [failure]
secrets: [ mail_pass, mail_user ]

64
.woodpecker/docs.yml Normal file
View File

@ -0,0 +1,64 @@
pipeline:
build:
image: woodpeckerci/plugin-docker-buildx
secrets: [docker_username, docker_password]
settings:
repo: serenelang/serene-docs
registry: docker.io
dockerfile: docs/Dockerfile
tags: latest
username:
from_secret: docker_username
password:
from_secret: docker_password
when:
- path:
include: [ 'mkdocs.yml', 'docs/**' ]
- branch: master
deploy:
image: docker:24.0.2-cli-alpine3.18
commands:
- docker stack deploy -c docs/service.yml serene-docs --prune
volumes:
- /var/run/docker.sock:/var/run/docker.sock
when:
- path:
include: [ 'mkdocs.yml', 'docs/**' ]
# ignore_message: "[ALL]"
- branch: master
ChatNotify:
image: lxsameer/notify:3
settings:
matrix_room_id:
from_secret: matrix_room
matrix_access_token:
from_secret: matrix_token
matrix_user:
from_secret: matrix_user
matrix_msg: "[${CI_REPO}][Docs] Job #${CI_BUILD_NUMBER} <b>failed</b> for branch <b>${CI_COMMIT_BRANCH}</b>. ${CI_BUILD_LINK}"
secrets: [ matrix_room, matrix_token, matrix_user ]
when:
- status: [failure]
MailNotify:
image: lxsameer/woodpecker_mailer:4
settings:
from: ci@serene-lang.org
user:
from_secret: mailer_user
password:
from_secret: mailer_password
to: ${CI_COMMIT_AUTHOR_EMAIL}
subject: "[${CI_REPO}][Docs] JOB #${CI_BUILD_NUMBER} failed for branch '${CI_COMMIT_BRANCH}'."
text: |
BUILD: ${CI_BUILD_LINK}
COMMIT: ${CI_COMMIT_LINK}
when:
- status: [failure]
secrets: [ mail_pass, mail_user ]

View File

@ -1,20 +1,61 @@
cmake_minimum_required(VERSION 3.16)
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.19)
# Project name and a few useful settings. Other commands can pick up the results
project(Serene
VERSION 0.1.0
DESCRIPTION "Serene language is a modern Lisp."
project(
Serene
VERSION 1.0.0
DESCRIPTION "A modern typed Lisp."
LANGUAGES CXX C)
# Clangd command file
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
option(CPP_20_SUPPORT "C++20 Support" OFF)
# Only do these if this is the main project, and not if it is included through add_subdirectory
# =============================================================================
# Policies
# =============================================================================
cmake_policy(SET CMP0116 OLD)
# =============================================================================
# User Options
# =============================================================================
option(CPP_20_SUPPORT "C++20 Support" ON)
option(SERENE_BUILD_TESTING "Enable tests" ON)
option(SERENE_ENABLE_BUILDID "Enable build id." OFF)
option(SERENE_ENABLE_THINLTO "Enable ThisLTO." ON)
option(SERENE_ENABLE_DOCS "Enable document generation" OFF)
option(SERENE_ENABLE_TIDY "Enable clang tidy check" OFF)
option(SERENE_DISABLE_CCACHE "Disable automatic ccache integration" OFF)
option(SERENE_ENABLE_DEVTOOLS "Enable the devtools build" OFF)
option(SERENE_DISABLE_MUSL "Disable musl libc (Musl is recommended)." OFF)
option(SERENE_DISABLE_LIBCXX "Disable libc++ (libc++ is recommended)." OFF)
option(SERENE_DISABLE_COMPILER_RT
"Disable compiler-rt (compiler-rt is recommended)." OFF)
# LLVM Info about the target llvm build
option(LLVM_USE_PERF "If the target LLVM build is built with LLVM_USE_PERF" OFF)
# Only do these if this is the main project, and not if it is included through
# add_subdirectory
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# Settings =======================
## Settings -----------------------------------------
set(C_STANDARD 17)
# specify the C++ standard
if (CPP_20_SUPPORT)
if(CPP_20_SUPPORT)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
@ -22,105 +63,145 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set(BIN_DIR ${CMAKE_SOURCE_DIR}/bin)
if(SERENE_ENABLE_TIDY)
find_program(CLANG_TIDY_PATH NAMES clang-tidy REQUIRED)
endif()
# We use iwyu intensively. For the version details check out the submodule at
# `deps/include-what-you-use`
find_program(iwyu NAMES include-what-you-use iwyu REQUIRED)
set(iwyu_path ${iwyu})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
#set(CMAKE_CXX_LINK_EXECUTABLE "ld.lld")
#set(CMAKE_C_LINK_EXECUTABLE "ld.lld")
#set(LLVM_USE_LINKER "ld.lld")
#set(LLVM_ENABLE_LLD ON)
set(CMAKE_CXX_CLANG_TIDY clang-tidy)
# Let's ensure -std=c++xx instead of -std=g++xx
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG
"${CMAKE_CXX_FLAGS_DEBUG} -g -fno-omit-frame-pointer $ENV{ASAN_FLAG} -fno-builtin-strlen -ggdb -fno-inline ")
set(CMAKE_LINKER_FLAGS_DEBUG
"${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer $ENV{ASAN_FLAG}")
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/scripts/cmake")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(MemoryCheckCommand "valgrind")
add_compile_options(-fno-rtti)
configure_file(${INCLUDE_DIR}/config.h.in config.h)
# Let's nicely support folders in IDEs
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
## Options ------------------------------------------
option(ENABLE_LOG "Enable logging" OFF)
option(ENABLE_EXPR_LOG "Enable AExpr logging" OFF)
option(ENABLE_READER_LOG "Enable reader logging" OFF)
option(BUILD_TESTING "Enable tests" OFF)
# Setup the basic compiler flags
add_compile_options(
-Wall
-Wextra
-Werror
-Wpedantic
-Wabstract-final-class
-Walloca
-Warray-bounds-pointer-arithmetic
-Warray-parameter
-Wassign-enum
-Wsign-conversion
-Wnon-virtual-dtor
-Wold-style-cast
-Wcast-align
-Wunused
-Woverloaded-virtual
-Wdouble-promotion
-Wformat=2)
# CCache support ==============================
if(SERENE_DISABLE_CCACHE)
message(STATUS "CCache support is disabled")
else()
find_program(CCACHE_PROGRAM ccache)
include(cotire)
include(FetchContent)
if(CCACHE_PROGRAM)
message(STATUS "Found CCache")
set(SERENE_CCACHE_MAXSIZE
""
CACHE STRING "Size of ccache")
set(SERENE_CCACHE_DIR
""
CACHE STRING "Directory to keep ccached data")
set(SERENE_CCACHE_PARAMS
"CCACHE_CPP2=yes CCACHE_HASHDIR=yes"
CACHE STRING "Parameters to pass through to ccache")
set(CCACHE_PROGRAM "${SERENE_CCACHE_PARAMS} ${CCACHE_PROGRAM}")
if(SERENE_CCACHE_MAXSIZE)
set(CCACHE_PROGRAM
"CCACHE_MAXSIZE=${SERENE_CCACHE_MAXSIZE} ${CCACHE_PROGRAM}")
endif()
if(SERENE_CCACHE_DIR)
set(CCACHE_PROGRAM "CCACHE_DIR=${SERENE_CCACHE_DIR} ${CCACHE_PROGRAM}")
endif()
message(STATUS "Using CCACHE: ${CCACHE_PROGRAM}")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PROGRAM})
else()
message(
FATAL_ERROR
"Unable to find the program ccache. Set SERENE_DISABLE_CCACHE to ON")
endif()
endif()
if(SERENE_BUILD_TESTING)
enable_testing()
find_package(GTest REQUIRED)
# For Windows: Prevent overriding the parent project's compiler/linker
# settings
set(gtest_force_shared_crt
ON
CACHE BOOL "" FORCE)
endif()
add_link_options(-Wl,-Map=output.map)
# LLVM setup
# ================================================================== Why not
# specify the version? Since we use the development version of the LLVM all
# the time it doesn't make sense to use a version here
find_package(LLVM REQUIRED CONFIG)
find_package(MLIR REQUIRED CONFIG)
find_package(LLD REQUIRED CONFIG)
find_program(LLD_PROGRAM REQUIRED NAMES lld)
message(STATUS "Found LLVM ${LLVM_PAsCKAGE_VERSION}")
find_program(MLIRTBLGEN_PROGRAM REQUIRED NAMES mlir-tblgen)
find_package(Clang REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
message(STATUS "Using LLDConfig.cmake in: ${LLD_DIR}")
message(STATUS "Using CLANGConfig.cmake in: ${Clang_DIR}")
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
# Make cmake modules available to load
list(APPEND CMAKE_MODULE_PATH "${MLIR_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLD_DIR}")
list(APPEND CMAKE_MODULE_PATH "${Clang_DIR}")
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)
include(AddClang)
include_directories(${LLVM_INCLUDE_DIRS})
include_directories(${MLIR_INCLUDE_DIRS})
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/include)
link_directories(${LLVM_BUILD_LIBRARY_DIR})
# This goes against the CMake's best practices to add these kind of settings
# to the targets only. But this is what LLVM recommends and we will stick to
# their recommendation.
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
# /LLVM setup
# =================================================================
# add_subdirectory(serene-tblgen)
add_subdirectory(serene)
# include(tablegen-serene) Create the tools we use to compile Serene
llvm_map_components_to_libnames(llvm_libs support core irreader)
# The compiled library code is here add_subdirectory(libserene) The static
# library containing builtin special forms and functions
# add_subdirectory(core) Binary tools of the compiler
# add_subdirectory(serenec) add_subdirectory(serene-repl)
# The compiled library code is here
add_subdirectory(src/serene)
# add_subdirectory(devtools)
# The executable code is here
add_subdirectory(bin)
add_subdirectory(include)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
# Testing only available if this is the main app
# Emergency override SERENE_CMAKE_BUILD_TESTING provided as well
if(BUILD_TESTING)
message("Build the test binary")
add_subdirectory(src/tests)
if(SERENE_ENABLE_DOCS)
add_subdirectory(docs)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Release")
# Docs only available if this is the main app
find_package(Doxygen
REQUIRED dot
OPTIONAL_COMPONENTS dia)
if(Doxygen_FOUND)
add_subdirectory(docs)
else()
message(STATUS "Doxygen not found, not building docs")
endif()
endif()
endif()

352
LICENSE Executable file → Normal file
View File

@ -1,19 +1,339 @@
Copyright (c) 2020 Sameer Rahmani <lxsameer@gnu.org>
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
Preamble
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

33
README.md Normal file
View File

@ -0,0 +1,33 @@
# Serene lang
[![Please don't upload to GitHub](https://nogithub.codeberg.page/badge.svg)](https://nogithub.codeberg.page)
[![status-badge](https://ci.devheroes.codes/api/badges/Serene/serene/status.svg)](https://ci.devheroes.codes/Serene/serene)
Serene is a modern typed lisp. It's not done yet, and it's heavily under development. Don't
expect anything stable for now.
## More Info
- Website: https://serene-lang.org
- Documentation: https://serene-lang.org/getting_started/
- CI: https://ci.devheroes.codes/Serene/serene
# Get Help
If you need help, or you just want to hang out, you can find us at:
- *IRC*: *#serene-lang* on the libera chat server
- *Matrix*: https://app.element.io/#/room/#serene:matrix.org
- *MailingList*: https://www.freelists.org/list/serene
# License
Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
*Serene* is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 2.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

View File

@ -1,75 +0,0 @@
* Serene lang
** Setup development environment
Setup the githook and install dependencies using the following commands:
#+BEGIN_SRC bash
./builder setup
#+END_SRC
*** Dependencies
You would need the following dependencies to start get started with *Serene* development
- LLVM (LLVM Instructions coming up.)
- cmake
- ninja
- doxygen (If you want to build the docs as well)
- Valgrind
- CCache (If you want faster builds specially with the LLVM)
** LLVM Installation
MLIR is a part of the [[https://llvm.org][LLVM]] project and in order to build it we need to build the LLVM itself as well.
Here is a quick guide to build the latest version of the LLVM and MLIR.
#+BEGIN_SRC bash
## YES we're using the development version of MLIR
git clone https://github.com/llvm/llvm-project.git
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja ../llvm \
-DCMAKE_INSTALL_PREFIX=/your/target/path \
-DLLVM_PARALLEL_COMPILE_JOBS=7 \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_CCACHE_BUILD=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DLLVM_ENABLE_PROJECTS='clang;lldb;lld;mlir;clang-tools-extra;compiler-rt' \
-DCMAKE_C_COMPILER=clang \ # If you have clang installed already
-DCMAKE_CXX_COMPILER=clang++ \ # If you have clang installed already
-DLLVM_ENABLE_LLD=ON
cmake --build .
cmake --build . --target check-mlir
cmake -DCMAKE_INSTALL_PREFIX=/your/target/location -P cmake_install.cmake
#+END_SRC
You need to have =clang= and =lld= installed to compile the LLVM with the above command. Also if you
are not using =ccache= just remove the option related to it from the above command.
*** Emacs
If you're using Emacs as your development environment just install =clangd= and =lsp=.
* How to build
In order to build for development (Debug mode) just use =./builder build= to setup the build and build
the project once and then you can just use =./builder compile= to build the changed files only.
Check out the =builder= script for more subcommands and details.
* Cheatsheets
- [[https://github.com/muqsitnawaz/modern-cpp-cheatsheet][Modern C++ Cheatsheet]]
* Get Help
If you need help or you just want to hangout, you can find us at:
- *IRC*: *#serene-lang* on the freenode server
- *Matrix Network*: https://matrix.to/#/#serene:matrix.org?via=matrix.org&via=gitter.im
- *MailingList*: https://www.freelists.org/list/serene

View File

@ -1,40 +0,0 @@
add_executable(serenec serene.cpp)
# Make sure to generate files related to the dialects first
add_dependencies(serenec SereneDialectGen)
if (CPP_20_SUPPORT)
target_compile_features(serenec PRIVATE cxx_std_20)
else()
target_compile_features(serenec PRIVATE cxx_std_17)
endif()
target_link_libraries(serenec PRIVATE
serene
${llvm_libs}
MLIRAnalysis
MLIRIR
MLIRParser
MLIRSideEffectInterfaces
MLIRTransforms
LLVMX86AsmParser
LLVMOption
#clangTooling
clangDriver
clangBasic
clangdSupport
clangFrontend
clangEdit
clangLex
)
target_include_directories(serene SYSTEM PRIVATE $ENV{INCLUDE})
target_include_directories(serene PRIVATE ${INCLUDE_DIR})
install(TARGETS serenec DESTINATION bin)
install(FILES "${PROJECT_BINARY_DIR}/config.h" DESTINATION include)
cotire(serenec)

View File

@ -1,295 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "serene/serene.h"
#include "mlir/ExecutionEngine/ExecutionEngine.h"
#include "serene/context.h"
#include "serene/namespace.h"
#include "serene/reader/reader.h"
#include "serene/reader/semantics.h"
#include "serene/slir/generatable.h"
#include "serene/slir/slir.h"
#include <clang/Driver/Compilation.h>
#include <clang/Driver/Driver.h>
#include <clang/Frontend/TextDiagnosticPrinter.h>
#include <clang/Tooling/Tooling.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/FileSystem.h>
#include <llvm/Support/FormatVariadic.h>
#include <llvm/Support/Host.h>
#include <llvm/Support/TargetRegistry.h>
#include <llvm/Support/TargetSelect.h>
#include <llvm/Support/raw_ostream.h>
#include <llvm/Target/TargetMachine.h>
#include <llvm/Target/TargetOptions.h>
#include <memory>
using namespace std;
using namespace serene;
namespace cl = llvm::cl;
namespace {
enum Action {
None,
DumpAST,
DumpSLIR,
DumpMLIR,
DumpSemantic,
DumpLIR,
DumpIR,
CompileToObject
};
}
static cl::opt<std::string> inputFile(cl::Positional,
cl::desc("The Serene file to compile"),
cl::init("-"),
cl::value_desc("filename"));
static cl::opt<std::string> outputFile("o",
cl::desc("The path to the output file"),
cl::init("-"),
cl::value_desc("filename"));
static cl::opt<enum Action> emitAction(
"emit", cl::desc("Select what to dump."), cl::init(CompileToObject),
cl::values(clEnumValN(DumpSemantic, "semantic",
"Output the AST after one level of analysis only")),
cl::values(clEnumValN(DumpIR, "ir", "Output the lowered IR only")),
cl::values(clEnumValN(DumpSLIR, "slir", "Output the SLIR only")),
cl::values(clEnumValN(DumpMLIR, "mlir",
"Output the MLIR only (Lowered SLIR)")),
cl::values(clEnumValN(DumpLIR, "lir",
"Output the LIR only (Lowerd to LLVM dialect)")),
cl::values(clEnumValN(DumpAST, "ast", "Output the AST only")),
cl::values(clEnumValN(CompileToObject, "object",
"Compile to object file. (Default)"))
);
exprs::Ast readInputFile() {
auto r = make_unique<reader::FileReader>(inputFile);
auto maybeAst = r->read();
if (!maybeAst) {
throw std::move(maybeAst.getError());
}
return maybeAst.getValue();
};
exprs::Ast readAndAnalyze(SereneContext &ctx) {
auto ast = readInputFile();
auto afterAst = reader::analyze(ctx, ast);
if (!afterAst) {
throw std::move(afterAst.getError());
}
return afterAst.getValue();
};
int dumpAsObject(Namespace &ns) {
auto &module = ns.getLLVMModule();
auto targetTriple = llvm::sys::getDefaultTargetTriple();
module.setTargetTriple(targetTriple);
std::string Error;
auto target = llvm::TargetRegistry::lookupTarget(targetTriple, Error);
// Print an error and exit if we couldn't find the requested target.
// This generally occurs if we've forgotten to initialise the
// TargetRegistry or we have a bogus target triple.
if (!target) {
llvm::errs() << Error;
return 1;
}
auto cpu = "generic";
auto features = "";
llvm::TargetOptions opt;
auto rm = llvm::Optional<llvm::Reloc::Model>();
auto targetMachinePtr =
target->createTargetMachine(targetTriple, cpu, features, opt, rm);
auto targetMachine = std::unique_ptr<llvm::TargetMachine>(targetMachinePtr);
module.setDataLayout(targetMachine->createDataLayout());
auto filename =
strcmp(outputFile.c_str(), "-") == 0 ? "output" : outputFile.c_str();
std::error_code ec;
llvm::raw_fd_ostream dest(llvm::formatv("{0}.o", filename).str(), ec,
llvm::sys::fs::OF_None);
if (ec) {
llvm::errs() << "Could not open file: " << ec.message();
return 1;
}
llvm::legacy::PassManager pass;
auto fileType = llvm::CGFT_ObjectFile;
if (targetMachine->addPassesToEmitFile(pass, dest, nullptr, fileType)) {
llvm::errs() << "TheTargetMachine can't emit a file of this type";
return 1;
}
pass.run(module);
dest.flush();
llvm::outs() << "Wrote " << filename << "\n";
clang::IntrusiveRefCntPtr<clang::DiagnosticIDs> diagID(
new clang::DiagnosticIDs());
clang::IntrusiveRefCntPtr<clang::DiagnosticOptions> diagOpts =
new clang::DiagnosticOptions();
clang::TextDiagnosticPrinter diagPrinter(llvm::errs(), &*diagOpts);
clang::DiagnosticsEngine diags(diagID, &*diagOpts, &diagPrinter);
clang::driver::Driver d("clang", targetTriple, diags, "Serene compiler");
std::vector<const char *> args;
args.push_back(filename);
args.push_back("-o");
args.push_back(
llvm::formatv("/home/lxsameer/src/serene/serene/build/{0}.o", filename)
.str()
.c_str());
d.setCheckInputsExist(false);
const std::unique_ptr<clang::driver::Compilation> compilation(
d.BuildCompilation(args));
if (!compilation) {
return 1;
}
llvm::SmallVector<std::pair<int, const clang::driver::Command *>> failCommand;
// compilation->ExecuteJobs(compilation->getJobs(), failCommand);
d.ExecuteCompilation(*compilation, failCommand);
if (failCommand.empty()) {
llvm::outs() << "Done!\n";
} else {
llvm::errs() << "Linking failed!\n";
}
// const llvm::opt::ArgStringList *const cc1Args = n
// getCC1Arguments(&diags, compilation.get());
// if (!cc1Args)
// return 2;
// std::unique_ptr<clang::CompilerInvocation> Invocation(
// clang::tooling::newInvocation(&diags, *cc1Args, "hnt"));
// return clang::tooling::runInvocation("hnt", compilation.get(),
// std::move(Invocation),
// std::move(PCHContainerOps));
return 0;
};
int main(int argc, char *argv[]) {
// mlir::registerAsmPrinterCLOptions();
mlir::registerMLIRContextCLOptions();
mlir::registerPassManagerCLOptions();
llvm::InitializeAllTargetInfos();
llvm::InitializeAllTargets();
llvm::InitializeAllTargetMCs();
llvm::InitializeAllAsmParsers();
llvm::InitializeAllAsmPrinters();
cl::ParseCommandLineOptions(argc, argv, "Serene compiler \n");
auto ctx = makeSereneContext();
auto ns = makeNamespace(*ctx, "user", llvm::None);
// TODO: We might want to find a better place for this
applyPassManagerCLOptions(ctx->pm);
switch (emitAction) {
// Just print out the raw AST
case Action::DumpAST: {
auto ast = readInputFile();
llvm::outs() << exprs::astToString(&ast) << "\n";
return 0;
};
case Action::DumpSemantic: {
auto ast = readAndAnalyze(*ctx);
llvm::outs() << exprs::astToString(&ast) << "\n";
return 0;
};
case Action::DumpSLIR: {
ctx->setOperationPhase(CompilationPhase::SLIR);
break;
}
case Action::DumpMLIR: {
ctx->setOperationPhase(CompilationPhase::MLIR);
break;
}
case Action::DumpLIR: {
ctx->setOperationPhase(CompilationPhase::LIR);
break;
}
case Action::DumpIR: {
ctx->setOperationPhase(CompilationPhase::IR);
break;
}
case Action::CompileToObject: {
ctx->setOperationPhase(CompilationPhase::NoOptimization);
break;
}
default: {
llvm::errs() << "No action specified. TODO: Print out help here\n";
return 1;
}
}
auto afterAst = readAndAnalyze(*ctx);
auto isSet = ns->setTree(afterAst);
if (isSet.succeeded()) {
ctx->insertNS(ns);
if (mlir::failed(serene::slir::generate<Namespace>(*ns))) {
llvm::errs() << "IR generation faild\n";
return 1;
}
if (emitAction < CompileToObject) {
serene::slir::dump<Namespace>(*ns);
} else {
return dumpAsObject(*ns);
}
} else {
llvm::outs() << "Can't set the tree of the namespace!\n";
}
return 0;
}

191
builder
View File

@ -1,191 +0,0 @@
#! /bin/bash
command=$1
# Utilize `ccache` if available
if type "ccache" > /dev/null
then
CC="$(which ccache) $(which clang)"
CXX="$(which ccache) $(which clang++)"
else
CC=$(which clang)
CXX=$(which clang++)
fi
export CC
export CXX
export CCACHE_SLOPPINESS="pch_defines,time_macros"
# Meke sure to use `lld` linker it faster and has a better UX
export LDFLAGS="-fuse-ld=lld"
export ASAN_FLAG="-fsanitize=address"
export ASAN_OPTIONS=check_initialization_order=1
LSAN_OPTIONS=suppressions=$(pwd)/.ignore_sanitize
export LSAN_OPTIONS
# The `builder` script is supposed to be run from the
# root of the source tree
ROOT_DIR=$(pwd)
BUILD_DIR=$ROOT_DIR/build
scanbuild=scan-build
function pushed_build() {
pushd "$BUILD_DIR" > /dev/null || return
}
function popd_build() {
popd > /dev/null || return
}
function compile() {
pushed_build
ninja -j "$(nproc)"
popd_build
}
function build() {
pushed_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug "$@" "$ROOT_DIR"
ninja -j "$(nproc)"
popd_build
}
function build-20() {
pushed_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCPP_20_SUPPORT=ON "$@" "$ROOT_DIR"
ninja -j "$(nproc)"
popd_build
}
function build-release() {
pushed_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release "$ROOT_DIR"
ninja -j "$(nproc)"
popd_build
}
function build-docs() {
pushed_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Docs "$ROOT_DIR"
ninja -j "$(nproc)"
popd_build
}
function clean() {
rm -rf "$BUILD_DIR"
}
function run() {
pushed_build
"$BUILD_DIR"/bin/serenec "$@"
popd_build
}
function memcheck() {
export ASAN_FLAG=""
build
pushed_build
valgrind --tool=memcheck --leak-check=yes --trace-children=yes "$BUILD_DIR"/bin/serenec "$@"
popd_build
}
function run-tests() {
"$BUILD_DIR"/src/tests/tests
}
function tests() {
pushed_build
cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON "$ROOT_DIR"
ninja -j "$(nproc)"
popd_build
}
case "$command" in
"setup")
pushd ./scripts || return
./git-pre-commit-format install
popd || return
echo "=== Manual action required ==="
echo "Set this environment variable. (clang-format-diff.py is located inside llvm's source directory)."
echo 'export CLANG_FORMAT_DIFF="python3 /path/to/llvm/saurce/llvm-project/clang/tools/clang-format/clang-format-diff.py"'
;;
"build")
clean
mkdir -p "$BUILD_DIR"
build "${@:2}"
;;
"build-20")
clean
mkdir -p "$BUILD_DIR"
build-20 "${@:2}"
;;
"build-docs")
clean
mkdir -p "$BUILD_DIR"
build-docs "${@:2}"
;;
"build-release")
clean
mkdir -p "$BUILD_DIR"
build-release "${@:2}"
;;
"compile")
compile
;;
"compile-and-test")
compile
run-tests
;;
"run")
run "${@:2}"
;;
"run-tests")
run-tests "${@:2}"
;;
"scan-build")
clean
mkdir -p "$BUILD_DIR"
pushed_build
exec $scanbuild cmake "$ROOT_DIR"
exec $scanbuild scan-build make -j 4
popd_build
;;
"memcheck")
memcheck "${@:2}"
;;
"tests")
clean
mkdir -p "$BUILD_DIR"
tests
run-tests
;;
"clean")
rm -rf "$BUILD_DIR"
;;
"full-build")
clean
mkdir -p "$BUILD_DIR"
build
tests
run-tests
memcheck
;;
*)
echo "Commands: "
echo "setup - Setup the githooks for devs"
echo "full-build - Build and test Serene."
echo "build - Build Serene from scratch in DEBUG mode."
echo "build-release - Build Serene from scratch in RELEASE mode."
echo "compile - reCompiles the project using the already exist cmake configuration"
echo "compile-and-tests - reCompiles the project using the already exist cmake configuration and runs the tests"
echo "run - Runs the serene executable"
echo "scan-build - Compiles serene with static analyzer"
echo "tests - Runs the test cases"
echo "memcheck - Runs the memcheck(valgrind) tool."
echo "clean - :D"
;;
esac

29
cmake/caches/debug.cmake Normal file
View File

@ -0,0 +1,29 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file sets up a CMakeCache to build serene for development. In this
# cache file we assume that you are using the toolchain and musl that are
# built by the `builder` script. For example: `builder deps build llvm`
# You still can just build everything yourself but the builder script and
# this file make the process easier.
# Where to find the packages. Packages can be built from source
# or downloaded via the builder script.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "")
set(SERENE_CCACHE_DIR "$ENV{HOME}/.ccache" CACHE STRING "")
set(CMAKE_BUILD_TYPE "Debug")

View File

@ -0,0 +1,29 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file sets up a CMakeCache to build serene for development. In this
# cache file we assume that you are using the toolchain and musl that are
# built by the `builder` script. For example: `builder deps build llvm`
# You still can just build everything yourself but the builder script and
# this file make the process easier.
# Where to find the packages. Packages can be built from source
# or downloaded via the builder script.
set(CMAKE_EXPORT_COMPILE_COMMANDS OFF CACHE BOOL "")
set(SERENE_CCACHE_DIR "$ENV{HOME}/.ccache" CACHE STRING "")
set(CMAKE_BUILD_TYPE "Release")

11
cmake/find-sphinx.cmake Normal file
View File

@ -0,0 +1,11 @@
#Look for an executable called sphinx-build
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
DOC "Path to sphinx-build executable")
include(FindPackageHandleStandardArgs)
#Handle standard arguments to find_package like REQUIRED and QUIET
find_package_handle_standard_args(Sphinx
"Failed to find sphinx-build executable"
SPHINX_EXECUTABLE)

View File

@ -0,0 +1,22 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
function(serene_tablegen ofn)
tablegen(SERENE ${ARGV})
set(TABLEGEN_OUTPUT ${TABLEGEN_OUTPUT} ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
PARENT_SCOPE)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endfunction()

View File

@ -0,0 +1,49 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file sets up a CMakeCache to build serene for development. In this
# cache file we assume that you are using the toolchain and musl that are
# built by the `builder` script. For example: `builder deps build llvm`
# You still can just build everything yourself but the builder script and
# this file make the process easier.
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(triple x86_64-pc-linux-musl)
set(CMAKE_SYSROOT ${SERENE_TOOLCHAIN_PATH})
set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT})
set(CMAKE_C_COMPILER "clang")
set(CMAKE_C_COMPILER_AR "llvm-ar")
set(CMAKE_C_COMPILER_RANLIB "llvm-ranlib")
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_CXX_COMPILER_AR "llvm-ar")
set(CMAKE_CXX_COMPILER_RANLIB "llvm-ranlib")
set(CMAKE_ASM_COMPILER "clang")
set(CMAKE_ASM_COMPILER_AR "llvm-ar")
set(CMAKE_ASM_COMPILER_RANLIB "llvm-ranlib")
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_ASM_COMPILER_TARGET ${triple})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

85
core/CMakeLists.txt Normal file
View File

@ -0,0 +1,85 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${LIBSERENE_INCLUDE_DIR})
add_subdirectory(lib/serene)
get_target_property(LIBNAME Serene::core CMAKE_PKG_NAME)
# Install rules for libserene target
install(TARGETS core
EXPORT CoreExports
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# Install rules for the public header files.
install(DIRECTORY ${INCLUDE_DIR}/serene
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN *.h
PATTERN *.td
PATTERN "CMake*" EXCLUDE)
# Install rule for the public generated header files
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN *.h
PATTERN *.td
PATTERN *.h.inc
PATTERN "CMake*" EXCLUDE)
include(CMakePackageConfigHelpers)
# Package config file let us use find_package with serene
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/${LIBNAME}Config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/serene-core-${PROJECT_VERSION}
)
write_basic_package_version_file(
"CoreConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${LIBNAME}ConfigVersion.cmake"
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/serene-core-${PROJECT_VERSION}
)
# Install the package exports
install(EXPORT CoreExports
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/serene-core-${PROJECT_VERSION}
NAMESPACE serene::)
# Testing only available if this is the main app
# Emergency override SERENE_CMAKE_BUILD_TESTING provided as well
if(SERENE_BUILD_TESTING)
message("Build the test binary")
add_subdirectory(tests)
endif()

View File

@ -0,0 +1,21 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Exports.cmake")
check_required_components("@PROJECT_NAME@")

View File

@ -0,0 +1,29 @@
/* -*- C++ -*-
* Serene Programming Language
*
* Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SERENE_CORE_CORE_H
#define SERENE_CORE_CORE_H
#include "serene/export.h"
namespace serene {
extern "C" int SERENE_EXPORT read() asm("serene.core/read");
extern "C" int SERENE_EXPORT compile() asm("serene.core/compile");
} // namespace serene
#endif

View File

@ -0,0 +1,70 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#TODO: To support MacOS look into cmake's public headers
# https://cmake.org/cmake/help/latest/prop_tgt/PUBLIC_HEADER.html
# Prevent any future RPATH issue on Posix
if(NOT APPLE)
set(CMAKE_INSTALL_RPATH $ORIGIN)
endif()
set(SOURCES core.cpp)
add_library(core OBJECT
${SOURCES})
#add_custom_target(serene.core)
# Create an ALIAS target. This way if we mess up the name
# there will be an cmake error inseat of a linker error which is harder
# to understand. So any binary that wants to use serene has to
# use `Serene::core` alias instead
add_library(Serene::core ALIAS core)
set_target_properties(core PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
CMAKE_PKG_NAME SereneCore
# Warn on unused libs
LINK_WHAT_YOU_USE TRUE
CXX_INCLUDE_WHAT_YOU_USE "${iwyu_path}"
C_INCLUDE_WHAT_YOU_USE "${iwyu_path}"
# LTO support we need the actual object file
# LTO will export them to llvm IR
INTERPROCEDURAL_OPTIMIZATION FALSE)
target_compile_options(core PRIVATE --static)
target_link_options(core PRIVATE --static)
if(SERENE_ENABLE_TIDY)
set_target_properties(core PROPERTIES CXX_CLANG_TIDY ${CLANG_TIDY_PATH})
endif()
if (CPP_20_SUPPORT)
target_compile_features(core PUBLIC cxx_std_20)
else()
target_compile_features(core PUBLIC cxx_std_17)
endif()
# We need this directory, and users of our library will need it too
target_include_directories(core PUBLIC "$<BUILD_INTERFACE:${INCLUDE_DIR}>")
target_include_directories(core PUBLIC "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>")
# Generate the export.h
include(GenerateExportHeader)
generate_export_header(core EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/serene/core/export.h)
target_link_libraries(core PRIVATE)

View File

@ -0,0 +1,31 @@
/* -*- C++ -*-
* Serene Programming Language
*
* Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "serene/core/core.h"
#include "serene/types/types.h"
#include <cstdio>
namespace serene {
extern "C" int SERENE_EXPORT compile() {
printf("compile11\n");
return 2;
};
} // namespace serene

20
core/lib/serene/core.cpp Normal file
View File

@ -0,0 +1,20 @@
/*
* Serene Programming Language
*
* Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <compiler.cpp.inc>
#include <reader.cpp.inc>

View File

@ -0,0 +1,26 @@
/* -*- C++ -*-
* Serene Programming Language
*
* Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "serene/core/core.h"
#include "serene/types/types.h"
namespace serene {
int read() { return 0; };
} // namespace serene

167
dev.org
View File

@ -1,7 +1,7 @@
#+TITLE: Serene Development
#+AUTHOR: Sameer Rahmani
#+SEQ_TODO: TODO(t/!) NEXT(n/!) BLOCKED(b@/!) | DONE(d%) WONT_DO(c@/!) FAILED(f@/!)
#+TAGS: DOCS(d) EXAMPLES(e) BOOTSTRAP(b) Old(o) Misc(m)
#+TAGS: DOCS(d) EXAMPLES(e) serenecli(c) reader(r) context(x) Misc(m) JIT(j) GC(g) Tool(t)
#+STARTUP: logdrawer logdone logreschedule indent content align constSI entitiespretty nolatexpreview
#+OPTIONS: tex:t
#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Eule
@ -36,6 +36,8 @@ Then here is the list or parsers that we have considered
- [[http://www.lispworks.com/documentation/HyperSpec/Body/02_df.htm][Backquote in CL]]
- [[https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node367.html][Backquote spec in Common Lisp the Language, 2nd Edition]]
- [[http://christophe.rhodes.io/notes/blog/posts/2014/backquote_and_pretty_printing/][Backquote and pretty printing]]
*** Compilers
- https://bernsteinbear.com/blog/compiling-a-lisp-0/
** Rust
- [[https://doc.rust-lang.org/book/][The Rust book]] (in [[https://www.reddit.com/r/rust/comments/2s1zj2/the_rust_programming_language_book_as_epub/][EPUB]] format)
** LLVM
@ -55,6 +57,13 @@ Then here is the list or parsers that we have considered
- [[https://julialang.org/research/julia-fresh-approach-BEKS.pdf][Julia: A Fresh Approach toNumerical Computing]]
** Cranelift
- [[https://github.com/bytecodealliance/wasmtime/tree/master/cranelift][Source tree]]
** Type Systems
- [[https://www.cs.cmu.edu/~rwh/courses/hott/][Homotopy Type Theory]]
- No, dynamic type systems are not inherently more open:
https://lexi-lambda.github.io/blog/2020/01/19/no-dynamic-type-systems-are-not-inherently-more-open/
- Type theory resources:
https://github.com/jozefg/learn-tt
** Memory management
- [[https://deepu.tech/memory-management-in-golang/][Visualizing memory management in Golang]]
- [[http://goog-perftools.sourceforge.net/doc/tcmalloc.html][TCMalloc : Thread-Caching Malloc]]
@ -62,18 +71,32 @@ Then here is the list or parsers that we have considered
** Concurrency
- [[https://www.ardanlabs.com/blog/2018/08/scheduling-in-go-part1.html][Scheduling In Go (Series)]]
** Garbage collection
** Garbage collection :GC:
- [[https://v8.dev/blog/high-performance-cpp-gc][GC on V8]]
- [[https://www.microsoft.com/en-us/research/uploads/prod/2020/11/perceus-tr-v1.pdf][Perceus: Garbage Free Reference Counting with Reuse]]
- [[https://www.hboehm.info/gc/][Boehm GC]]
*** [[https://www.hboehm.info/gc/][Boehm GC]] :Tool:
*** [[https://www.ravenbrook.com/project/mps/][MPS]] :Tool:
*** [[https://www.mmtk.io/code][MMTK]] :Tool:
*** [[https://github.com/JWesleySM/Whiro][Whiro]] :Tool:
This is not GC but a tool to debug GC and memory allocation.
** JIT
- [[https://asmjit.com/][Machine code generator for C++]]
- https://www.youtube.com/watch?v=hILdR8XRvdQ&t=1511s
** Optimizations
- [[https://sunfishcode.github.io/blog/2018/10/22/Canonicalization.html][Canonicalization]]
** Compiler
- [[https://eli.thegreenplace.net/2011/09/06/stack-frame-layout-on-x86-64][Stack frame layout on x86-64]]
*** Branch instructions
It would be cool to have macro to instruct the compiler about the likelyhood
of a branch in a conditional. Something similar to kernel's *likely* and *unlikely*
macros
*** How to learn compilers: LLVM Edition
https://lowlevelbits.org/how-to-learn-compilers-llvm-edition/
*** Pointers Are Complicated III, or: Pointer-integer casts exposed
https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html
*** Execution Instrumentation
The compiler should be able to embed some code in the program to collect data about
the different execution paths or function instrumentation and other useful data the
@ -93,49 +116,129 @@ on ADF
*** Emacs mode
- [[https://www.wilfred.me.uk/blog/2015/03/19/adding-a-new-language-to-emacs/][Adding A New Language to Emacs]]
- [[https://www.wilfred.me.uk/blog/2014/09/27/the-definitive-guide-to-syntax-highlighting/][The Definitive Guide To Syntax Highlighting]]
** Linker
- [[https://lwn.net/Articles/276782/][20 part linker essay]]
- [[https://lld.llvm.org/index.html][LLD Usage]]
** LLVM
- [[https://blog.yossarian.net/2021/07/19/LLVM-internals-part-1-bitcode-format][LLVM Internals]]
*** TableGen
- [[https://llvm.org/docs/TableGen/BackGuide.html#creating-a-new-backend][Create a backend]]
** Toolchain
- https://llvm.org/docs/BuildingADistribution.html
** Cross compilation
- https://blog.gibson.sh/2017/11/26/creating-portable-linux-binaries/#some-general-suggestions
A nice to read article on some of the common problems when linking statically
with none default libc or libc++
** Useful courses and resources
- https://www.cs.cornell.edu/courses/cs6120/2020fa/lesson/
- https://cs.lmu.edu/~ray/notes/languagedesignnotes/
* Considerations
** Hashmaps
*** DOS attack
- https://www.anchor.com.au/blog/2012/12/how-to-explain-hash-dos-to-your-parents-by-using-cats/
- https://en.wikipedia.org/wiki/Collision_attack
* Ideas
** Destructure types
Imagine a type that is a subset of a Coll, and when we
pass a Coll to its type constructor in destructs the input and
construct the type base on the data that it needs only and
leave the rest untouched
** Hot function optimization
it would be nice for the JIT to add instrumentation to the compiled
functions and detect hot functions similar to how javascript jits do it
and recompile those functions with more optimization passes
* Conversations
** Solutions to link other ~libc~ rather than the default
From my discassion with ~lhames~
#+BEGIN_QUOTE
I can think of a few approaches with different trade-offs:
- Link your whole JIT (including LLVM) against musl rather than the default -- JIT'd
code uses the desired libc, there's only one libc in the JIT'd process, but the
cost is high (perhaps prohibitive, depending on your constraints)
- JIT out-of-process -- JIT (including LLVM) uses default libc and is compiled only once,
executor links the (alternative) desired libc at compile time and must be compiled each
time that you want to change it -- JIT'd code uses the desired libc, there's only one libc
in the JIT'd process, but the config is involved (requires a cross-process setup)
- JIT in process, link desired libc via JIT -- Easy to set up, but now you've got two
libcs in the process. I've never tested that config. It might just work, it might
fail at link or runtime in weird ways.
#+END_QUOTE
* TODOs
** Bootstrap
*** TODO Replace =llvm::outs()= with debug statements
*** TODO Error handling
** Strings
*** TODO How to concat to strings in a functional and immutable way?
Should we include an pointer to another string???
** TODO Create =Catch2= generators to be used in tests. Specially for the =reader= tests
** TODO Investigate possible implementanion for Internal Errors
- An option is to use llvm registry functionality like the one used in =clang-doc= instead of
=errorVariants= var.
** TODO In =SereneContext::getLatestJITDylib= function, make sure that the JITDylib is still valid
Make sure that the returning Dylib still exists in the JIT
by calling =jit->engine->getJITDylibByName(dylib_name);=
** TODO Provide the CLI arguments to pass the =createTargetMachine=.
We need a way to tweak the target machine object. It's better to provide cli tools
to do so.
** TODO Walk the module and register the symbols with the engine (lazy and nonlazy) :JIT:
** TODO Change the compilation layer to accept MLIR modules instead of LLVM IR :JIT:
This way we can fine tune MLIR's passes based on the JIT settings as well
** TODO Create a pass to rename functions to include the ns name
** TODO Use =const= where ever it makes sense
** TODO Create different pass pipeline for different compilation phases
So we can use them directly via command line, like -O1 for example
** TODO Investigate the huge size of serenec
So far it seems that the static linking and the lack of tree shaking is the issue
** DONE Add the support for =ns-paths= :serenecli:context:
CLOSED: [2021-09-25 Sat 19:22]
:LOGBOOK:
- State "DONE" from "TODO" [2021-09-25 Sat 19:22]
:END:
We need to add the support for an array of paths to lookup namespaces. The =ns-paths= should
be an array that each entry represents a path which serene has to look into in order to find
a namespace. For instance, when serene wants to load the =foo.bar= namespace, it should walk
the paths in =ns-paths= and look for that ns. Similar to =classpath= in the JVM or =LOAD_PATH=
in python.
- [ ] Add the support to the *Context*.
- [ ] Add the support to *Namespace*.
- [ ] Add the cli argument to the =bin/serene.cpp=
** TODO Error handling
Create proper error handling for the internal infra
*** TODO Language Spec :DOCS:
*** TODO A proper List implementation
*** TODO Vector implementation
*** TODO Hashmap implementation
*** TODO Meta data support
*** TODO Docstring support :DOCS:
** TODO Replace =llvm::outs()= with debug statements
** TODO Move the generatable logic out of its files and remove them
** TODO Add a CLI option to get any extra pass
** TODO Add support for =sourcemgr= for input files
** TODO Language Spec :DOCS:
** TODO A proper List implementation
** TODO Vector implementation
** TODO Hashmap implementation
** TODO Meta data support
** TODO Docstring support :DOCS:
- [ ] For functions and macros
- [ ] For namespaces and projects
- [ ] API to interact with docstrings and helps
*** TODO FFI interface
*** TODO Load path and namespace loading
*** TODO nREPL
*** TODO Emacs mode :Misc:
*** TODO Number implementation
*** TODO String implementation
*** TODO Enum implementation
*** TODO Protocol
*** TODO Struct implementation
*** TODO Multi arity functions
*** TODO QuasiQuotation
*** TODO Linter :Misc:
*** TODO Document generator :DOCS:Misc:
*** TODO Spec like functionality
*** TODO Laziness implementation
*** TODO Investigate the Semantic Error tree and tracking
** TODO FFI interface
** TODO nREPL
** TODO Emacs mode :Misc:
** TODO Number implementation
** TODO String implementation
** TODO Enum implementation
** TODO Protocol
** TODO Struct implementation
** TODO Multi arity functions
** TODO QuasiQuotation
** TODO Linter :Misc:
** TODO Document generator :DOCS:Misc:
** TODO Spec like functionality
** TODO Laziness implementation
** TODO Investigate the Semantic Error tree and tracking
Basically we should be able to create an error tree on semantic analysis
time and trace semantic errors on different layers and intensively.
Is it a good idea ?
*** Standard libraries
**** TODO IO library
**** TODO Test library
** Standard libraries
*** TODO IO library
*** TODO Test library

93
devtools/CMakeLists.txt Normal file
View File

@ -0,0 +1,93 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
if (SERENE_ENABLE_DEVTOOLS)
add_executable(slir-lsp-server slir-lsp-server.cpp)
add_executable(Serene::SLIR::LSP ALIAS slir-lsp-server)
set_target_properties(slir-lsp-server PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
# Warn on unused libs
LINK_WHAT_YOU_USE TRUE
# LTO support
INTERPROCEDURAL_OPTIMIZATION TRUE)
if(SERENE_ENABLE_TIDY)
set_target_properties(slir-lsp-server PROPERTIES CXX_CLANG_TIDY ${CLANG_TIDY_PATH})
endif()
if (CPP_20_SUPPORT)
target_compile_features(slir-lsp-server PRIVATE cxx_std_20)
else()
target_compile_features(slir-lsp-server PRIVATE cxx_std_17)
endif()
target_link_libraries(slir-lsp-server
PRIVATE
Serene::lib
MLIRLspServerLib
)
target_include_directories(slir-lsp-server PRIVATE ${PROJECT_BINARY_DIR})
target_include_directories(slir-lsp-server PRIVATE ${INCLUDE_DIR})
install(TARGETS slir-lsp-server
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# ========
# slir-opt
# ========
add_executable(slir-opt slir-opt.cpp)
add_executable(Serene::SLIR::Opt ALIAS slir-opt)
set_target_properties(slir-opt PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
# Warn on unused libs
LINK_WHAT_YOU_USE TRUE
# LTO support
INTERPROCEDURAL_OPTIMIZATION TRUE)
if(SERENE_ENABLE_TIDY)
set_target_properties(slir-opt PROPERTIES CXX_CLANG_TIDY ${CLANG_TIDY_PATH})
endif()
if (CPP_20_SUPPORT)
target_compile_features(slir-opt PRIVATE cxx_std_20)
else()
target_compile_features(slir-opt PRIVATE cxx_std_17)
endif()
target_link_libraries(slir-opt
PRIVATE
Serene::lib
MLIROptLib
)
target_include_directories(slir-opt PRIVATE ${PROJECT_BINARY_DIR})
target_include_directories(slir-opt PRIVATE ${INCLUDE_DIR})
install(TARGETS slir-opt
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()

View File

@ -0,0 +1,35 @@
/* -*- C++ -*-
* Serene Programming Language
*
* Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "serene/slir/dialect.h"
#include <mlir/Dialect/Func/IR/FuncOps.h>
#include <mlir/IR/Dialect.h>
#include <mlir/Tools/mlir-lsp-server/MlirLspServerMain.h>
int main(int argc, char **argv) {
mlir::DialectRegistry registry;
serene::slir::registerTo(registry);
registry.insert<mlir::func::FuncDialect>();
// TODO: Register passes here
return static_cast<int>(
mlir::failed(mlir::MlirLspServerMain(argc, argv, registry)));
}

39
devtools/slir-opt.cpp Normal file
View File

@ -0,0 +1,39 @@
/* -*- C++ -*-
* Serene Programming Language
*
* Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "serene/passes.h"
#include "serene/slir/dialect.h"
#include <mlir/Dialect/Arithmetic/IR/Arithmetic.h>
#include <mlir/Dialect/Func/IR/FuncOps.h>
#include <mlir/Dialect/LLVMIR/LLVMDialect.h>
#include <mlir/IR/Dialect.h>
#include <mlir/Tools/mlir-opt/MlirOptMain.h>
int main(int argc, char **argv) {
mlir::DialectRegistry registry;
serene::slir::registerTo(registry);
registry.insert<mlir::arith::ArithmeticDialect, mlir::func::FuncDialect,
mlir::LLVM::LLVMDialect>();
serene::passes::registerAllPasses();
return static_cast<int>(
mlir::failed(mlir::MlirOptMain(argc, argv, "slir-opt", registry)));
}

View File

@ -1,16 +0,0 @@
set(DOXYGEN_GENERATE_HTML YES)
set(DOXYGEN_GENERATE_MAN YES)
set(DOXYGEN_EXTRACT_ALL YES)
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
set(DOXYGEN_PROJECT_BRIEF "Just another Lisp")
message("<<<<<<<<<<<<<<<<<<<<<<<<<<<")
message(${PROJECT_SOURCE_DIR})
message(${INCLUDE_DIR})
doxygen_add_docs(docs
#"${CMAKE_CURRENT_SOURCE_DIR}/index.md"
"${PROJECT_SOURCE_DIR}/src/"
${INCLUDE_DIR})
add_dependencies(serenec docs)

14
docs/Dockerfile Normal file
View File

@ -0,0 +1,14 @@
FROM docker.io/python
WORKDIR /app
COPY . .
RUN pip install -r docs/requirements.txt
RUN mkdocs build
FROM docker.io/busybox
COPY --from=0 /app/build/docs /app
WORKDIR /app
CMD ["busybox", "httpd", "-f", "-v", "-p", "3000"]

View File

@ -1,2 +1,2 @@
(def main (fn () 3))
(def main (fn () 4))
(def main1 (fn (v y n) 3))

View File

@ -0,0 +1,38 @@
module @some.ns {
// Value operator ----
%0 = "serene.value"(){value= 3} : () -> i64
// compact form
%1 = serene.value 3 : i32
%x = serene.symbol "some.ns" "x"
// Def operator ----
%foo = "serene.define"(%0){sym_name = "foo"}: (i64) -> !serene.symbol
// compact form
%bar = serene.define "bar", %0 : i64
// Fn operator ----
%f1 = "serene.fn"()({
^entry(%fnarg1 : i1, %fnarg2 : !serene.symbol):
%2 = serene.value 3 : i32
// Def operator ----
%baz = "serene.define"(%fnarg1){sym_name = "baz"}: (i1) -> !serene.symbol
serene.ret %baz : !serene.symbol
},
{
^b1(%f1 : i1):
%3 = serene.value 4 : i32
// Def operator ----
%baz1 = "serene.define"(%3){sym_name = "baz"}: (i32) -> !serene.symbol
serene.ret %baz1 : !serene.symbol
^b2:
%baz2 = "serene.define"(%3){sym_name = "baz"}: (i32) -> !serene.symbol
serene.ret %baz2 : !serene.symbol
}){name = "some-fn", return_type = i32} : () -> !serene.fn
%a1 = serene.value 1 : i1
%a2 = serene.value "x" : !serene.symbol
%result = serene.call %f1(%a1, %a2){} : (i1, !serene.symbol) -> i32
}

439
docs/imgs/ast.svg Normal file
View File

@ -0,0 +1,439 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="29cm"
height="10cm"
viewBox="0 0 290 99.999997"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="ast.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#2f2f2f"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="763.09643"
inkscape:cy="181.95893"
inkscape:document-units="mm"
inkscape:current-layer="g2389"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
units="cm" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g965"
transform="translate(168.03441,76.711761)" />
<g
id="g2389"
transform="matrix(0.75119316,0,0,0.75119316,51.312464,-32.10995)">
<g
id="g844"
transform="translate(13.040514,28.699914)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect833"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#333333;"
x="29.975029"
y="32.850342"
id="text839"><tspan
sodipodi:role="line"
id="tspan837"
x="29.975029"
y="32.850342"
style="stroke-width:0.264583;fill:#333333;">List</tspan></text>
</g>
<g
id="g852"
transform="translate(236.49722,28.699914)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect846"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="29.975029"
y="32.850342"
id="text850"><tspan
sodipodi:role="line"
id="tspan848"
x="29.975029"
y="32.850342"
style="fill:#1a1a1a;stroke-width:0.264583">List</tspan></text>
</g>
<g
id="g873"
transform="translate(-74.794886,79.485359)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect854"
width="50.245274"
height="24.248156"
x="17.127373"
y="18.076727" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#333333;"
x="24.819334"
y="28.069159"
id="text858"><tspan
sodipodi:role="line"
id="tspan856"
x="24.819334"
y="28.069159"
style="stroke-width:0.264583;fill:#333333;">Symbol</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#333333;"
x="34.455421"
y="37.899265"
id="text864"><tspan
sodipodi:role="line"
id="tspan862"
x="34.455421"
y="37.899265"
style="stroke-width:0.264583;fill:#333333;">def</tspan></text>
</g>
<g
id="g885"
transform="translate(-9.428929,79.485359)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect875"
width="50.245274"
height="24.248156"
x="17.127373"
y="18.076727" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#333333;"
x="24.819334"
y="28.069159"
id="text879"><tspan
sodipodi:role="line"
id="tspan877"
x="24.819334"
y="28.069159"
style="stroke-width:0.264583;fill:#333333;">Symbol</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#333333;"
x="30.550186"
y="37.899265"
id="text883"><tspan
sodipodi:role="line"
id="tspan881"
x="30.550186"
y="37.899265"
style="stroke-width:0.264583;fill:#333333;">main</tspan></text>
</g>
<g
id="g897"
transform="translate(8.560606,127.35446)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect887"
width="50.245274"
height="24.248156"
x="17.127373"
y="18.076727" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="24.819334"
y="28.069159"
id="text891"><tspan
sodipodi:role="line"
id="tspan889"
x="24.819334"
y="28.069159"
style="fill:#333333;stroke-width:0.264583">Symbol</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="37.482239"
y="37.899265"
id="text895"><tspan
sodipodi:role="line"
id="tspan893"
x="37.482239"
y="37.899265"
style="fill:#1a1a1a;stroke-width:0.264583">fn</tspan></text>
</g>
<g
id="g937"
transform="translate(194.83176,124.58311)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect927"
width="50.245274"
height="24.248156"
x="-51.96307"
y="20.848083" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="-44.271111"
y="30.840515"
id="text931"><tspan
sodipodi:role="line"
id="tspan929"
x="-44.271111"
y="30.840515"
style="fill:#1a1a1a;stroke-width:0.264583">Number</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="-29.835508"
y="40.67062"
id="text935"><tspan
sodipodi:role="line"
id="tspan933"
x="-29.835508"
y="40.67062"
style="fill:#1a1a1a;stroke-width:0.264583">4</tspan></text>
</g>
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect955"
width="50.245274"
height="24.248156"
x="17.127373"
y="16.008705"
transform="translate(168.03441,76.71176)" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="192.85374"
y="102.6676"
id="text959"><tspan
sodipodi:role="line"
id="tspan957"
x="192.85374"
y="102.6676"
style="fill:#1a1a1a;stroke-width:0.264583">Symbol</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="202.48984"
y="112.49773"
id="text963"><tspan
sodipodi:role="line"
id="tspan961"
x="202.48984"
y="112.49773"
style="fill:#1a1a1a;stroke-width:0.264583">prn</tspan></text>
<g
id="g997"
transform="translate(244.08463,122.05932)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect987"
width="50.245274"
height="24.248156"
x="17.127373"
y="18.076727" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="24.819334"
y="28.069159"
id="text991"><tspan
sodipodi:role="line"
id="tspan989"
x="24.819334"
y="28.069159"
style="fill:#1a1a1a;stroke-width:0.264583">Symbol</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="30.550186"
y="37.899265"
id="text995"><tspan
sodipodi:role="line"
id="tspan993"
x="30.550186"
y="37.899265"
style="fill:#1a1a1a;stroke-width:0.264583">main</tspan></text>
</g>
<g
id="g905"
transform="translate(71.553646,80.534686)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect899"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#333333;"
x="29.975029"
y="32.850342"
id="text903"><tspan
sodipodi:role="line"
id="tspan901"
x="29.975029"
y="32.850342"
style="stroke-width:0.264583;fill:#333333;">List</tspan></text>
</g>
<g
id="g925"
transform="translate(71.867786,128.40379)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect919"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="29.975029"
y="32.850342"
id="text923"><tspan
sodipodi:role="line"
id="tspan921"
x="29.975029"
y="32.850342"
style="fill:#1a1a1a;stroke-width:0.264583">List</tspan></text>
</g>
<g
id="g985"
transform="translate(248.15757,75.693066)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect979"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="29.975029"
y="32.850342"
id="text983"><tspan
sodipodi:role="line"
id="tspan981"
x="29.975029"
y="32.850342"
style="fill:#1a1a1a;stroke-width:0.264583">List</tspan></text>
</g>
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 37.22751,66.508878 -12.952959,97.562086"
id="path1037"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g844"
inkscape:connection-end="#g873" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 48.144985,66.508878 37.123996,97.562086"
id="path1039"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g844"
inkscape:connection-end="#g885" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 60.990496,66.508878 38.96731,34.519802"
id="path1041"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g844"
inkscape:connection-end="#g905" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 99.074574,118.34365 65.733643,145.43119"
id="path1043"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g905"
inkscape:connection-end="#g897" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 109.78753,118.34365 0.20051,30.55413"
id="path1045"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g905"
inkscape:connection-end="#g925" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 120.26758,118.34365 32.96775,27.08754"
id="path1047"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g905"
inkscape:connection-end="#g937" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 263.31186,66.508878 -37.11531,28.27961"
id="path1057"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g852" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 276.82246,66.508878 7.36401,29.67818"
id="path1059"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g852"
inkscape:connection-end="#g985" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 286.33464,113.50203 v 26.63402"
id="path1067"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g985"
inkscape:connection-end="#g997" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16cm"
height="10cm"
viewBox="0 0 160 99.999997"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="incorrct_semantic.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#2f2f2f"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="331.15811"
inkscape:cy="181.95893"
inkscape:document-units="mm"
inkscape:current-layer="g2389"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
units="cm" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g965"
transform="translate(168.03441,76.711761)" />
<g
id="g2389"
transform="matrix(0.75119316,0,0,0.75119316,51.312464,-32.10995)">
<g
id="g844"
transform="translate(0.0122228,25.177739)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect833"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="29.975029"
y="32.850342"
id="text839"><tspan
sodipodi:role="line"
id="tspan837"
x="29.975029"
y="32.850342"
style="fill:#333333;stroke-width:0.264583">List</tspan></text>
</g>
<g
id="g873"
transform="translate(-74.794886,75.963184)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect854"
width="50.245274"
height="24.248156"
x="17.127373"
y="19.014702" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="24.819334"
y="28.069159"
id="text858"><tspan
sodipodi:role="line"
id="tspan856"
x="24.819334"
y="28.069159"
style="fill:#333333;stroke-width:0.264583">Number</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="39.254936"
y="37.899265"
id="text864"><tspan
sodipodi:role="line"
id="tspan862"
x="39.254936"
y="37.899265"
style="fill:#333333;stroke-width:0.264583">4</tspan></text>
</g>
<g
id="g885"
transform="translate(66.698034,76.901159)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect875"
width="50.245274"
height="24.248156"
x="17.127373"
y="18.076727" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="24.819334"
y="28.069159"
id="text879"><tspan
sodipodi:role="line"
id="tspan877"
x="24.819334"
y="28.069159"
style="fill:#333333;stroke-width:0.264583">Symbol</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="30.550186"
y="37.899265"
id="text883"><tspan
sodipodi:role="line"
id="tspan881"
x="30.550186"
y="37.899265"
style="fill:#333333;stroke-width:0.264583">main</tspan></text>
</g>
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.352217px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M -15.350126,94.977886 27.529389,62.986703"
id="path922"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g873"
inkscape:connection-end="#g844" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.352217px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 48.852903,62.986703 91.747318,94.977886"
id="path924"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g844"
inkscape:connection-end="#g885" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.8 KiB

251
docs/imgs/semantic.svg Normal file
View File

@ -0,0 +1,251 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="922.8819"
height="235.56693"
viewBox="0 0 244.17924 62.327093"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="semantic.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#2f2f2f"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="565.58705"
inkscape:cy="393.87544"
inkscape:document-units="mm"
inkscape:current-layer="g905"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
units="px"
scale-x="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<g
id="g965"
transform="translate(168.03441,76.711761)" />
<g
id="g2389"
transform="matrix(0.75119316,0,0,0.75119316,51.312464,-32.10995)">
<g
id="g844"
transform="translate(-3.0341942,27.472385)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect833"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="29.975029"
y="32.850342"
id="text839"><tspan
sodipodi:role="line"
id="tspan837"
x="29.975029"
y="32.850342"
style="fill:#333333;stroke-width:0.264583">Def</tspan></text>
</g>
<g
id="g852"
transform="translate(155.69059,28.20857)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect846"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="29.975029"
y="32.850342"
id="text850"><tspan
sodipodi:role="line"
id="tspan848"
x="29.975029"
y="32.850342"
style="fill:#1a1a1a;stroke-width:0.264583">Call</tspan></text>
</g>
<g
id="g885"
transform="translate(-78.928215,77.877707)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect875"
width="50.245274"
height="24.248156"
x="17.127373"
y="18.076727" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="24.819334"
y="28.069159"
id="text879"><tspan
sodipodi:role="line"
id="tspan877"
x="24.819334"
y="28.069159"
style="fill:#333333;stroke-width:0.264583">Symbol</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="30.550186"
y="37.899265"
id="text883"><tspan
sodipodi:role="line"
id="tspan881"
x="30.550186"
y="37.899265"
style="fill:#333333;stroke-width:0.264583">main</tspan></text>
</g>
<g
id="g1187"
transform="translate(-57.763668,4.4614976)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.552882;stroke-linejoin:round"
id="rect955"
width="50.245274"
height="24.248156"
x="17.127373"
y="16.008705"
transform="translate(168.03441,76.71176)" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="192.85374"
y="102.6676"
id="text959"><tspan
sodipodi:role="line"
id="tspan957"
x="192.85374"
y="102.6676"
style="fill:#1a1a1a;stroke-width:0.264583">Symbol</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="202.48984"
y="112.49773"
id="text963"><tspan
sodipodi:role="line"
id="tspan961"
x="202.48984"
y="112.49773"
style="fill:#1a1a1a;stroke-width:0.264583">prn</tspan></text>
</g>
<g
id="g905"
transform="translate(55.478938,78.927034)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect899"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#333333;stroke-width:0.264583"
x="32.287472"
y="32.850342"
id="text903"><tspan
sodipodi:role="line"
id="tspan901"
x="32.287472"
y="32.850342"
style="fill:#333333;stroke-width:0.264583">Fn</tspan></text>
</g>
<g
id="g985"
transform="translate(190.39431,80.154563)">
<rect
style="fill:#ffffff;stroke:#ffffff;stroke-width:0.428288;stroke-linejoin:round"
id="rect979"
width="42.223991"
height="17.314972"
x="17.065075"
y="20.493992" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="29.975029"
y="32.850342"
id="text983"><tspan
sodipodi:role="line"
id="tspan981"
x="29.975029"
y="32.850342"
style="fill:#1a1a1a;stroke-width:0.264583">List</tspan></text>
</g>
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 23.058642,65.281349 -19.755257,95.954434"
id="path1039"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g844"
inkscape:connection-end="#g885" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 44.987986,65.281349 83.8109,99.421026"
id="path1041"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g844"
inkscape:connection-end="#g905" />
<path
style="display:inline;fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 187.68108,66.017534 162.87546,97.181963"
id="path1057"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#g852"
inkscape:connection-end="#g1187" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 200.35592,66.017534 23.13606,34.631016"
id="path1059"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-end="#g985"
inkscape:connection-start="#g852" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -0,0 +1,80 @@
---
title: Getting Started
---
# Getting Started
Serene is under heavy development. This guide is dedicated to help you to get started with
Serene development.
This guide assumes that you are familiar with C/C++ development and ecosystem.
## Are you a Linux user?
If you are using Linux (x86_64 only), then you're in luck. The `builder` script
will download the required toolchain automatically for you and set it up. So,
you can just use `builder` subcommands to develop serene (you still need to
install `cmake` and `ninja`).
You can disable this behaviour by setting the `USE_SERENE_TOOLCHAIN` env variable to
anything beside "true".
## Dependencies
Here is the list of dependencies that need to be present:
- `LLVM` (You can find the exact version in the `builder` script)
- `CMake` `>= 3.19`
- `Ninja`
- `include-what-you-use`
- `Valgrind` (Optional and only for development)
- `CCache` (If you want faster builds, specially with the LLVM)
- `Boehm GC` `v8.2.2`
make sure to build in statically with `-fPIC` flag.
- `zstd` (Only if you want to use prebuilt dependencies on Linux)
- Musl libc `v1.2.3` (It's not required but highly recommended)
- `libc++` (same version as LLVM abviously. It's not required but highly recommended)
- `compiler-rt` (same version as LLVM abviously. It's not required but highly recommended)
Serene build system uses Musl, libc++, and compiler-rt to generate a static binary.
You can use glibc, libgcc, and libstdc++ instead. But you might not be able to
cross compiler with Serene and also if anything happen to you, I might not be able
to help (I'll try for sure).
## Setup development environment
Before, you have to set up the necessary git hooks as follows:
```bash
./builder setup
```
## Build and installing dependencies (Other platforms)
Currently, the `builder` script does not support any platform beside GNU/Linux. So, you
need to build the dependencies yourself and make them available to the builder.
By the way, If you are interested, you can just hack the builder script and accommodate your
platform and contribute your changes to the project.
To build the dependencies in your platform, you can use the https://devheroes.codes/Serene/bootstrap-toolchain
repo as a reference or even modify it to support other platforms. Any contribution will be appreciated.
After all, it's just a cmake project. So, don't be afraid.
## How to build
To build for development (Debug mode) just use `./builder build` to setup the build system,
and build the project once, and then you can just use `./builder compile` to build the changed files
only.
Check out the `builder` script for more subcommands and details.
## How to debug
Since we're using the Boehm GC, to use a debugger, we need to turn off some of the signal
handlers that the debugger sets. To run the debugger (by default, lldb) with `serene`
just use the `lldb-run` subcommand of the builder script. In the debugger, after setting the
break point on the `main` function (`b main`) then use the following commands on:
```
process handle -p yes -s no -n no SIGPWR
process handle -p yes -s no -n no SIGXCPU
process handle -p yes -s no -n no SIGSEGV
```
## Cheatsheets
- [Modern C++ Cheatsheet](https://github.com/muqsitnawaz/modern-cpp-cheatsheet)
- [Modern CMake](https://cliutils.gitlab.io/modern-cmake/)

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

29
docs/pages/index.md Normal file
View File

@ -0,0 +1,29 @@
---
hide:
- navigation
- toc
title: Home
---
# “What I cannot create, I do not understand”
-- Richard Feynman
## Serene is ...
A modern lisp, and it is to be born. It started out of the curiosity of the author and his journey
through computer science and mathematics. We are at the early stages of the development process
and there is a long way to go. If you're interested, contact us by joining our mailing list and
checkout the git repository. Furthermore, we document our progress in development via some video
tutorials and code walkthrough that can be a good guide for the developers who are eager to join
the team. You can find the videos on [my :fontawesome-brands-youtube:{ .youtube } YouTube channel](https://www.youtube.com/c/lxsameer).
## Announcements:
### * How to build a compiler with LLVM and MLIR
I have decided to make a video series as a guide and walk through the Serenes code base. This
way, anyone who is interested in Serene but never done language development will have an easier
time getting started with Serene. It will also serve as a historical documentary for some
decisions and implementations that we made throughout the development process. The video series
in accessible via my YouTube channel and How to build a compiler with LLVM and MLIR playlist.
Looking forward to your feedback. :smile:
Date: `2021-08-15`

View File

@ -0,0 +1,18 @@
window.MathJax = {
tex: {
inlineMath: [["\\(", "\\)"]],
displayMath: [["\\[", "\\]"]],
processEscapes: true,
processEnvironments: true
},
options: {
ignoreHtmlClass: ".*|",
processHtmlClass: "arithmatex"
}
};
document$.subscribe(() => {
MathJax.typesetPromise()
})

192
docs/pages/resources.md Normal file
View File

@ -0,0 +1,192 @@
---
title: Resources
---
# Development Resource
## LLVM
- [Brief Overview of LLVM](https://www.infoworld.com/article/3247799/what-is-llvm-the-power-behind-swift-rust-clang-and-more.html)
- [A bit in depth details on LLVM](https://aosabook.org/en/llvm.html)
- [Official LLVM tutorial C++](https://llvm.org/docs/tutorial/)
- [Interactive C++ with Cling](https://blog.llvm.org/posts/2020-11-30-interactive-cpp-with-cling/)
- [My First LLVM Compiler](https://www.wilfred.me.uk/blog/2015/02/21/my-first-llvm-compiler/)
- [A Complete Guide to LLVM for Programming Language Creators](https://mukulrathi.co.uk/create-your-own-programming-language/llvm-ir-cpp-api-tutorial/)
- [LLVM Internals](https://blog.yossarian.net/2021/07/19/LLVM-internals-part-1-bitcode-format)
- [How to learn about compilers (LLVM Version)](https://lowlevelbits.org/how-to-learn-compilers-llvm-edition/)
### TableGen
- [Create a backend](https://llvm.org/docs/TableGen/BackGuide.html#creating-a-new-backend)
## Data Structures
- [Pure functional datastructures papaer](https://www.cs.cmu.edu/~rwh/theses/okasaki.pdf)
- [Dynamic typing: syntax and proof theory](https://reader.elsevier.com/reader/sd/pii/0167642394000042?token=CEFF5C5D1B03FD680762FC4889A14C0CA2BB28FE390EC51099984536E12AC358F3D28A5C25C274296ACBBC32E5AE23CD)
- [Representing Type Information in Dynamically Typed Languages](https://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.39.4394)
- [An empirical study on the impact of static typing on software maintainability](https://www.researchgate.net/publication/259634489_An_empirical_study_on_the_impact_of_static_typing_on_software_maintainability)
## Other languages
- [Julia: A Fresh Approach toNumerical Computing](https://julialang.org/research/julia-fresh-approach-BEKS.pdf)
## Memory management
- [Visualizing memory management in Golang](https://deepu.tech/memory-management-in-golang/)
- [TCMalloc : Thread-Caching Malloc](http://goog-perftools.sourceforge.net/doc/tcmalloc.html)
- [A visual guide to Go Memory Allocator from scratch (Golang)](https://medium.com/@ankur_anand/a-visual-guide-to-golang-memory-allocator-from-ground-up-e132258453ed)
## Concurrency
- [Scheduling In Go (Series)](https://www.ardanlabs.com/blog/2018/08/scheduling-in-go-part1.html)
## Garbage collection
- [GC on V8](https://v8.dev/blog/high-performance-cpp-gc)
- [Perceus: Garbage Free Reference Counting with Reuse](https://www.microsoft.com/en-us/research/uploads/prod/2020/11/perceus-tr-v1.pdf)
- [Boehm GC](https://www.hboehm.info/gc/)
- [MPS](https://www.ravenbrook.com/project/mps/)
- [MMTK](https://www.mmtk.io/code)
- [Whiro](https://github.com/JWesleySM/Whiro)<br/>
This is not GC but a tool to debug GC and memory allocation.
## JIT
- [Machine code generator for C++](https://asmjit.com/)
- [LLVM's Next Generation of JIT API](https://www.youtube.com/watch?v=hILdR8XRvdQ)
## Optimizations
- [Canonicalization](https://sunfishcode.github.io/blog/2018/10/22/Canonicalization.html)
## Compiler
- [Stack frame layout on x86-64](https://eli.thegreenplace.net/2011/09/06/stack-frame-layout-on-x86-64)
- [Pointers Are Complicated](https://www.ralfj.de/blog/2020/12/14/provenance.html)
- [Pointers Are Complicated III, or: Pointer-integer casts exposed](https://www.ralfj.de/blog/2022/04/11/provenance-exposed.html)
- [A compiler writting journal](https://github.com/DoctorWkt/acwj)
## Linker
- [20 part linker essay](https://lwn.net/Articles/276782/)
- [LLD Usage](https://lld.llvm.org/index.html)
## Toolchain
- [Building LLVM Distribution](https://llvm.org/docs/BuildingADistribution.html)
## Cross compilation
- [Creating portable Linux binaries](https://blog.gibson.sh/2017/11/26/creating-portable-linux-binaries/#some-general-suggestions)<br/>
A nice to read article on some of the common problems when linking statically
with none default libc or libc++
## Lang
- Scheme
* [Chicken Scheme - Easy-to-use compiler and interpreter, with lots of libraries](https://call-cc.org)
* [Stalin - Brutally optimizing Scheme compiler, with lots of optimization flags](https://github.com/barak/stalin)
* [Crafting Interpreters](https://craftinginterpreters.com/contents.html)
## Emacs mode
- [Adding A New Language to Emacs](https://www.wilfred.me.uk/blog/2015/03/19/adding-a-new-language-to-emacs/)
- [The Definitive Guide To Syntax Highlighting](https://www.wilfred.me.uk/blog/2014/09/27/the-definitive-guide-to-syntax-highlighting/)
## Mathematics
- [CS410 course: Advance Functional Programming](https://github.com/pigworker/CS410-18)<br/>
If you need to learn Agda (We use it for the mathematics side of Serene, to proof certain features)
check out
- [Programming Language Foundations in Agda](https://plfa.github.io/)<br/>
This book is an introduction to programming language theory using the proof assistant Agda.
### Curry-Howard correspondence
- [The formulae-as-types notion of construction](https://www.dcc.fc.up.pt/~acm/howard2.pdf)
- [Propositions as Types](https://www.youtube.com/watch?v=IOiZatlZtGU)
### Type Theory
- [Homotopy Type Theory](https://www.cs.cmu.edu/~rwh/courses/hott/)
- [No, dynamic type systems are not inherently more open](https://lexi-lambda.github.io/blog/2020/01/19/no-dynamic-type-systems-are-not-inherently-more-open/)
- Practical Foundations of Programming Languages
+ [Online copy (2nd Edition Preview)](http://www.cs.cmu.edu/~rwh/pfpl/2nded.pdf)
+ [Dead-tree copy (2nd Edition)](https://www.amazon.com/Practical-Foundations-Programming-Languages-Robert/dp/1107150302)
- Types and Programming Languages
+ [Online supplements](http://www.cis.upenn.edu/~bcpierce/tapl/)
+ [Dead-tree copy](https://mitpress.mit.edu/books/types-and-programming-languages)
- Advanced Topics in Types and Programming Languages
+ [Online supplements](http://www.cis.upenn.edu/~bcpierce/attapl/)
+ [Dead-tree copy](http://www.amazon.com/exec/obidos/ASIN/0262162288/benjamcpierce)
- The Works of Per Martin-Löf:
+ [1972](https://github.com/michaelt/martin-lof/blob/master/pdfs/An-Intuitionistic-Theory-of-Types-1972.pdf?raw=true)
+ [1979](https://github.com/michaelt/martin-lof/blob/master/pdfs/Constructive-mathematics-and-computer-programming-1982.pdf?raw=true)
+ [1984](https://github.com/michaelt/martin-lof/blob/master/pdfs/Bibliopolis-Book-retypeset-1984.pdf?raw=true)
+ [The Complete Works of Per Martin-Löf](https://github.com/michaelt/martin-lof)
- [Programming In Martin-Löf's Type Theory](http://www.cse.chalmers.se/research/group/logic/book/book.pdf)
- The Works of John Reynolds
* [Types, Abstraction and Parametric Polymorphism](http://www.cse.chalmers.se/edu/year/2010/course/DAT140_Types/Reynolds_typesabpara.pdf) (Parametricity for
System F)
* [A Logic For Shared Mutable State](http://www.cs.cmu.edu/~jcr/seplogic.pdf)
* [Course notes on separation logic](http://www.cs.cmu.edu/afs/cs.cmu.edu/project/fox-19/member/jcr/www15818As2011/cs818A3-11.html)
* [Course notes on denotational semantics](http://www.cs.cmu.edu/~jcr/cs819-00.html)
- [The HoTT book](http://homotopytypetheory.org/book/)
- [Student's Notes on HoTT](https://github.com/RobertHarper/hott-notes)
- [Materials for the Schools and Workshops on UniMath](https://github.com/UniMath/Schools)
### Proof Theory
- Frank Pfenning's Lecture Notes
* [Introductory Course](http://www.cs.cmu.edu/~fp/courses/15317-f09/)
* [Linear Logic](http://www.cs.cmu.edu/~fp/courses/15816-s12/)
* [Modal Logic](http://www.cs.cmu.edu/~fp/courses/15816-s10/)
- [Proofs and Types](http://www.paultaylor.eu/stable/prot.pdf)
- [The Blind Spot: Lectures on Logic](http://www.ems-ph.org/books/book.php?proj_nr=136&srch=browse_authors%7CGirard%2C+Jean-Yves)
- [Mustard Watches: An Integrated Approach to Time and Food](http://girard.perso.math.cnrs.fr/mustard/page1.html)
### Category Theory
- Category Theory in Context
* [Online version](http://www.math.jhu.edu/~eriehl/context.pdf)
* [Dead-tree version](http://store.doverpublications.com/048680903x.html)
* [The author's post on the book](https://golem.ph.utexas.edu/category/2016/11/category_theory_in_context.html)
- Practical Foundations of Mathematics
* [HTML version](http://www.paultaylor.eu/~pt/prafm/)
* [Dead-tree version](https://www.amazon.com/gp/product/0521631076)
- [Category Theory](http://www.amazon.com/Category-Theory-Oxford-Logic-Guides/dp/0199237182/ref=sr_1_1?ie=UTF8&qid=1439348930&sr=8-1&keywords=awodey+category+theory)
- [Ed Morehouse's Category Theory Lecture Notes](https://emorehouse.wescreates.wesleyan.edu/research/notes/intro_categorical_semantics.pdf)
- Categorical Logic and Type Theory
* [Jacob's thesis, containing much of what went into the book](http://www.cs.ru.nl/B.Jacobs/PAPERS/PhD.ps)
* [A definitely not suspicious online copy](https://people.mpi-sws.org/~dreyer/courses/catlogic/jacobs.pdf)
* [Dead-tree copy](https://www.amazon.com/exec/obidos/ASIN/0444501703/qid%3D922441598/002-9790597-0750031)
- [Introduction to Higher-Order Categorical Logic](https://www.amazon.com/Introduction-Higher-Order-Categorical-Cambridge-Mathematics/dp/0521356539/ref=pd_sim_14_5?_encoding=UTF8&psc=1&refRID=V4H286NSZWK4MWDPV17R)
- [Sheaves in Geometry and Logic](https://www.amazon.com/Sheaves-Geometry-Logic-Introduction-Universitext/dp/0387977104)
### Others
- [Gunter's "Semantics of Programming Language"](http://www.amazon.com/Semantics-Programming-Languages-Structures-Foundations/dp/0262071436/ref=sr_1_1?ie=UTF8&qid=1439349219&sr=8-1&keywords=gunter+semantics+of+programming+languages)
- [Abramsky and Jung's "Domain Theory"](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.50.8851)
- [Realizability: An Introduction to Its Categorical Side](https://www.amazon.com/Realizability-Introduction-its-Categorical-Side/dp/0444550208)
- OPLSS:<br/>
The Oregon Programming Languages Summer School is a 2 week long
bootcamp on PLs held annually at the university of Oregon. It's a
wonderful event to attend but if you can't make it they record all
their lectures anyways! They're taught be a variety of lecturers
but they're all world class researchers.
* [2012](https://www.cs.uoregon.edu/research/summerschool/summer12/curriculum.html)
* [2013](https://www.cs.uoregon.edu/research/summerschool/summer13/curriculum.html)
* [2014](https://www.cs.uoregon.edu/research/summerschool/summer14/curriculum.html)
* [2015](https://www.cs.uoregon.edu/research/summerschool/summer15/curriculum.html)
* [2016](https://www.cs.uoregon.edu/research/summerschool/summer16/curriculum.php)
* [2017](https://www.cs.uoregon.edu/research/summerschool/summer17/topics.php)
* [2018](https://www.cs.uoregon.edu/research/summerschool/summer18/topics.php)

View File

@ -0,0 +1,18 @@
[data-md-color-scheme=slate] #what-i-cannot-create-i-do-not-understand {
color: white;
font-weight: 700;
margin-bottom: -20px;
}
[data-md-color-scheme=default] #what-i-cannot-create-i-do-not-understand {
color: #2f2f2f;
font-weight: 700;
margin-bottom: -20px;
}
.md-typeset .md-annotation__index > ::before {
content: attr(data-md-annotation-id);
}
.md-typeset :focus-within > .md-annotation__index > ::before {
transform: none;
}

4
docs/requirements.txt Normal file
View File

@ -0,0 +1,4 @@
mkdocs-material
mike
mkdocs-git-revision-date-localized-plugin
mkdocs-glightbox

48
docs/service.yml Normal file
View File

@ -0,0 +1,48 @@
version: "3.9"
services:
serene-docs:
image: serenelang/serene-docs
environment:
USER_UID: 1100
USER_GID: 1100
security_opt:
- no-new-privileges:true
networks:
- public_lb
volumes:
- /var/run/docker.sock:/var/run/docker.sock
deploy:
labels:
- "traefik.enable=true"
- "traefik.http.routers.serene-lang.rule=Host(`serene-lang.org`)"
- "traefik.http.routers.serene-lang.entrypoints=websecure"
- "traefik.http.routers.serene-lang.tls=true"
- "traefik.http.routers.serene-lang.tls.certresolver=default"
- "traefik.http.services.serene-lang-web.loadbalancer.server.port=3000"
- "traefik.http.services.serene-lang-web.loadbalancer.server.scheme=http"
- "traefik.http.routers.serene-lang.service=serene-lang-web"
- "traefik.docker.network=public_lb"
- "traefik.http.middlewares.serene-lang-ratelimit.ratelimit.average=50"
- "traefik.http.middlewares.serene-lang-ratelimit.ratelimit.burst=10"
- "traefik.http.routers.serene-lang.middlewares=serene-lang-ratelimit"
mode: replicated
replicas: 1
restart_policy:
condition: on-failure
max_attempts: 3
update_config:
parallelism: 1
delay: 5s
order: stop-first
logging:
options:
max-size: "10m"
max-file: "3"
networks:
public_lb:
external: true
name: public_lb

80
docs/spec.org Normal file
View File

@ -0,0 +1,80 @@
#+TITLE: Serene's Language Specification
#+AUTHOR: Sameer Rahmani
#+SEQ_TODO: TODO(t/!) | DONE(d%)
#+TAGS:
#+STARTUP: logdrawer logdone logreschedule indent content align constSI entitiespretty nolatexpreview
#+OPTIONS: tex:t
#+HTML_MATHJAX: align: left indent: 5em tagside: left font: Neo-Eule
# book style has to be remapped to koma scripts scrbook
#+LATEX_CLASS: book
#+LATEX_HEADER: \usepackage[english]{babel}
#+LATEX_CLASS_OPTIONS: [fontsize=11pt,paper=a5, pagesize=auto]
#+LATEX_HEADER: \KOMAoptions{fontsize=11pt}
#+LATEX_HEADER: \usepackage[utf8]{inputenc}
#+LATEX_HEADER: \usepackage{microtype}
#+LATEX_HEADER: \usepackage{pxfonts}
#+LATEX_HEADER: \usepackage{amsmath}
#+LATEX_HEADER: \usepackage{amssymb}
#+LATEX_HEADER: \usepackage{mathabx}
#+LATEX_HEADER: \usepackage{tcolorbox}
#+LATEX_HEADER: \setlength{\parskip}{1em}
#+LATEX_HEADER: \newtcolorbox{infobox}[2][]{colback=cyan!5!white,before skip=14pt,after skip=8pt,colframe=cyan!75!black,sharp corners,title={#2},#1}
#+LATEX_HEADER: \newcommand\tab[1][1cm]{\hspace*{#1}}
#+LATEX_HEADER: \let\oldsection\section
#+LATEX_HEADER: \newcommand\caution[1]{\textcolor{blue}{\textbf{#1}}}
#+LATEX_HEADER: \renewcommand\section{\pagebreak\oldsection}
#+LATEX_HEADER: \hypersetup{hidelinks}
#+LATEX_HEADER: \renewcommand{\contentsname}{Serene's Spec}
\clearpage\null\newpage
\chapter{Overview of Serene}
* Basic Types
* Special Forms
** ~def~:
~def~ has the following form:
#+BEGIN_SRC lisp
(def <NAME> <VALUE>)
#+END_SRC
- Defines a global binding
- Returns the name of the binding as a symbol
- ~<NAME>~ has to be a symbol
- If ~def~ is not a top level expression, it will create an ~undef~ global binding which
will be set to the ~<VALUE>~ when the execution flow reaches the ~def~ itself.
* Libraries
In terms of static and dynamic libraries, If the library is a Serene library
meaning that it is designed to only work with serene (we will see how in a bit), then
whatever namespaces that it contains will be added to the compiler and all those
namespaces will be map to the library (all the namespaces will point to the same JITDylib).
But if the library is a generic static or dynamic library a namespace with the same
name as the library minus the suffix will be added to the compiler, for example ~libssh.so~
will be mapped to ~libssh~ namespace.
** Static
** Dynamic
** Object
* Unsorted
** Eval
Evaluating any form using =eval= will add the form to the namespace containing the
=eval= expression.
* Glossary
- Symbol :: A Lisp Symbol. Just a symbol. A name that might be bound to a value
and evaluates to the value.
- IR Symbol :: The ~Symbol~ infrastructure essentially provides a non-SSA mechanism in which to refer to an
operation in IR symbolically with a name. On MLIR level they are different from *native symbols*
even though we use them to refer to *native symbols*. But they don't necessarily map to
*native symbols*.
- Native Sybol :: As the name suggests native symbols refer to native code symbols. Like those you find in an
object file.

File diff suppressed because it is too large Load Diff

149
flake.lock Normal file
View File

@ -0,0 +1,149 @@
{
"nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": "nixpkgs-lib"
},
"locked": {
"lastModified": 1715865404,
"narHash": "sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "8dc45382d5206bd292f9c2768b8058a8fd8311d9",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1715870890,
"narHash": "sha256-nacSOeXtUEM77Gn0G4bTdEOeFIrkCBXiyyFZtdGwuH0=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "fa606cccd7b0ccebe2880051208e4a0f61bfc8c1",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1710765496,
"narHash": "sha256-p7ryWEeQfMwTB6E0wIUd5V2cFTgq+DRRBz2hYGnJZyA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e367f7a1fb93137af22a3908f00b9a35e2d286a7",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs-lib": {
"locked": {
"lastModified": 1714640452,
"narHash": "sha256-QBx10+k6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94=",
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/50eb7ecf4cd0a5756d7275c8ba36790e5bd53e33.tar.gz"
}
},
"nixpkgs-stable": {
"locked": {
"lastModified": 1710695816,
"narHash": "sha256-3Eh7fhEID17pv9ZxrPwCLfqXnYP006RKzSs0JptsN84=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "614b4613980a522ba49f0d194531beddbb7220d3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1712525377,
"narHash": "sha256-TbfZDd8NN6gx7eU5XQWgF/ojnnkTvn7cPXWdY4PVTMU=",
"owner": "lxsameer",
"repo": "nixpkgs",
"rev": "c738ee8ad1c35383037c20fa13eaac17c8ae98c5",
"type": "github"
},
"original": {
"owner": "lxsameer",
"repo": "nixpkgs",
"rev": "c738ee8ad1c35383037c20fa13eaac17c8ae98c5",
"type": "github"
}
},
"root": {
"inputs": {
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}

132
flake.nix Normal file
View File

@ -0,0 +1,132 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{
description = "Serene programming language";
inputs.nixpkgs.url =
"github:lxsameer/nixpkgs/c738ee8ad1c35383037c20fa13eaac17c8ae98c5";
#inputs.nixpkgs.url = "/home/lxsameer/src/nixpkgs/";
inputs.git-hooks.url = "github:cachix/git-hooks.nix";
inputs.flake-parts.url = "github:hercules-ci/flake-parts";
outputs = { self, nixpkgs, git-hooks, flake-parts, ... }@inputs:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "aarch64-darwin" "riscv64-linux" "x86_64-linux" ];
flake = { };
perSystem = { config, self', inputs', system, pkgs, lib, ... }:
let
version = "1.0.0";
overlays = (lib.attrsets.attrValues (import ./nix/overlays.nix { }));
utils = import ./nix/utils.nix { inherit nixpkgs; };
hostPkgs = pkgs;
targetPkgs = utils.getPkgs system overlays;
# Create a stdenv based on LLVM
stdenv = targetPkgs.stdenvAdapters.overrideCC targetPkgs.stdenv
targetPkgs.llvmPackages_18.clangUseLLVM;
gc = targetPkgs.callPackage ./nix/boehmgc.nix { inherit stdenv; };
zlib' = targetPkgs.zlib-ng.overrideAttrs (old: {
cmakeFlags = [
"-DCMAKE_INSTALL_PREFIX=/"
"-DBUILD_SHARED_LIBS=OFF"
"-DINSTALL_UTILS=ON"
"-DZLIB_COMPAT=ON"
];
});
# By default llvm adds zlib to `propagatedBuildInputs` which means any
# package that uses llvm will indirectly depends on zlib. And since
# by default that zlib is built as a shared lib (since our packageset
# is not static), We can't statically link to it. So, we just replace
# that zlib with our override of zlib-ng
clang' = stdenv.cc.overrideAttrs (old: {
propagatedBuildInputs = [ stdenv.cc.bintools ]
++ [ targetPkgs.zlib.static ];
});
llvm = targetPkgs.llvmPackages_18.llvm.overrideAttrs
(old: { propagatedBuildInputs = [ targetPkgs.zlib.static ]; });
# This is the actual stdenv that we need to use anywhere else
stdenv' =
targetPkgs.stdenvAdapters.overrideCC targetPkgs.stdenv clang';
nativeBuildToolsDeps = (with hostPkgs; [ cmake ninja ccache ]);
buildToolsDeps = (with targetPkgs; [
llvm
llvmPackages_18.mlir
llvmPackages_18.clang
iwyu
]);
buildDeps = (with targetPkgs; [
gc
zlib'
llvm
llvmPackages_18.mlir
llvmPackages_18.clang
]);
testDeps = (with hostPkgs; [ gtest gmock gbenchmark ]);
in {
devShells.default =
(targetPkgs.mkShell.override { stdenv = stdenv'; }) {
inherit (self.checks.${system}.git-hook-check) shellHook;
nativeBuildInputs = nativeBuildToolsDeps ++ buildToolsDeps;
buildInputs = buildDeps ++ testDeps
++ self.checks.${system}.git-hook-check.enabledPackages;
};
packages.blah = buildDeps ++ testDeps ++ nativeBuildToolsDeps
++ buildToolsDeps;
packages.devshell = stdenv'.mkDerivation {
inherit version;
name = "devshell";
src = ./.;
doBuild = false;
doUnpack = false;
doCheck = false;
nativeBuildInputs = nativeBuildToolsDeps ++ buildToolsDeps;
buildInputs = buildDeps ++ testDeps;
};
checks = {
git-hook-check = git-hooks.lib.${system}.run {
src = ./.;
hooks = {
nixfmt.enable = true;
clang-format = {
enable = true;
types_or = hostPkgs.lib.mkForce [ "c" "c++" ];
};
shellcheck.enable = true;
cmake-format.enable = true;
};
};
};
};
};
}

View File

@ -1 +0,0 @@
add_subdirectory("serene/slir/")

View File

@ -1,11 +0,0 @@
#ifndef CONFIG_H
#define CONFIG_H
// the configured options and settings for Tutorial
#define SERENE_VERSION_MAJOR @Serene_VERSION_MAJOR@
#define SERENE_VERSION_MINOR @Serene_VERSION_MINOR@
#cmakedefine ENABLE_READER_LOG
#cmakedefine ENABLE_EXPR_LOG
#cmakedefine ENABLE_LOG
#endif

View File

@ -1,109 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_CONTEXT_H
#define SERENE_CONTEXT_H
#include "serene/environment.h"
#include "serene/namespace.h"
#include "serene/passes.h"
#include "serene/slir/dialect.h"
#include <llvm/ADT/StringRef.h>
#include <memory>
#include <mlir/Dialect/StandardOps/IR/Ops.h>
#include <mlir/IR/MLIRContext.h>
#include <mlir/Pass/PassManager.h>
namespace serene {
namespace exprs {
class Expression;
using Node = std::shared_ptr<Expression>;
} // namespace exprs
enum class CompilationPhase {
SLIR,
MLIR, // Lowered slir to other dialects
LIR, // Lowered to the llvm ir dialect
IR, // Lowered to the LLVMIR itself
NoOptimization,
O1,
O2,
O3,
};
class SereneContext {
public:
// --------------------------------------------------------------------------
// IMPORTANT:
// These two contextes have to be the very first members of the class in
// order to destroy last. DO NOT change the order or add anything before
// them
// --------------------------------------------------------------------------
llvm::LLVMContext llvmContext;
mlir::MLIRContext mlirContext;
mlir::PassManager pm;
/// Insert the given `ns` into the context. The Context object is
/// the owner of all the namespaces. The `ns` will overwrite any
/// namespace with the same name.
void insertNS(std::shared_ptr<Namespace> ns);
/// Sets the n ame of the current namespace in the context and return
/// a boolean indicating the status of this operation. The operation
/// will fail if the namespace does not exist in the namespace table.
bool setCurrentNS(llvm::StringRef ns_name);
std::shared_ptr<Namespace> getCurrentNS();
std::shared_ptr<Namespace> getNS(llvm::StringRef ns_name);
SereneContext()
: pm(&mlirContext), targetPhase(CompilationPhase::NoOptimization) {
mlirContext.getOrLoadDialect<serene::slir::SereneDialect>();
mlirContext.getOrLoadDialect<mlir::StandardOpsDialect>();
pm.enableCrashReproducerGeneration("/home/lxsameer/mlir.mlir");
};
void setOperationPhase(CompilationPhase phase);
CompilationPhase getTargetPhase() { return targetPhase; };
int getOptimizatioLevel();
private:
CompilationPhase targetPhase;
std::map<std::string, std::shared_ptr<Namespace>> namespaces;
// Why string vs pointer? We might rewrite the namespace and
// holding a pointer means that it might point to the old version
std::string current_ns;
};
/// Creates a new context object. Contexts are used through out the compilation
/// process to store the state
std::unique_ptr<SereneContext> makeSereneContext();
}; // namespace serene
#endif

View File

@ -1,64 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_ENVIRONMENT_H
#define SERENE_ENVIRONMENT_H
#include "mlir/Support/LogicalResult.h"
#include "serene/llvm/patches.h"
#include "llvm/ADT/DenseMap.h"
namespace serene {
template <typename K, typename V>
class Environment {
Environment<K, V> *parent;
llvm::DenseMap<K, V> pairs;
public:
Environment() : parent(nullptr) {}
Environment(Environment *parent) : parent(parent){};
llvm::Optional<V> lookup(K key) {
if (auto value = pairs.lookup(key)) {
return value;
}
if (parent) {
return parent->lookup(key);
}
return llvm::None;
};
mlir::LogicalResult insert_symbol(K key, V value) {
pairs.insert(std::pair<K, V>(key, value));
return mlir::success();
};
};
} // namespace serene
#endif

View File

@ -1,31 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_ERRORS_H
#define SERENE_ERRORS_H
#include "serene/errors/errc.h"
#include "serene/errors/error.h"
#endif

View File

@ -1,82 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_ERRORS_CONSTANTS_H
#define SERENE_ERRORS_CONSTANTS_H
#include <map>
#include <string>
namespace serene {
namespace errors {
enum ErrID {
E0000,
E0001,
E0002,
E0003,
E0004,
E0005,
E0006,
};
struct ErrorVariant {
ErrID id;
std::string description;
std::string longDescription;
ErrorVariant(ErrID id, std::string desc, std::string longDesc)
: id(id), description(desc), longDescription(longDesc){};
};
static ErrorVariant
UnknownError(E0000, "Can't find any description for this error.", "");
static ErrorVariant
DefExpectSymbol(E0001, "The first argument to 'def' has to be a Symbol.",
"");
static ErrorVariant DefWrongNumberOfArgs(
E0002, "Wrong number of arguments is passed to the 'def' form.", "");
static ErrorVariant FnNoArgsList(E0003, "'fn' form requires an argument list.",
"");
static ErrorVariant FnArgsMustBeList(E0004, "'fn' arguments should be a list.",
"");
static ErrorVariant CantResolveSymbol(E0005, "Can't resolve the given name.",
"");
static ErrorVariant
DontKnowHowToCallNode(E0006, "Don't know how to call the given expression.",
"");
static std::map<ErrID, ErrorVariant *> ErrDesc = {
{E0000, &UnknownError}, {E0001, &DefExpectSymbol},
{E0002, &DefWrongNumberOfArgs}, {E0003, &FnNoArgsList},
{E0004, &FnArgsMustBeList}, {E0005, &CantResolveSymbol},
{E0006, &DontKnowHowToCallNode}};
} // namespace errors
} // namespace serene
#endif

View File

@ -1,83 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_ERRORS_ERRC_H
#define SERENE_ERRORS_ERRC_H
#include "llvm/Support/Errc.h"
namespace serene {
/// A collection of common error codes in Serene
enum class errc {
argument_list_too_long = int(std::errc::argument_list_too_long),
argument_out_of_domain = int(std::errc::argument_out_of_domain),
bad_address = int(std::errc::bad_address),
bad_file_descriptor = int(std::errc::bad_file_descriptor),
broken_pipe = int(std::errc::broken_pipe),
device_or_resource_busy = int(std::errc::device_or_resource_busy),
directory_not_empty = int(std::errc::directory_not_empty),
executable_format_error = int(std::errc::executable_format_error),
file_exists = int(std::errc::file_exists),
file_too_large = int(std::errc::file_too_large),
filename_too_long = int(std::errc::filename_too_long),
function_not_supported = int(std::errc::function_not_supported),
illegal_byte_sequence = int(std::errc::illegal_byte_sequence),
inappropriate_io_control_operation =
int(std::errc::inappropriate_io_control_operation),
interrupted = int(std::errc::interrupted),
invalid_argument = int(std::errc::invalid_argument),
invalid_seek = int(std::errc::invalid_seek),
io_error = int(std::errc::io_error),
is_a_directory = int(std::errc::is_a_directory),
no_child_process = int(std::errc::no_child_process),
no_lock_available = int(std::errc::no_lock_available),
no_space_on_device = int(std::errc::no_space_on_device),
no_such_device_or_address = int(std::errc::no_such_device_or_address),
no_such_device = int(std::errc::no_such_device),
no_such_file_or_directory = int(std::errc::no_such_file_or_directory),
no_such_process = int(std::errc::no_such_process),
not_a_directory = int(std::errc::not_a_directory),
not_enough_memory = int(std::errc::not_enough_memory),
not_supported = int(std::errc::not_supported),
operation_not_permitted = int(std::errc::operation_not_permitted),
permission_denied = int(std::errc::permission_denied),
read_only_file_system = int(std::errc::read_only_file_system),
resource_deadlock_would_occur = int(std::errc::resource_deadlock_would_occur),
resource_unavailable_try_again =
int(std::errc::resource_unavailable_try_again),
result_out_of_range = int(std::errc::result_out_of_range),
too_many_files_open_in_system = int(std::errc::too_many_files_open_in_system),
too_many_files_open = int(std::errc::too_many_files_open),
too_many_links = int(std::errc::too_many_links)
};
/// The **official way** to create `std::error_code` in context of Serene.
inline std::error_code make_error_code(errc E) {
return std::error_code(static_cast<int>(E), std::generic_category());
};
}; // namespace serene
#endif

View File

@ -1,68 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_ERRORS_ERROR_H
#define SERENE_ERRORS_ERROR_H
#include "serene/context.h"
#include "serene/errors/constants.h"
#include "serene/errors/traits.h"
#include "serene/reader/location.h"
#include "serene/reader/traits.h"
#include "serene/traits.h"
//#include "serene/exprs/expression.h"
#include "llvm/Support/Error.h"
namespace serene::errors {
/// This enum represent the expression type and **not** the value type.
enum class ErrType {
Syntax,
Semantic,
Compile,
};
/// This data structure represent the Lisp error. This type of expression
/// doesn't show up in the AST but the compiler might rewrite the AST
/// to contains error expressions
class Error
: public WithTrait<Error, IError, reader::ILocatable, serene::IDebuggable> {
reader::LocationRange location;
ErrorVariant *variant;
std::string message;
public:
Error(reader::LocationRange &loc, ErrorVariant *err, llvm::StringRef msg)
: location(loc), variant(err), message(msg){};
std::string toString() const;
reader::LocationRange &where();
ErrorVariant *getVariant();
std::string getMessage();
~Error() = default;
};
}; // namespace serene::errors
#endif

View File

@ -1,44 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef ERRORS_TRAITS_H
#define ERRORS_TRAITS_H
#include "serene/context.h"
#include "serene/errors/constants.h"
#include "serene/traits.h"
namespace serene::errors {
template <typename ConcreteType>
class IError : public TraitBase<ConcreteType, IError> {
public:
IError(){};
IError(const IError &) = delete;
ErrorVariant *getVariant();
std::string getMessage();
};
} // namespace serene::errors
#endif

View File

@ -1,79 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EXPRS_CALL_H
#define EXPRS_CALL_H
#include "serene/context.h"
#include "serene/errors/error.h"
#include "serene/exprs/expression.h"
#include "serene/exprs/list.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include <memory>
#include <string>
namespace serene {
namespace exprs {
class List;
/// This data structure represents a function. with a collection of
/// arguments and the ast of a body
class Call : public Expression {
public:
Node target;
Ast params;
Call(reader::LocationRange &loc, Node &target, Ast &params)
: Expression(loc), target(target), params(params){};
Call(Call &) = delete;
ExprType getType() const;
std::string toString() const;
MaybeNode analyze(SereneContext &);
void generateIR(serene::Namespace &){};
static bool classof(const Expression *e);
/// Creates a call node out of a list.
/// For exmaple: `(somefn (param1 param2) param3)`. This function
/// is supposed to be used in the semantic analysis phase.
///
/// \param ctx The semantic analysis context object.
/// \param list the list in question.
static MaybeNode make(SereneContext &ctx, List *list);
~Call() = default;
};
} // namespace exprs
} // namespace serene
#endif

View File

@ -1,76 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EXPRS_DEF_H
#define EXPRS_DEF_H
#include "serene/context.h"
#include "serene/errors/error.h"
#include "serene/exprs/expression.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include <memory>
#include <string>
namespace serene {
namespace exprs {
class List;
/// This data structure represent the Lisp symbol. Just a symbol
/// in the context of the AST and nothing else.
class Def : public Expression {
public:
std::string binding;
Node value;
Def(reader::LocationRange &loc, llvm::StringRef binding, Node &v)
: Expression(loc), binding(binding), value(v){};
Def(Def &d) = delete;
ExprType getType() const;
std::string toString() const;
MaybeNode analyze(SereneContext &);
void generateIR(serene::Namespace &);
static bool classof(const Expression *e);
/// Create a Def node out a list. The list should contain the
/// correct `def` form like `(def blah value)`. This function
/// is supposed to be used in the semantic analysis phase.
///
/// \param ctx The semantic analysis context object.
/// \param list the list containing the `def` form
static MaybeNode make(SereneContext &ctx, List *list);
~Def() = default;
};
} // namespace exprs
} // namespace serene
#endif

View File

@ -1,147 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EXPRS_EXPRESSION_H
#define EXPRS_EXPRESSION_H
#include "serene/context.h"
#include "serene/errors/error.h"
#include "serene/exprs/traits.h"
#include "serene/reader/location.h"
#include "serene/utils.h"
#include <memory>
namespace serene {
/// Contains all the builtin AST expressions including those which do not appear
/// in the syntax directly. Like function definitions.
namespace exprs {
class Expression;
using Node = std::shared_ptr<Expression>;
using ErrorPtr = std::shared_ptr<errors::Error>;
// tree? Yupe, Errors can be stackable which makes
using ErrorTree = std::vector<ErrorPtr>;
using MaybeNode = Result<Node, ErrorTree>;
using Ast = std::vector<Node>;
using MaybeAst = Result<Ast, ErrorTree>;
static auto EmptyNode = MaybeNode::success(nullptr);
/// The base class of the expressions which provides the common interface for
/// the expressions to implement.
class Expression {
public:
/// The location range provide information regarding to where in the input
/// string the current expression is used.
reader::LocationRange location;
Expression(const reader::LocationRange &loc) : location(loc){};
virtual ~Expression() = default;
/// Returns the type of the expression. We need this funciton to perform
/// dynamic casting of expression object to implementations such as lisp or
/// symbol.
virtual ExprType getType() const = 0;
/// The AST representation of an expression
virtual std::string toString() const = 0;
/// Analyzes the semantics of current node and return a new node in case
/// that we need to semantically rewrite the current node and replace it with
/// another node. For example to change from a List containing `(def a b)`
/// to a `Def` node that represents defining a new binding.
///
/// \param ctx is the context object of the semantic analyzer.
virtual MaybeNode analyze(SereneContext &ctx) = 0;
virtual void generateIR(serene::Namespace &ns) = 0;
};
/// Create a new `node` of type `T` and forwards any given parameter
/// to the constructor of type `T`. This is the **official way** to create
/// a new `Expression`. Here is an example:
/// \code
/// auto list = make<List>();
/// \endcode
///
/// \param[args] Any argument with any type passed to this function will be
/// passed to the constructor of type T.
/// \return A unique pointer to an Expression
template <typename T, typename... Args>
Node make(Args &&...args) {
return std::make_shared<T>(std::forward<Args>(args)...);
};
/// Create a new `node` of type `T` and forwards any given parameter
/// to the constructor of type `T`. This is the **official way** to create
/// a new `Expression`. Here is an example:
/// \code
/// auto list = makeAndCast<List>();
/// \endcode
///
/// \param[args] Any argument with any type passed to this function will be
/// passed to the constructor of type T.
/// \return A unique pointer to a value of type T.
template <typename T, typename... Args>
std::shared_ptr<T> makeAndCast(Args &&...args) {
return std::make_shared<T>(std::forward<Args>(args)...);
};
/// The helper function to create a new `Node` and use that as the success case
// of a `Result`. It should be useds where every we want to return a `MaybeNode`
/// successfully
template <typename T, typename... Args>
Result<Node, ErrorTree> makeSuccessfulNode(Args &&...args) {
return Result<Node, ErrorTree>::success(make<T>(std::forward<Args>(args)...));
};
/// The hlper function to create an Errorful `Result<T,...>` (`T` would be
/// either
/// `Node` or `Ast` most of the time) with just one error creating from passing
/// any argument to this function to the `serene::errors::Error` constructor.
template <typename T, typename... Args>
Result<T, ErrorTree> makeErrorful(Args &&...args) {
std::vector<ErrorPtr> v{
std::move(makeAndCast<errors::Error>(std::forward<Args>(args)...))};
return Result<T, ErrorTree>::error(v);
};
/// Convert the given AST to string by calling the `toString` method
/// of each node.
std::string astToString(const Ast *);
/// Converts the given ExprType to string.
std::string stringifyExprType(ExprType);
/// Converts the given AST to string and prints it out
void dump(Ast &);
} // namespace exprs
} // namespace serene
#endif

View File

@ -1,83 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EXPRS_FN_H
#define EXPRS_FN_H
#include "serene/context.h"
#include "serene/errors/error.h"
#include "serene/exprs/expression.h"
#include "serene/exprs/list.h"
#include "serene/namespace.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include <memory>
#include <string>
namespace serene {
namespace exprs {
class List;
/// This data structure represents a function. with a collection of
/// arguments and the ast of a body
class Fn : public Expression {
public:
std::string name;
// TODO: Use a coll type instead of a list here
List args;
Ast body;
Fn(SereneContext &ctx, reader::LocationRange &loc, List &args, Ast body);
Fn(Fn &f) = delete;
ExprType getType() const;
std::string toString() const;
MaybeNode analyze(SereneContext &);
void generateIR(serene::Namespace &);
static bool classof(const Expression *e);
/// Creates a function node out of a function definition
/// in a list. the list has to contain the correct definition
/// of a function, for exmaple: `(fn (args1 arg2) body)`.This function
/// is supposed to be used in the semantic analysis phase.
///
/// \param ctx The semantic analysis context object.
/// \param list the list containing the `fn` form
static MaybeNode make(SereneContext &ctx, List *list);
void setName(std::string);
~Fn() = default;
};
} // namespace exprs
} // namespace serene
#endif

View File

@ -1,82 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EXPRS_LIST_H
#define EXPRS_LIST_H
#include "serene/context.h"
#include "serene/exprs/expression.h"
#include "llvm/ADT/Optional.h"
#include <string>
namespace serene {
namespace exprs {
/// This class represents a List in the AST level and not the List as the data
/// type.
class List : public Expression {
public:
// Internal elements of the lest (small vector of shared pointers to
// expressions)
Ast elements;
List(const List &l); // Copy ctor
List(List &&e) noexcept = default; // Move ctor
List(const reader::LocationRange &loc) : Expression(loc){};
List(const reader::LocationRange &loc, Node &e);
List(const reader::LocationRange &loc, Ast elems);
ExprType getType() const;
std::string toString() const;
void append(Node);
size_t count() const;
Ast from(uint begin);
// llvm::MutableArrayRef<Expression> from(uint begin);
llvm::Optional<Expression *> at(uint index);
std::vector<Node>::const_iterator cbegin();
std::vector<Node>::const_iterator cend();
std::vector<Node>::iterator begin();
std::vector<Node>::iterator end();
MaybeNode analyze(SereneContext &);
void generateIR(serene::Namespace &){};
static bool classof(const Expression *e);
~List() = default;
};
} // namespace exprs
} // namespace serene
#endif

View File

@ -1,69 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EXPRS_NUMBER_H
#define EXPRS_NUMBER_H
#include "serene/context.h"
#include "serene/exprs/expression.h"
#include "serene/namespace.h"
#include "llvm/Support/FormatVariadic.h"
namespace serene {
namespace exprs {
/// This data structure represent a number. I handles float points, integers,
/// positive and negative numbers. This is not a data type representative.
/// So it won't cast to actual numeric types and it has a string container
/// to hold the parsed value.
struct Number : public Expression {
// TODO: Use a variant here instead
std::string value;
bool isNeg;
bool isFloat;
Number(reader::LocationRange &loc, const std::string &num, bool isNeg,
bool isFloat)
: Expression(loc), value(num), isNeg(isNeg), isFloat(isFloat){};
ExprType getType() const;
std::string toString() const;
MaybeNode analyze(SereneContext &ctx);
static bool classof(const Expression *e);
// TODO: This is horrible, we need to fix it after the mvp
int toI64();
void generateIR(serene::Namespace &);
~Number() = default;
};
} // namespace exprs
} // namespace serene
#endif

View File

@ -1,65 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EXPRS_SYMBOL_H
#define EXPRS_SYMBOL_H
#include "serene/context.h"
#include "serene/exprs/expression.h"
#include "llvm/ADT/StringRef.h"
#include <string>
namespace serene {
namespace exprs {
/// This data structure represent the Lisp symbol. Just a symbol
/// in the context of the AST and nothing else.
class Symbol : public Expression {
public:
std::string name;
Symbol(reader::LocationRange &loc, llvm::StringRef name)
: Expression(loc), name(name){};
Symbol(Symbol &s) : Expression(s.location) { this->name = s.name; }
ExprType getType() const;
std::string toString() const;
static bool classof(const Expression *e);
MaybeNode analyze(SereneContext &);
void generateIR(serene::Namespace &){};
~Symbol() = default;
};
} // namespace exprs
} // namespace serene
#endif

View File

@ -1,53 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef EXPRS_TRAITS_H
#define EXPRS_TRAITS_H
#include "serene/context.h"
#include "serene/reader/location.h"
#include "serene/reader/traits.h"
#include "serene/traits.h"
#include "serene/utils.h"
namespace serene::exprs {
/// This enum represent the expression type and **not** the value type.
enum class ExprType {
Symbol,
List,
Number,
Def,
Error,
Fn,
Call,
};
/// The string represantion of built in expr types (NOT DATATYPES).
static const char *exprTypes[] = {
"Symbol", "List", "Number", "Def", "Error", "Fn", "Call",
};
}; // namespace serene::exprs
#endif

View File

@ -1,7 +0,0 @@
#ifndef SERENE_LLVM_VALUE_H
#define SERENE_LLVM_VALUE_H
#pragma clang diagnostic ignored "-Wunused-parameter"
#include <llvm/IR/Value.h>
#endif

View File

@ -1,60 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_LLVM_PATCHES_H
#define SERENE_LLVM_PATCHES_H
#include "llvm/ADT/DenseMap.h"
namespace llvm {
// Our specialization of DensMapInfo for string type. This will allow use to use
// string
template <>
struct DenseMapInfo<std::string> {
static inline std::string getEmptyKey() { return ""; }
static inline std::string getTombstoneKey() {
// Maybe we need to use something else beside strings ????
return "0TOMBED";
}
static unsigned getHashValue(std::string Val) {
assert(Val != getEmptyKey() && "Cannot hash the empty key!");
assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
return (unsigned)(llvm::hash_value(Val));
}
static bool isEqual(std::string LHS, std::string RHS) {
if (RHS == getEmptyKey())
return LHS == getEmptyKey();
if (RHS == getTombstoneKey())
return LHS == getTombstoneKey();
return LHS == RHS;
}
};
} // namespace llvm
#endif

View File

@ -1,107 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_NAMESPACE_H
#define SERENE_NAMESPACE_H
#include "serene/environment.h"
#include "serene/slir/generatable.h"
#include "serene/traits.h"
#include "serene/utils.h"
#include <algorithm>
#include <atomic>
#include <llvm/ADT/SmallString.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/IR/Module.h>
#include <memory>
#include <mlir/IR/Builders.h>
#include <mlir/IR/BuiltinOps.h>
#include <mlir/IR/Value.h>
#include <mlir/Support/LogicalResult.h>
#include <string>
#define NAMESPACE_LOG(...) \
DEBUG_WITH_TYPE("NAMESPACE", llvm::dbgs() << __VA_ARGS__ << "\n");
namespace serene {
class SereneContext;
namespace exprs {
class Expression;
using Node = std::shared_ptr<Expression>;
using Ast = std::vector<Node>;
} // namespace exprs
/// Serene's namespaces are the unit of compilation. Any code that needs to be
/// compiled has to be in a namespace. The official way to create a new
/// namespace is to use the `makeNamespace` function.
class Namespace : public WithTrait<Namespace, slir::Generatable> {
private:
SereneContext &ctx;
bool initialized = false;
std::atomic<uint> fn_counter = 0;
exprs::Ast tree;
std::unique_ptr<llvm::Module> llvmModule;
mlir::ModuleOp module;
public:
mlir::StringRef name;
llvm::Optional<std::string> filename;
/// The root environment of the namespace on the semantic analysis phase.
/// Which is a mapping from names to AST nodes ( no evaluation ).
Environment<std::string, exprs::Node> semanticEnv;
Environment<llvm::StringRef, mlir::Value> symbolTable;
Namespace(SereneContext &ctx, llvm::StringRef ns_name,
llvm::Optional<llvm::StringRef> filename);
exprs::Ast &getTree();
mlir::LogicalResult setTree(exprs::Ast &);
uint nextFnCounter();
mlir::ModuleOp &getModule();
SereneContext &getContext();
void setLLVMModule(std::unique_ptr<llvm::Module>);
llvm::Module &getLLVMModule();
// Generatable Trait
/// Generate the IR of the namespace with respect to the compilation phase
mlir::LogicalResult generate();
mlir::LogicalResult runPasses();
/// Dumps the namespace with respect to the compilation phase
void dump();
~Namespace();
};
std::shared_ptr<Namespace>
makeNamespace(SereneContext &ctx, llvm::StringRef name,
llvm::Optional<llvm::StringRef> filename, bool setCurrent = true);
} // namespace serene
#endif

View File

@ -1,37 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_PASSES_H
#define SERENE_PASSES_H
#include <mlir/Pass/Pass.h>
namespace serene::passes {
std::unique_ptr<mlir::Pass> createSLIRLowerToAffinePass();
std::unique_ptr<mlir::Pass> createSLIRLowerToLLVMDialectPass();
} // namespace serene::passes
#endif

View File

@ -1,65 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_READER_ERRORS_H
#define SERENE_READER_ERRORS_H
#include "serene/errors.h"
namespace serene {
namespace reader {
class ReadError : public std::exception {
private:
char *message;
public:
ReadError(char *msg) : message(msg){};
const char *what() const throw() { return message; }
};
class MissingFileError : public llvm::ErrorInfo<MissingFileError> {
using llvm::ErrorInfo<MissingFileError>::log;
using llvm::ErrorInfo<MissingFileError>::convertToErrorCode;
public:
static char ID;
std::string path;
// TODO: Move this to an error namespace somewhere.
int file_is_missing = int();
void log(llvm::raw_ostream &os) const {
os << "File does not exist: " << path << "\n";
}
MissingFileError(llvm::StringRef path) : path(path.str()){};
std::error_code convertToErrorCode() const {
return make_error_code(errc::no_such_file_or_directory);
}
};
} // namespace reader
} // namespace serene
#endif

View File

@ -1,64 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef LOCATION_H
#define LOCATION_H
#include "mlir/IR/Location.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/OpDefinition.h"
#include <string>
namespace serene {
namespace reader {
/// It represents a location in the input string to the parser via `line`,
struct Location {
int pos; // Position of in the input string.
int line;
int col;
::std::string toString() const;
static Location unit() { return {0, 0, 0}; };
};
class LocationRange {
public:
Location start;
Location end;
LocationRange() : start(Location{0, 0, 0}), end(Location{0, 0, 0}){};
LocationRange(Location _start) : start(_start), end(_start){};
LocationRange(Location _start, Location _end) : start(_start), end(_end){};
LocationRange(const LocationRange &);
};
void inc_location(Location &, bool);
void dec_location(Location &, bool);
} // namespace reader
} // namespace serene
#endif

View File

@ -1,106 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef READER_H
#define READER_H
#include "serene/errors.h"
#include "serene/exprs/expression.h"
#include "serene/exprs/list.h"
#include "serene/exprs/symbol.h"
#include "serene/reader/errors.h"
#include "serene/reader/location.h"
#include "serene/serene.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"
#include <memory>
#include <sstream>
#include <stdexcept>
#include <string>
#include <system_error>
#include <vector>
#define READER_LOG(...) \
DEBUG_WITH_TYPE("READER", llvm::dbgs() << __VA_ARGS__ << "\n");
namespace serene {
namespace reader {
/// Base reader class which reads from a string directly.
class Reader {
private:
char current_char = ';'; // Some arbitary char to begin with
std::stringstream input_stream;
Location current_location{0, 0, 0};
char getChar(bool skip_whitespace);
void ungetChar();
bool isValidForIdentifier(char c);
// The property to store the ast tree
exprs::Ast ast;
exprs::Node readSymbol();
exprs::Node readNumber(bool);
exprs::Node readList();
exprs::Node readExpr();
public:
Reader() : input_stream(""){};
Reader(const llvm::StringRef string);
void setInput(const llvm::StringRef string);
Result<exprs::Ast> read();
// Dumps the AST data to stdout
void toString();
~Reader();
};
/// A reader to read the content of a file as AST
class FileReader {
std::string file;
Reader *reader;
public:
FileReader(const std::string file_name)
: file(file_name), reader(new Reader()) {}
// Dumps the AST data to stdout
void toString();
Result<exprs::Ast> read();
~FileReader();
};
/// Parses the given `input` string and returns a `Result<ast>`
/// which may contains an AST or an `llvm::Error`
Result<exprs::Ast> read(llvm::StringRef input);
} // namespace reader
} // namespace serene
#endif

View File

@ -1,43 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef READER_SEMANTICS_H
#define READER_SEMANTICS_H
#include "serene/context.h"
#include "serene/errors/error.h"
#include "serene/exprs/expression.h"
namespace serene::reader {
using AnalyzeResult = Result<exprs::Ast, std::vector<exprs::ErrorPtr>>;
/// This function is the entrypoint to the Semantic Analysis phase of **Serene**
/// It will call the `analyze` method on every node in the given AST and
/// returns a new AST as the result of the semantic analysis.
///
/// \param ctx The serene context
/// \prama tree The raw AST to analyze
AnalyzeResult analyze(serene::SereneContext &ctx, exprs::Ast &tree);
}; // namespace serene::reader
#endif

View File

@ -1,46 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef READER_TRAITS_H
#define READER_TRAITS_H
#include "serene/reader/location.h"
#include "serene/traits.h"
namespace serene::reader {
template <typename ConcreteType>
class ILocatable : public TraitBase<ConcreteType, ILocatable> {
public:
ILocatable(){};
ILocatable(const ILocatable &) = delete;
serene::reader::LocationRange &where() const {
return this->Object().where();
}
};
template <typename T>
serene::reader::LocationRange &where(ILocatable<T> &);
} // namespace serene::reader
#endif

View File

@ -1,33 +0,0 @@
/*
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_H
#define SERENE_H
// Sometimes we need this to make both analyzer happy
// and the fn signature right.
#define UNUSED(x) (void)(x)
namespace serene {}
#endif

View File

@ -1,5 +0,0 @@
set(LLVM_TARGET_DEFINITIONS dialect.td)
mlir_tablegen(ops.h.inc -gen-op-decls)
mlir_tablegen(ops.cpp.inc -gen-op-defs)
mlir_tablegen(dialect.h.inc -gen-dialect-decls)
add_public_tablegen_target(SereneDialectGen)

View File

@ -1,42 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_SLIR_DIALECT_H_
#define SERENE_SLIR_DIALECT_H_
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/Dialect.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
// Include the auto-generated header file containing the declaration of the
// serene's dialect.
#include "serene/slir/dialect.h.inc"
// Include the auto-generated header file containing the declarations of the
// serene's operations.
// for more on GET_OP_CLASSES: https://mlir.llvm.org/docs/OpDefinitions/
#define GET_OP_CLASSES
#include "serene/slir/ops.h.inc"
#endif // DIALECT_H_

View File

@ -1,124 +0,0 @@
#ifndef SERENE_DIALECT
#define SERENE_DIALECT
include "mlir/IR/OpBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/Interfaces/CallInterfaces.td"
include "mlir/Interfaces/CastInterfaces.td"
include "mlir/Interfaces/DataLayoutInterfaces.td"
// Dialect definition. It will directly generate the SereneDialect class
def Serene_Dialect : Dialect {
let name = "serene";
let cppNamespace = "::serene::slir";
let summary = "Primary IR of serene language.";
let description = [{
This dialect tries to map the special forms of a lisp into
IR level operations.
}];
}
// Base class for Serene dialect operations. This operation inherits from the base
// `Op` class in OpBase.td, and provides:
// * The parent dialect of the operation.
// * The mnemonic for the operation, or the name without the dialect prefix.
// * A list of traits for the operation.
class Serene_Op<string mnemonic, list<OpTrait> traits = []> :
Op<Serene_Dialect, mnemonic, traits>;
// All of the types will extend this class.
class Serene_Type<string name> : TypeDef<Serene_Dialect, name> { }
// def SymbolType : Serene_Type<"Symbol"> {
// let mnemonic = "symbol";
// let summary = "A typical Lisp symbol";
// let description = [{
// A symbol is just a name and nothing more. Just a name
// to give to a value or to use it as it is.
// }];
// // let cppNamespace = "::serene::sir";
// let parameters = (ins "std::string":$name);
// // We define the printer inline.
// let printer = [{
// $_printer << "Symbol<" << getImpl()->name << ">";
// }];
// // The parser is defined here also.
// let parser = [{
// if ($_parser.parseLess())
// return Type();
// std::string name;
// if ($_parser.parseInteger(name))
// return Type();
// return get($_ctxt, name);
// }];
// }
def ValueOp: Serene_Op<"value"> {
let summary = "This operation represent a value";
let description = [{
some description
}];
let arguments = (ins I64Attr:$value);
let results = (outs I64);
// let verifier = [{ return serene::sir::verify(*this); }];
let builders = [
OpBuilder<(ins "int":$value), [{
// Build from fix 64 bit int
build(odsBuilder, odsState, odsBuilder.getI64Type(), (uint64_t) value);
}]>,
];
}
def FnOp: Serene_Op<"fn", [
AffineScope, AutomaticAllocationScope,
IsolatedFromAbove
]> {
let summary = "This operation is just a place holder for a function";
let description = [{
A place holder for an anonymous function. For example consider an expression
like `(def a (fn (x) x))`, in this case we don't immediately create an anonymous
function since we need to set the name and create the function later.
}];
let arguments = (ins StrAttr:$name,
DictionaryAttr:$args,
OptionalAttr<StrAttr>:$sym_visibility);
let regions = (region AnyRegion:$body);
let results = (outs NoneType);
// let builders = [
// OpBuilder<(ins
// "llvm::StringRef":$name, "mlir::FunctionType":$type,
// CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attrs,
// CArg<"llvm::ArrayRef<mlir::DictionaryAttr>", "{}">:$argAttrs)
// >];
// let extraClassDeclaration = [{
// static FnOp create(mlir::Location location, llvm::StringRef name, mlir::FunctionType type,
// llvm::ArrayRef<mlir::NamedAttribute> attrs = {});
// static FnOp create(mlir::Location location, llvm::StringRef name, mlir::FunctionType type,
// mlir::Operation::dialect_attr_range attrs);
// static FnOp create(mlir::Location location, llvm::StringRef name, mlir::FunctionType type,
// llvm::ArrayRef<mlir::NamedAttribute> attrs,
// llvm::ArrayRef<mlir::DictionaryAttr> argAttrs);
// }];
}
#endif // SERENE_DIALECT

View File

@ -1,124 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_SLIR_GENERATABLE_H
#define SERENE_SLIR_GENERATABLE_H
#include "serene/slir/dialect.h"
#include "serene/traits.h"
#include <llvm/ADT/STLExtras.h>
#include <llvm/IR/Module.h>
#include <llvm/Support/Casting.h>
#include <llvm/Support/TargetSelect.h>
#include <mlir/ExecutionEngine/ExecutionEngine.h>
#include <mlir/ExecutionEngine/OptUtils.h>
#include <mlir/IR/BuiltinOps.h>
#include <mlir/IR/MLIRContext.h>
#include <mlir/Support/LogicalResult.h>
#include <mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h>
#include <mlir/Target/LLVMIR/ModuleTranslation.h>
#include <stdexcept>
#include <utility>
namespace serene {
class Namespace;
class SereneContext;
} // namespace serene
namespace serene::slir {
template <typename T>
class GeneratableUnit : public TraitBase<T, GeneratableUnit> {
public:
GeneratableUnit(){};
GeneratableUnit(const GeneratableUnit &) = delete;
void generate(serene::Namespace &ns) {
// TODO: should we return any status or possible error here or
// should we just populate them in a ns wide state?
this->Object().generateIR(ns);
};
};
template <typename T>
class Generatable : public TraitBase<T, Generatable> {
public:
Generatable(){};
Generatable(const Generatable &) = delete;
mlir::LogicalResult generate() { return this->Object().generate(); };
mlir::LogicalResult runPasses() { return this->Object().runPasses(); };
mlir::ModuleOp &getModule() { return this->Object().getModule(); };
serene::SereneContext &getContext() { return this->Object().getContext(); };
void dump() { this->Object().dump(); };
};
template <typename T>
mlir::LogicalResult generate(Generatable<T> &t) {
return t.generate();
};
template <typename T>
std::unique_ptr<llvm::Module> toLLVMIR(Generatable<T> &t) {
auto &module = t.getModule();
auto &ctx = t.getContext();
// Register the translation to LLVM IR with the MLIR context.
mlir::registerLLVMDialectTranslation(ctx.mlirContext);
// Convert the module to LLVM IR in a new LLVM IR context.
auto llvmModule = mlir::translateModuleToLLVMIR(module, ctx.llvmContext);
if (!llvmModule) {
// TODO: Return a Result type instead
llvm::errs() << "Failed to emit LLVM IR\n";
throw std::runtime_error("Failed to emit LLVM IR\n");
}
// Initialize LLVM targets.
llvm::InitializeNativeTarget();
llvm::InitializeNativeTargetAsmPrinter();
mlir::ExecutionEngine::setupTargetTriple(llvmModule.get());
/// Optionally run an optimization pipeline over the llvm module.
auto optPipeline = mlir::makeOptimizingTransformer(
/*optLevel=*/ctx.getOptimizatioLevel(), /*sizeLevel=*/0,
/*targetMachine=*/nullptr);
if (auto err = optPipeline(llvmModule.get())) {
llvm::errs() << "Failed to optimize LLVM IR " << err << "\n";
throw std::runtime_error("Failed to optimize LLVM IR");
}
return std::move(llvmModule);
};
template <typename T>
void dump(Generatable<T> &t) {
t.dump();
};
} // namespace serene::slir
#endif

View File

@ -1,39 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_SLIR_H
#define SERENE_SLIR_H
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/MLIRContext.h"
#include "serene/exprs/expression.h"
#include "serene/slir/generatable.h"
#include <memory>
namespace serene {
namespace slir {} // namespace slir
} // namespace serene
#endif

View File

@ -1,45 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_SLIR_UTILS_H
#define SERENE_SLIR_UTILS_H
#include "mlir/IR/BuiltinOps.h"
#include "serene/reader/location.h"
namespace serene {
class Namespace;
}
namespace serene::slir {
/**
* Convert a Serene location to MLIR FileLineLoc Location
*/
::mlir::Location toMLIRLocation(serene::Namespace &,
serene::reader::Location &);
} // namespace serene::slir
#endif

View File

@ -1,128 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**
* This is a CRTP based Trait implementation that allows to use Trait like
* classes to create polymorphic functions and API statically at compile type
* without any runtime shenanigans. For more on CRTP checkout:
*
* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern
*
* In order to define a trait, use the `TraitBase` class like:
* \code
* template <typename ConcreteType>
* class Blahable : public TraitBase<ConcreteType, Blahable> {}
* \endcode
*
* Every Trait has to take the `ConcreteType` as template argument and pass it
* to the `TraitBase`. Checkout the documentation of `TraitBase` for more info
* on creating a new Trait.
*
* Alongside with each Trait type, you should provide the "Official" interface
* of the Trait via some standalone functions that operates on the Trait type.
* For example Imagine we have a Trait type called `ABC` with two main
* functionality `foo` and `bar`. We need to create two functions as follows:
*
* \code
* template <typename T>
* SomeType Foo(ABC<T> &t) { return t.foo(); };
*
* template <typename T>
* SomeType bar(ABC<T> &t, int x) { return t.bar(x); };
* \endcode
*
* These two functions will be the official interface to the trait `ABC`.
* IMPORTANT NOTE: Make sure to pass a reference of type `ABC<T>` to the
* functions and DO NOT PASS BY COPY. Since copying will copy the value by the
* trait type only, we would not be able to statically case it to the
* implementor type and it will lead to some allocation problem.
*
* Traits can be used via `WithTrait` helper class which provides a clean
* interface to mix and match Trait types.
*
*/
#ifndef SERENE_TRAITS_H
#define SERENE_TRAITS_H
#include <string>
#include <type_traits>
namespace serene {
/// A placeholder structure that replaces the concrete type of the
/// Imlementations Which might have child classes.
struct FinalImpl;
/// In order to use Traits, we can use `WithTrait` class as the base
/// of any implementation class and pass the Trait classes as template argument
/// for example:
///
/// \code
/// class Expression : public WithTrait<Expression, Printable, Locatable> {}
/// \endcode
template <typename ConcreteType, template <typename T> class... Traits>
class WithTrait : public Traits<ConcreteType>... {
protected:
WithTrait(){};
friend ConcreteType;
};
/// This class provides the common functionality among the Trait Types and
/// every Trait has to inherit from this class. Here is an example:
///
/// \code
/// template <typename ConcreteType>
/// class Blahable : public TraitBase<ConcreteType, Blahable> {}
/// \endcode
///
/// In the Trait class the underlaying object which implements the Trait
/// is accessable via the `Object` method.
template <typename ConcreteType, template <typename> class TraitType>
class TraitBase {
protected:
/// Statically casts the object to the concrete type object to be
/// used in the Trait Types.
// const ConcreteType &Object() const {
// return static_cast<const ConcreteType &>(*this);
// };
ConcreteType &Object() { return static_cast<ConcreteType &>(*this); };
};
template <typename ConcreteType>
class IDebuggable : public TraitBase<ConcreteType, IDebuggable> {
public:
IDebuggable(){};
IDebuggable(const IDebuggable &) = delete;
std::string toString() const { return this->Object().toString(); }
};
template <typename T>
std::string toString(IDebuggable<T> &t) {
return t.toString();
}
}; // namespace serene
#endif

View File

@ -1,28 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef TRAITS_LOCATABLE_H
#define TRAITS_LOCATABLE_H
#endif

View File

@ -1,41 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_TYPES_TYPE_H
#define SERENE_TYPES_TYPE_H
#include <string>
namespace serene::types {
class Type {
public:
virtual ~Type() = default;
/// The AST representation of a type
virtual std::string toString() const = 0;
};
}; // namespace serene::types
#endif

View File

@ -1,97 +0,0 @@
/* -*- C++ -*-
* Serene programming language.
*
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef SERENE_UTILS_H
#define SERENE_UTILS_H
#include "llvm/Support/Error.h"
#include <variant>
// C++17 required. We can't go back to 14 any more :))
namespace serene {
/// A similar type to Rust's Result data structure. It either holds a value of
/// type `T` successfully or holds a value of type `E` errorfully. It is
/// designed to be used in situations which the return value of a function might
/// contains some errors. The official way to use this type is to use the
/// factory functions `Success` and `Error`. For example:
///
/// \code
/// auto successfulResult = Result<int>::success(3);
/// auto notOkResult = Result<int>::error(SomeLLVMError());
// \endcode
///
/// In order check for a value being errorful or successful checkout the `ok`
/// method or simply use the value as a conditiona.
template <typename T, typename E = llvm::Error>
class Result {
// The actual data container
std::variant<T, E> contents;
/// The main constructor which we made private to avoid ambiguousness in
/// input type. `Success` and `Error` call this ctor.
template <typename InPlace, typename Content>
Result(InPlace i, Content &&c) : contents(i, std::forward<Content>(c)){};
public:
/// Create a succesfull result with the given value of type `T`.
static Result success(T v) {
return Result(std::in_place_index_t<0>(), std::move(v));
}
/// Create an errorful result with the given value of type `E` (default
/// `llvm::Error`).
static Result error(E e) {
return Result(std::in_place_index_t<1>(), std::move(e));
}
/// Return the value if it's successful otherwise throw an error
T &&getValue() && { return std::move(std::get<0>(contents)); };
/// Return the error value if it's errorful otherwise throw an error
E &&getError() && { return std::move(std::get<1>(contents)); };
// using std::get, it'll throw if contents doesn't contain what you ask for
/// Return the value if it's successful otherwise throw an error
T &getValue() & { return std::get<0>(contents); };
/// Return the error value if it's errorful otherwise throw an error
E &getError() & { return std::get<1>(contents); };
const T &getValue() const & { return std::get<0>(contents); }
const E &getError() const & { return std::get<1>(contents); }
/// Return the a boolean value indicating whether the value is succesful
/// or errorful.
bool ok() const { return std::holds_alternative<T>(contents); };
operator bool() const { return ok(); }
};
} // namespace serene
#endif

27
maths/cheatsheet.tex Normal file
View File

@ -0,0 +1,27 @@
\documentclass{article}
\title{Serene's mathematical cheatsheet}
\author{Sameer Rahmani}
\date{January 2024}
\NeedsTeXFormat{LaTeX2e}
\usepackage[default,light,semibold]{sourcesanspro}
\setsansfont{Source Sans Pro}
\usepackage{etoolbox}
\usepackage{titlesec}
\usepackage{fontspec}
\usepackage[left=0.6in,top=0.3in,right=0.6in,bottom=0.6in]{geometry} % Document margins
\usepackage{hyperref}
\usepackage{mfirstuc}
\edef\restoreparindent{\parindent=\the\parindent\relax}
\usepackage{parskip}
\restoreparindent{}
\pagestyle{empty}
\begin{document}
\maketitle
\newpage
\end{document}

135
mkdocs.yml Normal file
View File

@ -0,0 +1,135 @@
site_name: Serene Programming Language
site_description: A modern, typed lisp
site_author: lxsameer
repo_url: https://devheroes.codes/serene/serene
repo_name: Serene
copyright: Copyright &copy; 2019 - 2023 Sameer Rahmani
edit_uri: _edit/master/docs/pages/
docs_dir: ./docs/pages
site_dir: ./build/docs
nav:
- Home: 'index.md'
- Getting Started: 'getting_started.md'
- Resources: 'resources.md'
theme:
name: material
logo: /images/serene.png
favicon: /images/serene.png
icon:
repo: fontawesome/brands/git-alt
edit: material/pencil
view: material/eye
features:
- content.action.edit
- navigation.tracking
- navigation.instant
- navigation.tabs
- navigation.tabs.sticky
- navigation.sections
- navigation.expand
- navigation.indexes
- toc.follow
- toc.integrate
- navigation.top
- search.suggest
- search.highlight
- search.share
- header.autohide
- navigation.footer
- content.code.copy
- content.code.annotate
palette:
- scheme: slate
# toggle:
# icon: material/brightness-4
# name: Switch to light mode
primary: deep purple
accent: amber
# # Palette toggle for light mode
# - scheme: default
# toggle:
# icon: material/brightness-7
# name: Switch to dark mode
# primary: deep purple
# accent: amber
# # Palette toggle for dark mode
plugins:
- git-revision-date-localized:
enable_creation_date: true
- search
# - social:
# concurrency: 16
- tags
#tags_file: tags.md
- mike:
# These fields are all optional; the defaults are as below...
alias_type: symlink
redirect_template: null
deploy_prefix: ''
canonical_version: null
version_selector: true
css_dir: css
javascript_dir: js
extra:
version:
provider: mike
social:
- icon: fontawesome/brands/mastodon
link: https://social.lxsameer.com/@lxsameer
- icon: fontawesome/brands/twitter
link: https://twitter.com/@lxsameer
- icon: fontawesome/brands/youtube
link: https://www.youtube.com/c/lxsameer
generator: false
extra_css:
- stylesheets/extra.css
markdown_extensions:
- attr_list
- md_in_html
- def_list
- footnotes
- tables
- md_in_html
- pymdownx.superfences
- admonition
- pymdownx.details
- pymdownx.highlight:
anchor_linenums: true
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.snippets
- pymdownx.superfences
- pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
- pymdownx.tasklist:
custom_checkbox: true
- pymdownx.emoji:
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
- pymdownx.arithmatex:
generic: true
extra_javascript:
- javascripts/mathjax.js
- https://polyfill.io/v3/polyfill.min.js?features=es6
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js

76
nix/boehmgc.nix Normal file
View File

@ -0,0 +1,76 @@
{ lib,
stdenv,
fetchurl,
nixVersions,
libatomic_ops,
cmake,
ninja,
}:
stdenv.mkDerivation (finalAttrs: rec {
pname = "boehmgc";
version = "8.2.4";
src = fetchurl {
urls = [
"https://github.com/ivmai/bdwgc/releases/download/v${finalAttrs.version}/gc-${finalAttrs.version}.tar.gz"
];
sha256 = "sha256-PQ082+B3QD0xBrtA8Mu1Y0E9bv27Kn4c1ohlld7Ej8I=";
};
nativeBuildInputs = [ cmake ninja ];
buildInputs = [ libatomic_ops ];
#outputs = [ "out" "dev" "doc" ];
ninjaFlags = [ "-v" ];
cmakeFlags = [
#"-Denable_cplusplus=ON"
"-Ddefault_enable_threads=ON"
"-DBUILD_SHARED_LIBS=OFF"
"-Denable_threads=ON"
"-Denable_parallel_mark=ON"
"-Denable_thread_local_alloc=ON"
"-Denable_mmap=ON"
# TODO: Do we want to return the pages to the OS if empty for N collections?
"-Denable_munmap=ON"
"-Denable_werror=ON"
# TODO: Do we want the entire GC in a single object file?
"-Denable_single_obj_compilation=ON"
"-Dwith_libatomic_ops=OFF"
"-Dwithout_libatomic_ops=ON"
"-DCMAKE_INSTALL_LIBDIR=${placeholder "out"}/lib"
];
# `gctest` fails under emulation on aarch64-darwin
doCheck = !(stdenv.isDarwin && stdenv.isx86_64);
enableParallelBuilding = true;
passthru.tests = nixVersions;
meta = with lib; {
homepage = "https://hboehm.info/gc/";
description = "The Boehm-Demers-Weiser conservative garbage collector for C and C++";
longDescription = ''
The Boehm-Demers-Weiser conservative garbage collector can be used as a
garbage collecting replacement for C malloc or C++ new. It allows you
to allocate memory basically as you normally would, without explicitly
deallocating memory that is no longer useful. The collector
automatically recycles memory when it determines that it can no longer
be otherwise accessed.
The collector is also used by a number of programming language
implementations that either use C as intermediate code, want to
facilitate easier interoperation with C libraries, or just prefer the
simple collector interface.
Alternatively, the garbage collector may be used as a leak detector for
C or C++ programs, though that is not its primary goal.
'';
# non-copyleft, X11-style license
changelog = "https://github.com/ivmai/bdwgc/blob/v${finalAttrs.version}/ChangeLog";
license = "https://hboehm.info/gc/license.txt";
maintainers = with maintainers; [ AndersonTorres ];
platforms = platforms.all;
};
})

111
nix/overlays.nix Normal file
View File

@ -0,0 +1,111 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ ... }:
with builtins;
let getEnv = p: (p.env or { }).NIX_LDFLAGS or p.NIX_LDFLAGS or "";
in {
# Most of these overlays are do to bugs and problems
# in upstream nixpkgs. But thanks to their design
# We can fix them using these overlays and contribute
# them upstream little by little.
sereneDev = (final: prev:
if !prev.stdenv.hostPlatform.isLinux then
prev
else {
p11-kit = prev.p11-kit.overrideAttrs
(old: { patches = [ ./nix/patches/p11-kit_skip_test.patch ]; });
cpio = prev.cpio.overrideAttrs (old: {
nativeBuildInputs = [ final.autoreconfHook ];
NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
});
libedit = prev.libedit.overrideAttrs (old: {
# Musl is ISO 10646 compliant but doesn't define __STDC_ISO_10646__ we need to do it ourselves
NIX_CFLAGS_COMPILE = "-D__STDC_ISO_10646__=201103L";
});
elfutils = prev.elfutils.overrideAttrs (old: {
# libcxx does not have __cxa_demangle
configureFlags = old.configureFlags ++ [ "--disable-demangler" ];
});
ccache = prev.ccache.overrideAttrs (old: {
nativeBuildInputs = old.nativeBuildInputs ++ [ final.elfutils ];
});
# We don't need systemd at all
util-linux = prev.util-linux.override { systemdSupport = false; };
# libpam exmaples use glibc. We need to disable them
linux-pam = prev.linux-pam.overrideAttrs (old: {
postConfigure = ''
sed 's/examples//' -i Makefile
'';
});
#=============================================================
# Since we're using lld-18, and --no-undefined-version is the
# default in lld-18. We need to explicitly turn it off for
# these problematic packages untill they fix it upstream.
libxcrypt = prev.libxcrypt.overrideAttrs (old: {
env.NIX_LDFLAGS = "${getEnv old} --undefined-version";
#old.NIX_FLAGS ++ final.lib.optional (prev.stdenv.cc.isClang)
});
ncurses = prev.ncurses.overrideAttrs
(old: { env.NIX_LDFLAGS = "${getEnv old} --undefined-version"; });
libbsd = prev.libbsd.overrideAttrs (old: {
env.NIX_LDFLAGS = "${getEnv old} --undefined-version";
# NIX_LDFLAGS = [ ] ++ final.lib.optional (prev.stdenv.cc.isClang)
# [ "--undefined-version" ];
});
libxml2 = prev.libxml2.overrideAttrs (old: {
env.NIX_LDFLAGS = "${getEnv old} --undefined-version";
propagatedBuildInputs = old.propagatedBuildInputs
++ [ final.zlib.static ];
# NIX_LDFLAGS = [ ] ++ final.lib.optional (prev.stdenv.cc.isClang)
# [ "--undefined-version" ];
});
# binutils = prev.binutils.overrideAttrs (old: {
# env.NIX_LDFLAGS = (getEnv old NIX_LDFLAGS " ") ++ "--undefined-version";
# buildInputs = [ final.zlib final.gettext final.zlib.static ];
# });
});
iwyu = (final: prev: {
iwyu = (prev.include-what-you-use.overrideAttrs (old:
let version = "0.22";
in {
inherit version;
src = prev.fetchurl {
url =
"${old.meta.homepage}/downloads/${old.pname}-${version}.src.tar.gz";
hash = "sha256-hZB0tGHqS4MlpzQYwgfKM7XmVmsI5rWH65FkQWVppt0=";
};
cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${prev.llvmPackages_18.llvm.dev}" ];
})).override { llvmPackages = prev.__splicedPackages.llvmPackages_18; };
});
}

View File

@ -0,0 +1,27 @@
From 132b779414c2236c1350b578b59c8edcfc4c5a14 Mon Sep 17 00:00:00 2001
From: Sameer Rahmani <lxsameer@gnu.org>
Date: Sat, 25 Nov 2023 13:14:42 +0000
Subject: [PATCH] test
---
common/test.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/common/test.c b/common/test.c
index 6cdbd1fa2118..6cd6f84bcdc7 100644
--- a/common/test.c
+++ b/common/test.c
@@ -614,8 +614,9 @@ p11_test_copy_setgid (const char *input,
assert (fd >= 0);
copy_file (input, fd);
- if (fchown (fd, getuid (), group) < 0)
- assert_not_reached ();
+ if (fchown (fd, getuid (), group) < 0) {
+ return NULL;
+ }
if (fchmod (fd, 02750) < 0)
assert_not_reached ();
if (close (fd) < 0)
--
2.41.0

29
nix/utils.nix Normal file
View File

@ -0,0 +1,29 @@
# Serene Programming Language
#
# Copyright (c) 2019-2024 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
{ nixpkgs }: {
getPkgs = system: overlays:
if system == "x86_64-linux" then
import nixpkgs {
inherit system overlays;
linker = "lld";
crossSystem = nixpkgs.lib.systems.examples.musl64 // {
useLLVM = true;
};
}
else
import nixpkgs { inherit system overlays; };
}

View File

@ -0,0 +1,69 @@
FROM docker.io/debian:sid-slim
ARG VERSION
RUN apt-get update && \
apt-get install --no-install-recommends -y \
gnupg \
cmake \
ccache \
git \
ninja-build \
binutils \
lsb-release \
wget \
software-properties-common \
zlib1g \
cppcheck \
shellcheck \
zlib1g-dev
RUN wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh
RUN ./llvm.sh ${VERSION} all
RUN apt-get update --fix-missing && \
apt-get install -y --no-install-recommends \
mlir-${VERSION}-tools \
libmlir-${VERSION}-dev \
libmlir-${VERSION} \
libmlir-${VERSION}-dbgsym \
liblld-${VERSION} \
liblld-${VERSION}-dev \
clang-format-${VERSION} \
clang-tidy-${VERSION}
RUN ln -s `which lld-${VERSION}` /usr/bin/lld && \
ln -s `which clang-${VERSION}` /usr/bin/clang && \
ln -s `which clang++-${VERSION}` /usr/bin/clang++ && \
ln -s `which clang-format-${VERSION}` /usr/bin/clang-format && \
ln -s `which clang-tidy-${VERSION}` /usr/bin/clang-tidy && \
ln -s `which mlir-tblgen-${VERSION}` /usr/bin/mlir-tblgen
ENV MLIR_DIR /usr/lib/llvm-${VERSION}
ENV CMAKE_PREFIX_PATH=/usr/lib/llvm-${VERSION}
ENV LD_LIBRARY_PATH=/usr/lib/llvm-${VERSION}/lib/clang/${VERSION}.0.0/lib/linux/
ENV CC=/usr/bin/clang
ENV CXX=/usr/bin/clang++
# --branch clang_${VERSION}
WORKDIR /iwuy
RUN git clone https://github.com/include-what-you-use/include-what-you-use.git --depth 1 && \
mkdir build && cd build && \
cmake -G Ninja -DCMAKE_PREFIX_PATH=/usr/lib/llvm-${VERSION} ../include-what-you-use && \
cmake --build . && \
cmake -P cmake_install.cmake
WORKDIR /boehm
RUN git clone https://github.com/ivmai/bdwgc.git --depth 1 --branch v8.2.0 && \
mkdir build && cd build && \
cmake -G Ninja -DBUILD_SHARED_LIBS=OFF -Denable_cplusplus=ON -Denable_threads=ON \
-Denable_gcj_support=OFF -Dinstall_headers=ON \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON ../bdwgc && \
cmake --build . --config Release && \
cmake -P cmake_install.cmake
WORKDIR /app
RUN rm /iwuy -rf && rm /boehm -rf && rm /llvm.sh
RUN apt-get purge -y git software-properties-common wget && \
apt-get autoremove -y && \
apt-get clean

View File

@ -0,0 +1,11 @@
FROM rg.fr-par.scw.cloud/serene/llvm:latest
WORKDIR /app
# For CI
COPY .pre-commit-config.yaml .
RUN apt-get update && \
apt-get install -y --no-install-recommends git python3 python3-pip && \
pip3 install pre-commit && \
git init . && \
pre-commit autoupdate && \
rm -fv /app/.pre-commit-config.yaml

View File

@ -0,0 +1,24 @@
FROM debian:sid-slim as builder
RUN apt-get update --fix-missing && apt-get install -y wget gnupg ccache cmake ccache git ninja-build build-essential binutils
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add -
RUN echo "deb http://apt.llvm.org/unstable/ llvm-toolchain main" >> /etc/apt/sources.list
RUN apt-get update --fix-missing && apt-get install -y clang-format-15 clang-tidy-15 clang-tools-15 clang-15 clangd-15 libc++-15-dev libc++1-15 libc++abi-15-dev libc++abi1-15 libclang-15-dev libclang1-15 liblldb-15-dev lld-15 lldb-15 llvm-15-dev llvm-15-runtime llvm python3-clang-15 python3-lldb-15 mlir-15-tools libmlir-15-dev
RUN mkdir -p /opt/build
WORKDIR /opt/build
COPY ./ /usr/src/llvm-project
RUN ln -s `which lld-15` /usr/bin/lld && ln -s `which lldb-15` /usr/bin/lldb
RUN cmake -G Ninja /usr/src/llvm-project/llvm -DCMAKE_INSTALL_PREFIX=/opt/llvm -DLLVM_PARALLEL_COMPILE_JOBS=7 -DLLVM_PARALLEL_LINK_JOBS=1 -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_CCACHE_BUILD=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DLLVM_ENABLE_PROJECTS='clang;lldb;lld;mlir;clang-tools-extra;compiler-rt' -DCMAKE_C_COMPILER=clang-15 -DCMAKE_CXX_COMPILER=clang++-15 -DLLVM_ENABLE_LLD=ON
RUN cmake --build .
RUN cmake -DCMAKE_INSTALL_PREFIX=/opt/llvm -P cmake_install.cmake
FROM debian:sid-slim
COPY --from=builder /opt/llvm /opt/llvm

View File

@ -0,0 +1,9 @@
FROM rg.fr-par.scw.cloud/serene/llvm:15-8
ARG TASK=build
WORKDIR /app
COPY . .
RUN ./builder ${TASK}

View File

@ -0,0 +1,47 @@
FROM alpine:edge
RUN apk update \
&& apk add --no-cache \
ninja \
make \
clang \
clang-dev \
bison \
flex \
# compiler-rt \ #
# llvm-libunwind \
# lld \
gcc \
libgcc
curl \
g++ \
alpine-sdk \
libatomic \
libgcc \
cmake \
bash \
git \
linux-headers \
zlib \
zlib-dev \
zstd \
zstd-dev \
tar \
xz \
python3
# RUN ln -sf /usr/bin/clang /usr/bin/cc \
# && ln -sf /usr/bin/clang++ /usr/bin/c++ \
# && ls -l /usr/bin/cc /usr/bin/c++ \
# && cc --version \
# && c++ --version
# && update-alternatives --install /usr/bin/cc cc /usr/bin/clang 10\
# && update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 10\
RUN addgroup -S serene && \
adduser -h /home/serene -S serene -G serene
USER serene:serene
ENV HOME=/home/serene
WORKDIR /home/serene/serene

View File

@ -0,0 +1,22 @@
FROM alpine:edge
RUN apk update \
&& apk upgrade \
&& apk add --no-cache \
alpine-sdk \
linux-headers \
gcc \
g++ \
libgcc \
build-base \
zlib \
zlib-dev \
zstd \
zstd-dev
# clang-dev \
# compiler-rt \
# libc++-dev \
# llvm-runtimes \
# libc++-static \
# llvm-libunwind \
# lld \

View File

@ -0,0 +1,122 @@
;;; serene-dev --- Serene's development lib for Emacs users -*- lexical-binding: t; -*-
;;
;; Copyright (c) 2019-2024 Sameer Rahmani
;;
;; Author: Sameer Rahmani <lxsameer@gnu.org>
;; URL: https://serene-lang.org
;; Version: 0.1.0
;; Package-Requires: (projectile)
;;
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;;
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;
;;; Commentary:
;; In order to use this library just put it somewhere that Emacs can load it
;; either via `require' or `load' and then call `serene/setup-dev-env' in your
;; init file.
;;
;; Keybindings:
;; * `s-c c' Runs `./builder compile'
;; * `s-c b' Runs `./builder build'
;;
;;; Code:
(defvar serene/compile-buffer "*compile*")
(defmacro serene/builder (command &optional buf-name sync)
"Run the given COMMAND via the builder script.
Use the optional BUF-NAME as the buffer.
If SYNC is non-nil it will block."
(let ((buf (or buf-name (format "*%s*" command))))
(if (not sync)
`(projectile-run-async-shell-command-in-root
(format "./builder %s" ,command) ,buf)
`(projectile-run-shell-command-in-root
(format "./builder %s" ,command) ,buf))))
(defun serene/compile (&optional sync)
"Compile the project.
It will run the `./builder compile' asynchronously or synchronously if
SYNC is non-nil."
(interactive)
(serene/builder "compile" serene/compile-buffer sync))
(defun serene/build ()
"Compile the project.
It will run the `./builder build' asynchronously."
(interactive)
(serene/builder "build" serene/compile-buffer))
(defun serene/build-release ()
"Compile the project.
It will run the `./builder build-release' asynchronously."
(interactive)
(serene/builder "build-release" serene/compile-buffer))
(defun serene/run (args)
"Run the project with the give ARGS.
It will run the `./builder build-release' asynchronously."
(interactive "sRun: ")
(serene/builder (format "run %s" args) serene/compile-buffer))
(defun serene/run-hello-world (args)
"Run the project with the give ARGS.
It will run the `./builder build-release' asynchronously."
(interactive "s-b . -l `pwd` docs.examples.hello_world ")
(let ((cmd (format "run -b . -l `pwd` docs.examples.hello_world %s" args)))
(serene/builder cmd serene/compile-buffer)))
(defun serene/run-hello-world-emit (args)
"Run the project with the give ARGS.
It will run the `./builder build-release' asynchronously."
(interactive (list (completing-read "Emit: " '("ast" "semantic" "slir" "mlir" "lir" "ir" "jit" "object" "target"))))
(let ((cmd (format "run -b . -l `pwd` docs.examples.hello_world -emit %s" args)))
(serene/builder cmd serene/compile-buffer)))
(defun serene/setup-keybindings ()
"Setup the serene-dev keybindings."
(interactive)
(define-key c++-mode-map (kbd "s-c c") #'serene/compile)
(define-key c++-mode-map (kbd "s-c b") #'serene/build)
(define-key c++-mode-map (kbd "s-c r") #'serene/run)
(define-key c++-mode-map (kbd "s-c e") #'serene/run-hello-world-emit))
(defun serene/format-buffer ()
"Format the buffer if `lsp-format-buffer' is available."
(when (and (eq major-mode 'c++-mode) (featurep 'lsp-mode))
(lsp-format-buffer)))
(defun serene/setup-dev-env ()
"Setup the development env of Serene."
(interactive)
(add-hook 'c++-mode-hook
(lambda ()
(require 'projectile)
(serene/setup-keybindings)
(add-hook 'before-save-hook #'serene/format-buffer))))
(provide 'serene-dev)
;;; serene-dev.el ends here

Some files were not shown because too many files have changed in this diff Show More