Compare commits

..

1 Commits
master ... ep2

Author SHA1 Message Date
Sameer Rahmani a4c895562d Upgrade to llvm 13rc2 2021-08-28 18:07:54 +01:00
207 changed files with 11943 additions and 13612 deletions

View File

@ -15,20 +15,4 @@ 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
...

View File

@ -1,237 +0,0 @@
---
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'
...

View File

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

11
.gitignore vendored
View File

@ -23,14 +23,3 @@ 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

View File

@ -1,55 +0,0 @@
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 ]

View File

@ -1,64 +0,0 @@
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,61 +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/>.
cmake_minimum_required(VERSION 3.19)
cmake_minimum_required(VERSION 3.16)
project(
Serene
VERSION 1.0.0
DESCRIPTION "A modern typed Lisp."
# 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."
LANGUAGES CXX C)
# Clangd command file
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
option(CPP_20_SUPPORT "C++20 Support" OFF)
# =============================================================================
# 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
# 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 =======================
set(C_STANDARD 17)
## Settings -----------------------------------------
# specify the C++ standard
if(CPP_20_SUPPORT)
if (CPP_20_SUPPORT)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
@ -63,145 +22,105 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CMAKE_CXX_STANDARD_REQUIRED True)
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(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(SRC_DIR ${CMAKE_SOURCE_DIR}/src)
set(BIN_DIR ${CMAKE_SOURCE_DIR}/bin)
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_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_CXX_FLAGS_RELEASE
"${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/scripts/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)
# 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)
## 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)
# CCache support ==============================
if(SERENE_DISABLE_CCACHE)
message(STATUS "CCache support is disabled")
else()
find_program(CCACHE_PROGRAM ccache)
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")
include(cotire)
include(FetchContent)
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)
find_program(MLIRTBLGEN_PROGRAM REQUIRED NAMES mlir-tblgen)
find_package(Clang REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Found LLVM ${LLVM_PAsCKAGE_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})
# 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}")
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(TableGen)
include(AddLLVM)
include(AddMLIR)
include(HandleLLVMOptions)
include(AddClang)
# 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})
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})
add_definitions(${LLVM_DEFINITIONS})
# /LLVM setup
# =================================================================
# add_subdirectory(serene-tblgen)
add_subdirectory(serene)
# include(tablegen-serene) Create the tools we use to compile Serene
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
# 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)
llvm_map_components_to_libnames(llvm_libs support core irreader)
# add_subdirectory(devtools)
# The compiled library code is here
add_subdirectory(src/serene)
if(SERENE_ENABLE_DOCS)
add_subdirectory(docs)
# 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)
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 Normal file → Executable file
View File

@ -1,339 +1,19 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (c) 2020 Sameer Rahmani <lxsameer@gnu.org>
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.
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:
Preamble
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of 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.
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.

View File

@ -1,33 +0,0 @@
# 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/>.

75
README.org Normal file
View File

@ -0,0 +1,75 @@
* 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

39
bin/CMakeLists.txt Normal file
View File

@ -0,0 +1,39 @@
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)

247
bin/serene.cpp Normal file
View File

@ -0,0 +1,247 @@
/* -*- 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 <llvm/IR/LegacyPassManager.h>
#include <llvm/Support/CommandLine.h>
#include <llvm/Support/FileSystem.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.o" : outputFile.c_str();
std::error_code ec;
llvm::raw_fd_ostream dest(filename, 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";
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 Executable file
View File

@ -0,0 +1,191 @@
#! /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
# 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

View File

@ -1,29 +0,0 @@
# 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

@ -1,29 +0,0 @@
# 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")

View File

@ -1,11 +0,0 @@
#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

@ -1,22 +0,0 @@
# 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

@ -1,49 +0,0 @@
# 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)

View File

@ -1,85 +0,0 @@
# 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

@ -1,21 +0,0 @@
# 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

@ -1,29 +0,0 @@
/* -*- 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

@ -1,70 +0,0 @@
# 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

@ -1,31 +0,0 @@
/* -*- 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

View File

@ -1,20 +0,0 @@
/*
* 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

@ -1,26 +0,0 @@
/* -*- 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) serenecli(c) reader(r) context(x) Misc(m) JIT(j) GC(g) Tool(t)
#+TAGS: DOCS(d) EXAMPLES(e) BOOTSTRAP(b) Old(o) Misc(m)
#+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,8 +36,6 @@ 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
@ -57,13 +55,6 @@ 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]]
@ -71,32 +62,18 @@ 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 :GC:
** Garbage collection
- [[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]] :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.
- [[https://www.hboehm.info/gc/][Boehm GC]]
** 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
@ -116,129 +93,49 @@ 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
** 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
** Bootstrap
*** TODO Replace =llvm::outs()= with debug statements
*** TODO Error handling
Create proper error handling for the internal infra
** 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:
*** 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 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 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
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

View File

@ -1,93 +0,0 @@
# 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

@ -1,35 +0,0 @@
/* -*- 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)));
}

View File

@ -1,39 +0,0 @@
/* -*- 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)));
}

16
docs/CMakeLists.txt Normal file
View File

@ -0,0 +1,16 @@
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)

View File

@ -1,14 +0,0 @@
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 () 4))
(def main (fn () 3))
(def main1 (fn (v y n) 3))

View File

@ -1,38 +0,0 @@
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
}

View File

@ -1,439 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 16 KiB

View File

@ -1,167 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -1,496 +0,0 @@
<?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="300mm"
height="121mm"
viewBox="0 0 299.99999 121"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="mlir.svg"
inkscape:export-filename="/home/lxsameer/llvm.png"
inkscape:export-xdpi="92.360001"
inkscape:export-ydpi="92.360001">
<defs
id="defs2">
<marker
style="overflow:visible"
id="marker1383"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1381" />
</marker>
<marker
style="overflow:visible"
id="marker1361"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1359" />
</marker>
<marker
style="overflow:visible"
id="marker1345"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1343" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1073" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#2f2f2f"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="294.03577"
inkscape:cy="132.14784"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:pagecheckerboard="false"
units="mm"
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">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.680398;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect833"
width="53.203156"
height="99.187119"
x="39.798038"
y="14.766902" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.680398;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect845"
width="53.203156"
height="99.187119"
x="204.01189"
y="14.766902" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.680398;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect847"
width="53.203156"
height="99.187119"
x="121.1113"
y="14.766902" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect853"
width="32.496605"
height="11.482824"
x="50.151314"
y="25.091484" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect855"
width="32.496605"
height="11.482824"
x="49.647457"
y="46.382851" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect857"
width="32.496605"
height="11.482824"
x="48.86647"
y="88.965683" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect859"
width="32.496605"
height="11.482824"
x="50.000584"
y="67.674217" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect877"
width="32.496605"
height="11.482824"
x="215.36081"
y="26.682007" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect879"
width="32.496605"
height="11.482824"
x="214.85695"
y="47.973373" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect881"
width="32.496605"
height="11.482824"
x="214.07596"
y="90.556221" />
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.904656;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect883"
width="32.496605"
height="11.482824"
x="215.21007"
y="69.264763" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 19.103878,30.432169 31.048358,0.08648"
id="path893"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 19.208101,51.519017 30.441484,0.12621"
id="path895"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 19.207508,72.830702 30.795797,-0.02086"
id="path897"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 19.639113,93.83918 48.872908,93.727557"
id="path899"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 80.324067,36.574308 121.1113,53.391941"
id="path901"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect853"
inkscape:connection-end="#rect847" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 82.144062,54.554286 121.1113,60.382049"
id="path903"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect855"
inkscape:connection-end="#rect847" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 82.497189,71.609542 121.1113,67.317372"
id="path905"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect859"
inkscape:connection-end="#rect847" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 80.741868,88.965683 121.1113,74.13391"
id="path907"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect857"
inkscape:connection-end="#rect847" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 174.31445,60.964566 40.5425,-5.17556"
id="path935"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect847"
inkscape:connection-end="#rect879" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 174.31445,67.74205 40.89562,5.198643"
id="path937"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect847"
inkscape:connection-end="#rect883" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 174.31445,74.644506 41.15859,15.911715"
id="path939"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect847"
inkscape:connection-end="#rect881" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 174.31445,54.233956 42.2124,-16.069125"
id="path941"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect847"
inkscape:connection-end="#rect877" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 257.21439,63.923698 17.00337,0.0079"
id="path947"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="125.76978"
y="66.61837"
id="text951"><tspan
sodipodi:role="line"
id="tspan949"
x="125.76978"
y="66.61837"
style="stroke-width:0.230399;fill:#f9f9f9;">Optimizers</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="58.58448"
y="32.424187"
id="text955"><tspan
sodipodi:role="line"
id="tspan953"
x="58.58448"
y="32.424187"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Clang</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="59.840881"
y="54.154854"
id="text959"><tspan
sodipodi:role="line"
id="tspan957"
x="59.840881"
y="54.154854"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Rust</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="56.326378"
y="75.648979"
id="text963"><tspan
sodipodi:role="line"
id="tspan961"
x="56.326378"
y="75.648979"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Haskell</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="55.91111"
y="96.768547"
id="text967"><tspan
sodipodi:role="line"
id="tspan965"
x="55.91111"
y="96.768547"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Serene</tspan></text>
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="48.082981"
y="11.066843"
id="text971"><tspan
sodipodi:role="line"
id="tspan969"
x="48.082981"
y="11.066843"
style="stroke-width:0.230399;fill:#f9f9f9;">Frontend</tspan></text>
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="213.57785"
y="10.725649"
id="text975"><tspan
sodipodi:role="line"
id="tspan973"
x="213.57785"
y="10.725649"
style="stroke-width:0.230399;fill:#f9f9f9;">Backend</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="224.12849"
y="34.484726"
id="text981"><tspan
sodipodi:role="line"
id="tspan979"
x="224.12849"
y="34.484726"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">ARM</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="225.47711"
y="55.859039"
id="text985"><tspan
sodipodi:role="line"
id="tspan983"
x="225.47711"
y="55.859039"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">X86</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="225.302"
y="77.067497"
id="text989"><tspan
sodipodi:role="line"
id="tspan987"
x="225.302"
y="77.067497"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">PPC</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="225.76587"
y="98.383621"
id="text993"><tspan
sodipodi:role="line"
id="tspan991"
x="225.76587"
y="98.383621"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">WA</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="1.8287945"
y="26.920044"
id="text997"><tspan
sodipodi:role="line"
id="tspan995"
x="1.8287945"
y="26.920044"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="1.8287945"
y="47.655968"
id="text1001"><tspan
sodipodi:role="line"
id="tspan999"
x="1.8287945"
y="47.655968"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="1.8287945"
y="68.852684"
id="text1005"><tspan
sodipodi:role="line"
id="tspan1003"
x="1.8287945"
y="68.852684"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="1.8287945"
y="90.049477"
id="text1009"><tspan
sodipodi:role="line"
id="tspan1007"
x="1.8287945"
y="90.049477"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.230399;fill:#f9f9f9;"
x="260.26126"
y="61.178581"
id="text1013"><tspan
sodipodi:role="line"
id="tspan1011"
x="260.26126"
y="61.178581"
style="font-size:6.14398px;stroke-width:0.230399;fill:#f9f9f9;">Machine Code</tspan></text>
<text
xml:space="preserve"
style="font-size:5.64444px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#f9f9f9;"
x="59.464577"
y="117.82257"
id="text1469"
transform="rotate(-20.430611)"><tspan
sodipodi:role="line"
id="tspan1467"
x="59.464577"
y="117.82257"
style="font-size:5.64444px;stroke-width:0.264583;fill:#f9f9f9;">LLVM IR</tspan></text>
<text
xml:space="preserve"
style="font-size:5.64444px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583;fill:#f9f9f9;"
x="197.69336"
y="11.637094"
id="text1473"
transform="rotate(21.686113)"
inkscape:transform-center-x="0.58506171"
inkscape:transform-center-y="-0.021176311"><tspan
sodipodi:role="line"
id="tspan1471"
x="197.69336"
y="11.637094"
style="font-size:5.64444px;stroke-width:0.264583;fill:#f9f9f9;">LLVM IR</tspan></text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 19 KiB

View File

@ -1,383 +0,0 @@
<?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="319mm"
height="138mm"
viewBox="0 0 318.99999 138"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="llvm.svg"
inkscape:export-filename="/home/lxsameer/llvm.png"
inkscape:export-xdpi="92.360001"
inkscape:export-ydpi="92.360001">
<defs
id="defs2">
<marker
style="overflow:visible"
id="marker1383"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1381" />
</marker>
<marker
style="overflow:visible"
id="marker1361"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1359" />
</marker>
<marker
style="overflow:visible"
id="marker1345"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1343" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill-rule:evenodd;stroke:#000000;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path1073" />
</marker>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#2f2f2f"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="472.50849"
inkscape:cy="266.46612"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
showguides="true"
inkscape:guide-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1064"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="0"
inkscape:pagecheckerboard="false"
units="mm"
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">
<path
style="display:none;fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 274.26769,123.45548 235.03465,76.05329"
id="path1554"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<g
id="g1617"
transform="translate(-3.1077376,-3.3836528)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.307798;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect833"
width="53.575756"
height="20.157219"
x="45.531528"
y="22.062426" />
<path
style="fill:none;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.230399px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="M 278.95952,123.75393 295.96571,123.573"
id="path947"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.230399"
x="54.002769"
y="35.491024"
id="text971"><tspan
sodipodi:role="line"
id="tspan969"
x="54.002769"
y="35.491024"
style="fill:#f9f9f9;stroke-width:0.230399">Frontend</tspan></text>
<text
xml:space="preserve"
style="font-size:9.21593px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.230399"
x="235.41437"
y="125.88704"
id="text975"><tspan
sodipodi:role="line"
id="tspan973"
x="235.41437"
y="125.88704"
style="fill:#f9f9f9;stroke-width:0.230399">Backend</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.230399"
x="5.0139894"
y="29.200495"
id="text997"><tspan
sodipodi:role="line"
id="tspan995"
x="5.0139894"
y="29.200495"
style="font-size:6.14398px;fill:#f9f9f9;stroke-width:0.230399">Source Code</tspan></text>
<text
xml:space="preserve"
style="font-size:6.14398px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.230399"
x="282.008"
y="120.81123"
id="text1013"><tspan
sodipodi:role="line"
id="tspan1011"
x="282.008"
y="120.81123"
style="font-size:6.14398px;fill:#f9f9f9;stroke-width:0.230399">Machine Code</tspan></text>
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.842751;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1493"
width="65.955437"
height="122.74801"
x="128.33922"
y="16.364525" />
<g
id="g1504"
transform="translate(14.81667)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.244213;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1495"
width="40.131203"
height="16.940268"
x="125.274"
y="24.818373" />
<text
xml:space="preserve"
style="font-size:7.05556px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="131.3943"
y="35.853203"
id="text1499"><tspan
sodipodi:role="line"
id="tspan1497"
x="131.3943"
y="35.853203"
style="font-size:7.05556px;fill:#f9f9f9;stroke-width:0.264583">Dialect X</tspan></text>
</g>
<g
id="g1512"
transform="translate(14.81667,22.225012)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.244213;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1506"
width="40.131203"
height="16.940268"
x="125.274"
y="24.818373" />
<text
xml:space="preserve"
style="font-size:7.05556px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="131.3943"
y="35.853203"
id="text1510"><tspan
sodipodi:role="line"
id="tspan1508"
x="131.3943"
y="35.853203"
style="font-size:7.05556px;fill:#f9f9f9;stroke-width:0.264583">Dialect Y</tspan></text>
</g>
<g
id="g1520"
transform="translate(14.81667,43.920858)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.244213;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1514"
width="40.131203"
height="16.940268"
x="125.274"
y="24.818373" />
<text
xml:space="preserve"
style="font-size:7.05556px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="131.3943"
y="35.853203"
id="text1518"><tspan
sodipodi:role="line"
id="tspan1516"
x="131.3943"
y="35.853203"
style="font-size:7.05556px;fill:#f9f9f9;stroke-width:0.264583">Dialect Z</tspan></text>
</g>
<g
id="g1528"
transform="translate(14.81667,88.90005)">
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.244213;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1522"
width="40.131203"
height="16.940268"
x="125.274"
y="26.246077" />
<text
xml:space="preserve"
style="font-size:7.05556px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="145.26199"
y="32.641876"
id="text1526"><tspan
sodipodi:role="line"
id="tspan1524"
x="145.26199"
y="32.641876"
style="font-size:7.05556px;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583">LLVM </tspan><tspan
sodipodi:role="line"
x="145.26199"
y="41.461327"
style="font-size:7.05556px;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583"
id="tspan1530">Dialect</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:0;font-family:Charter;-inkscape-font-specification:Charter;fill:#ffffff;stroke-width:0.264583"
x="143.37328"
y="3.9393847"
id="text1534"><tspan
sodipodi:role="line"
id="tspan1532"
x="143.37328"
y="3.9393847"
style="font-size:22.5778px;line-height:0.35;fill:#ffffff;stroke-width:0.264583">.</tspan><tspan
sodipodi:role="line"
x="143.37328"
y="11.841615"
style="font-size:22.5778px;line-height:0.35;fill:#ffffff;stroke-width:0.264583"
id="tspan1536">.</tspan><tspan
sodipodi:role="line"
x="143.37328"
y="19.743845"
style="font-size:22.5778px;line-height:0.35;fill:#ffffff;stroke-width:0.264583"
id="tspan1538">.</tspan><tspan
sodipodi:role="line"
x="143.37328"
y="20.552401"
style="font-size:22.5778px;line-height:0.35;fill:#ffffff;stroke-width:0.264583"
id="tspan1540" /></text>
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.286366px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 165.40323,34.185302 45.30444,0.06755"
id="path1552"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
</g>
<rect
style="fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:0.307798;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect1542"
width="53.575756"
height="20.157219"
x="225.66211"
y="112.45845" />
<path
style="fill:#ffffff;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 16.152169,31.098656 29.384046,-0.01103"
id="path1546"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0" />
<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.107285,32.490983 40.983385,0.535393"
id="path1548"
inkscape:connector-type="polyline"
inkscape:connector-curvature="0"
inkscape:connection-start="#rect833"
inkscape:connection-end="#g1504" />
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:1.25;font-family:Charter;-inkscape-font-specification:Charter;fill:#f9f9f9;stroke-width:0.264583"
x="138.35216"
y="12.875091"
id="text1558"><tspan
sodipodi:role="line"
id="tspan1556"
x="138.35216"
y="12.875091"
style="fill:#f9f9f9;stroke-width:0.264583">Optimizer</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:0;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="115.36226"
y="41.259983"
id="text1562"><tspan
sodipodi:role="line"
id="tspan1560"
x="115.36226"
y="41.259983"
style="font-size:7.05556px;line-height:1.05;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583">Some</tspan><tspan
sodipodi:role="line"
x="115.36226"
y="48.66832"
style="font-size:7.05556px;line-height:1.05;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583"
id="tspan1564">IR</tspan></text>
<text
xml:space="preserve"
style="font-size:10.5833px;line-height:0;font-family:Charter;-inkscape-font-specification:Charter;stroke-width:0.264583"
x="211.18536"
y="111.30232"
id="text1570"><tspan
sodipodi:role="line"
id="tspan1566"
x="211.18536"
y="111.30232"
style="font-size:7.05556px;line-height:1.05;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583">LLVM</tspan><tspan
sodipodi:role="line"
x="211.18536"
y="118.71066"
style="font-size:7.05556px;line-height:1.05;text-align:center;text-anchor:middle;fill:#f9f9f9;stroke-width:0.264583"
id="tspan1568">IR</tspan></text>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,251 +0,0 @@
<?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>

Before

Width:  |  Height:  |  Size: 9.0 KiB

View File

@ -1,80 +0,0 @@
---
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.

Before

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -1,29 +0,0 @@
---
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

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

View File

@ -1,192 +0,0 @@
---
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

@ -1,18 +0,0 @@
[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;
}

View File

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

View File

@ -1,48 +0,0 @@
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

View File

@ -1,80 +0,0 @@
#+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

View File

@ -1,149 +0,0 @@
{
"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
View File

@ -1,132 +0,0 @@
# 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;
};
};
};
};
};
}

1
include/CMakeLists.txt Normal file
View File

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

11
include/config.h.in Normal file
View File

@ -0,0 +1,11 @@
#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

109
include/serene/context.h Normal file
View File

@ -0,0 +1,109 @@
/* -*- 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

@ -0,0 +1,64 @@
/* -*- 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

31
include/serene/errors.h Normal file
View File

@ -0,0 +1,31 @@
/* -*- 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

@ -0,0 +1,82 @@
/* -*- 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

@ -0,0 +1,83 @@
/* -*- 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

@ -0,0 +1,68 @@
/* -*- 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

@ -0,0 +1,44 @@
/* -*- 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

@ -0,0 +1,79 @@
/* -*- 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

@ -0,0 +1,76 @@
/* -*- 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

@ -0,0 +1,147 @@
/* -*- 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

83
include/serene/exprs/fn.h Normal file
View File

@ -0,0 +1,83 @@
/* -*- 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

@ -0,0 +1,82 @@
/* -*- 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

@ -0,0 +1,69 @@
/* -*- 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

@ -0,0 +1,65 @@
/* -*- 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

@ -0,0 +1,53 @@
/* -*- 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

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

View File

@ -0,0 +1,60 @@
/* -*- 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

107
include/serene/namespace.h Normal file
View File

@ -0,0 +1,107 @@
/* -*- 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

37
include/serene/passes.h Normal file
View File

@ -0,0 +1,37 @@
/* -*- 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

@ -0,0 +1,65 @@
/* -*- 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

@ -0,0 +1,64 @@
/* -*- 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

@ -0,0 +1,106 @@
/* -*- 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

@ -0,0 +1,43 @@
/* -*- 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

@ -0,0 +1,46 @@
/* -*- 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

33
include/serene/serene.h Normal file
View File

@ -0,0 +1,33 @@
/*
* 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

@ -0,0 +1,6 @@
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)
mlir_tablegen(dialect.cpp.inc -gen-dialect-defs)
add_public_tablegen_target(SereneDialectGen)

View File

@ -0,0 +1,42 @@
/* -*- 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

@ -0,0 +1,124 @@
#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

@ -0,0 +1,124 @@
/* -*- 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

@ -0,0 +1,39 @@
/* -*- 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

@ -0,0 +1,45 @@
/* -*- 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

128
include/serene/traits.h Normal file
View File

@ -0,0 +1,128 @@
/* -*- 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

@ -0,0 +1,28 @@
/* -*- 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

@ -0,0 +1,41 @@
/* -*- 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

97
include/serene/utils.h Normal file
View File

@ -0,0 +1,97 @@
/* -*- 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

View File

@ -1,27 +0,0 @@
\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}

View File

@ -1,135 +0,0 @@
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

View File

@ -1,76 +0,0 @@
{ 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;
};
})

View File

@ -1,111 +0,0 @@
# 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

@ -1,27 +0,0 @@
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

View File

@ -1,29 +0,0 @@
# 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

@ -1,69 +0,0 @@
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

@ -1,11 +0,0 @@
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

@ -1,24 +0,0 @@
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

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

View File

@ -1,47 +0,0 @@
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

@ -1,22 +0,0 @@
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 \

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