Refactor the main cmake list file and fix the unused warns
This commit is contained in:
parent
6ef69d329a
commit
225ff6bba1
136
CMakeLists.txt
136
CMakeLists.txt
|
@ -1,3 +1,24 @@
|
|||
# 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.
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
# Project name and a few useful settings. Other commands can pick up the results
|
||||
|
@ -6,13 +27,23 @@ project(Serene
|
|||
DESCRIPTION "Serene language is a modern Lisp."
|
||||
LANGUAGES CXX C)
|
||||
|
||||
# Clangd command file
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
|
||||
|
||||
# Policies ==========================
|
||||
cmake_policy(SET CMP0116 NEW)
|
||||
|
||||
# User Options ======================
|
||||
option(CPP_20_SUPPORT "C++20 Support" OFF)
|
||||
option(SERENE_BUILD_TESTING "Enable tests" OFF)
|
||||
option(SERENE_ENABLE_BUILDID "Enable build id." OFF)
|
||||
option(SERENE_ENABLE_THINLTO "Enable ThisLTO." ON)
|
||||
option(SERENE_ENABLE_ASAN "Enable address sanitizer" ON)
|
||||
option(SERENE_ENABLE_DOCS "Enable document generation" OFF)
|
||||
|
||||
# Only do these if this is the main project, and not if it is included through add_subdirectory
|
||||
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
||||
|
||||
## Settings -----------------------------------------
|
||||
## Settings =======================
|
||||
# specify the C++ standard
|
||||
if (CPP_20_SUPPORT)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
@ -22,50 +53,73 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
|
||||
# Setup the source locations
|
||||
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 -fdebug-prefix-map=$PWD=.")
|
||||
set(CMAKE_LINKER_FLAGS_DEBUG
|
||||
"${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer $ENV{ASAN_FLAG}")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE
|
||||
"${CMAKE_CXX_FLAGS_RELEASE} -O3")
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/scripts/cmake")
|
||||
set(MemoryCheckCommand "valgrind")
|
||||
|
||||
add_compile_options(-fno-rtti)
|
||||
|
||||
configure_file(${INCLUDE_DIR}/serene/config.h.in serene/config.h)
|
||||
|
||||
# Let's nicely support folders in IDEs
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
## Options ------------------------------------------
|
||||
option(ENABLE_LOG "Enable logging" OFF)
|
||||
option(ENABLE_EXPR_LOG "Enable AExpr logging" OFF)
|
||||
option(ENABLE_READER_LOG "Enable reader logging" OFF)
|
||||
option(BUILD_TESTING "Enable tests" OFF)
|
||||
# Setup the basic compiler flags
|
||||
add_compile_options(
|
||||
-Wall
|
||||
-Wextra
|
||||
-Werror
|
||||
-fno-rtti
|
||||
-fno-builtin-strlen
|
||||
|
||||
# Dedicate a section to each function, so the linker
|
||||
# can do a better job on dead code elimination
|
||||
-ffunction-sections
|
||||
-fdata-sections
|
||||
|
||||
include(cotire)
|
||||
include(FetchContent)
|
||||
$<$<CONFIG:DEBUG>:-g3>
|
||||
$<$<CONFIG:DEBUG>:-ggdb>
|
||||
# For the sake of debugging
|
||||
$<$<CONFIG:DEBUG>:-fno-inline>
|
||||
# To make the local ccache happy
|
||||
$<$<CONFIG:DEBUG>:-fdebug-prefix-map=$PWD=.>
|
||||
|
||||
$<$<CONFIG:DEBUG>:-fno-omit-frame-pointer>
|
||||
$<$<CONFIG:RELEASE>:-fomit-frame-pointer>
|
||||
|
||||
$<$<CONFIG:RELEASE>:-O3>
|
||||
)
|
||||
|
||||
add_link_options(
|
||||
# We enforce the lld linker
|
||||
-fuse-ld=lld
|
||||
-fsanitize=address
|
||||
# Do not link against shared libraries
|
||||
#--static
|
||||
)
|
||||
|
||||
if(SERENE_ENABLE_BUILDID)
|
||||
add_link_options(-Wl,--build-id)
|
||||
endif()
|
||||
|
||||
if(SERENE_ENABLE_ASAN)
|
||||
add_compile_options(-fsanitize=address)
|
||||
endif()
|
||||
|
||||
if(SERENE_ENABLE_THINLTO)
|
||||
endif()
|
||||
|
||||
# LLVM setup =========================================
|
||||
find_package(LLVM REQUIRED CONFIG)
|
||||
find_package(MLIR REQUIRED CONFIG)
|
||||
|
||||
message(STATUS "Found LLVM ${LLVM_PAsCKAGE_VERSION}")
|
||||
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
|
||||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
|
||||
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
|
||||
|
||||
|
@ -81,36 +135,42 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|||
include(AddMLIR)
|
||||
include(HandleLLVMOptions)
|
||||
|
||||
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})
|
||||
|
||||
include_directories(${LLVM_INCLUDE_DIRS})
|
||||
|
||||
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
|
||||
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
|
||||
add_definitions(${LLVM_DEFINITIONS_LIST})
|
||||
|
||||
link_directories(${LLVM_BUILD_LIBRARY_DIR})
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
|
||||
llvm_map_components_to_libnames(llvm_libs support core irreader)
|
||||
|
||||
|
||||
|
||||
# Serene Setup ===================================
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
# We don't want the generated files from table gen
|
||||
# to be treated as local since the contain warnings
|
||||
include_directories(SYSTEM ${PROJECT_BINARY_DIR}/include)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include/)
|
||||
|
||||
# The compiled library code is here
|
||||
add_subdirectory(src/serene)
|
||||
|
||||
# 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)
|
||||
if(SERENE_BUILD_TESTING)
|
||||
message("Build the test binary")
|
||||
add_subdirectory(src/tests)
|
||||
endif()
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
if (SERENE_ENABLE_DOCS)
|
||||
# Docs only available if this is the main app
|
||||
|
||||
find_package(Doxygen
|
||||
REQUIRED dot
|
||||
OPTIONAL_COMPONENTS dia)
|
||||
|
@ -121,6 +181,4 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|||
message(STATUS "Doxygen not found, not building docs")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
endif()
|
||||
|
|
|
@ -1,7 +1,26 @@
|
|||
add_executable(serenec serene.cpp)
|
||||
# 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.
|
||||
|
||||
# Make sure to generate files related to the dialects first
|
||||
#add_dependencies(serenec SereneDialectGen)
|
||||
add_executable(serenec serene.cpp)
|
||||
|
||||
if (CPP_20_SUPPORT)
|
||||
target_compile_features(serenec PRIVATE cxx_std_20)
|
||||
|
@ -10,8 +29,6 @@ else()
|
|||
endif()
|
||||
|
||||
|
||||
|
||||
|
||||
target_link_libraries(serenec PRIVATE
|
||||
serene
|
||||
${llvm_libs}
|
||||
|
@ -32,8 +49,8 @@ target_link_libraries(serenec PRIVATE
|
|||
)
|
||||
|
||||
|
||||
target_include_directories(serene SYSTEM PRIVATE $ENV{INCLUDE})
|
||||
#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)
|
||||
#install(FILES "${PROJECT_BINARY_DIR}/config.h" DESTINATION include)
|
||||
|
|
7
builder
7
builder
|
@ -19,8 +19,6 @@ export CXX=$(which clang++)
|
|||
|
||||
export CCACHE_SLOPPINESS="pch_defines,time_macros"
|
||||
# Meke sure to use `lld` linker it faster and has a better UX
|
||||
export LDFLAGS="-fuse-ld=lld"
|
||||
export ASAN_FLAG="-fsanitize=address"
|
||||
export ASAN_OPTIONS=check_initialization_order=1
|
||||
LSAN_OPTIONS=suppressions=$(pwd)/.ignore_sanitize
|
||||
export LSAN_OPTIONS
|
||||
|
@ -28,6 +26,7 @@ export LSAN_OPTIONS
|
|||
# The `builder` script is supposed to be run from the
|
||||
# root of the source tree
|
||||
ROOT_DIR=$(pwd)
|
||||
CMAKEARGS="-DLLVM_PARALLEL_COMPILE_JOBS=7 -DLLVM_PARALLEL_LINK_JOBS=7 "
|
||||
BUILD_DIR=$ROOT_DIR/build
|
||||
ME=$(cd "$(dirname "$0")/." >/dev/null 2>&1 ; pwd -P)
|
||||
|
||||
|
@ -60,8 +59,8 @@ function compile() {
|
|||
function build() {
|
||||
pushed_build
|
||||
echo "Running: "
|
||||
echo "cmake -G Ninja $CMAKE_CCACHE -DCMAKE_BUILD_TYPE=Debug \"$@\" \"$ROOT_DIR\""
|
||||
cmake -G Ninja $CMAKE_CCACHE -DCMAKE_BUILD_TYPE=Debug "$@" "$ROOT_DIR"
|
||||
echo "cmake -G Ninja $CMAKE_CCACHE $CMAKEARGS -DCMAKE_BUILD_TYPE=Debug \"$@\" \"$ROOT_DIR\""
|
||||
cmake -G Ninja $CMAKE_CCACHE $CMAKEARGS -DCMAKE_BUILD_TYPE=Debug "$@" "$ROOT_DIR"
|
||||
cmake --build .
|
||||
popd_build
|
||||
}
|
||||
|
|
8
dev.org
8
dev.org
|
@ -108,7 +108,13 @@ on ADF
|
|||
|
||||
* TODOs
|
||||
** Bootstrap*
|
||||
*** TODO Add the support for =ns-paths= :serenecli:context:
|
||||
*** TODO Investigate the huge size of serenec
|
||||
- Checkout -ffunction-sections -fdata-sections flags of lld
|
||||
*** 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
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "serene/slir/dialect.h"
|
||||
#include "serene/source_mgr.h"
|
||||
|
||||
#include <llvm/ADT/None.h>
|
||||
#include <llvm/ADT/Optional.h>
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/IR/LLVMContext.h>
|
||||
|
@ -118,6 +119,11 @@ public:
|
|||
targetPhase(CompilationPhase::NoOptimization) {
|
||||
mlirContext.getOrLoadDialect<serene::slir::SereneDialect>();
|
||||
mlirContext.getOrLoadDialect<mlir::StandardOpsDialect>();
|
||||
|
||||
// We need to create one empty namespace, so that the JIT can
|
||||
// start it's operation.
|
||||
auto ns = makeNamespace(*this, "serene.user", llvm::None);
|
||||
|
||||
// TODO: Get the crash report path dynamically from the cli
|
||||
// pm.enableCrashReproducerGeneration("/home/lxsameer/mlir.mlir");
|
||||
|
||||
|
|
|
@ -30,9 +30,8 @@
|
|||
#include "serene/exprs/expression.h"
|
||||
#include "serene/exprs/list.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/Support/Error.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -54,10 +53,10 @@ public:
|
|||
|
||||
Call(Call &) = delete;
|
||||
|
||||
ExprType getType() const;
|
||||
std::string toString() const;
|
||||
MaybeNode analyze(SereneContext &);
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &){};
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override{};
|
||||
|
||||
static bool classof(const Expression *e);
|
||||
|
||||
|
|
|
@ -29,9 +29,8 @@
|
|||
#include "serene/errors/error.h"
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/Support/Error.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -53,10 +52,10 @@ public:
|
|||
|
||||
Def(Def &d) = delete;
|
||||
|
||||
ExprType getType() const;
|
||||
std::string toString() const;
|
||||
MaybeNode analyze(SereneContext &);
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &);
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override;
|
||||
|
||||
static bool classof(const Expression *e);
|
||||
|
||||
|
|
|
@ -31,9 +31,8 @@
|
|||
#include "serene/exprs/list.h"
|
||||
#include "serene/namespace.h"
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/Error.h"
|
||||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/Support/Error.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
|
@ -57,10 +56,10 @@ public:
|
|||
|
||||
Fn(Fn &f) = delete;
|
||||
|
||||
ExprType getType() const;
|
||||
std::string toString() const;
|
||||
MaybeNode analyze(SereneContext &);
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &);
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override;
|
||||
|
||||
static bool classof(const Expression *e);
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ public:
|
|||
List(const reader::LocationRange &loc, Node &e);
|
||||
List(const reader::LocationRange &loc, Ast elems);
|
||||
|
||||
ExprType getType() const;
|
||||
std::string toString() const;
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
|
||||
void append(Node);
|
||||
|
||||
|
@ -77,8 +77,8 @@ public:
|
|||
/// by the for loop.
|
||||
std::vector<Node>::iterator end();
|
||||
|
||||
MaybeNode analyze(SereneContext &);
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &){};
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override{};
|
||||
|
||||
~List() = default;
|
||||
|
||||
|
|
|
@ -50,11 +50,11 @@ struct Number : public Expression {
|
|||
bool isFloat)
|
||||
: Expression(loc), value(num), isNeg(isNeg), isFloat(isFloat){};
|
||||
|
||||
ExprType getType() const;
|
||||
std::string toString() const;
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
|
||||
MaybeNode analyze(SereneContext &ctx);
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &);
|
||||
MaybeNode analyze(SereneContext &ctx) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override;
|
||||
|
||||
// TODO: This is horrible, we need to fix it after the mvp
|
||||
int toI64();
|
||||
|
|
|
@ -47,11 +47,11 @@ public:
|
|||
|
||||
Symbol(Symbol &s) : Expression(s.location) { this->name = s.name; }
|
||||
|
||||
ExprType getType() const;
|
||||
std::string toString() const;
|
||||
ExprType getType() const override;
|
||||
std::string toString() const override;
|
||||
|
||||
MaybeNode analyze(SereneContext &);
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &){};
|
||||
MaybeNode analyze(SereneContext &) override;
|
||||
void generateIR(serene::Namespace &, mlir::ModuleOp &) override{};
|
||||
|
||||
~Symbol() = default;
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Commentary:
|
||||
*/
|
||||
|
||||
#ifndef SERENE_JIT_H
|
||||
#define SERENE_JIT_H
|
||||
|
||||
|
@ -153,6 +157,7 @@ public:
|
|||
(void)dummy;
|
||||
return invokePacked(adapterName, argsArray);
|
||||
};
|
||||
|
||||
/// Dump object code to output file `filename`.
|
||||
void dumpToObjectFile(llvm::StringRef filename);
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SERENE_READER_ERRORS_H
|
||||
#define SERENE_READER_ERRORS_H
|
||||
#include "serene/errors.h"
|
||||
|
||||
namespace serene {
|
||||
namespace reader {
|
||||
|
||||
class ReadError : public std::exception {
|
||||
private:
|
||||
char *message;
|
||||
|
||||
public:
|
||||
ReadError(char *msg) : message(msg){};
|
||||
const char *what() const throw() { return message; }
|
||||
};
|
||||
|
||||
class MissingFileError : public llvm::ErrorInfo<MissingFileError> {
|
||||
|
||||
using llvm::ErrorInfo<MissingFileError>::log;
|
||||
using llvm::ErrorInfo<MissingFileError>::convertToErrorCode;
|
||||
|
||||
public:
|
||||
static char ID;
|
||||
std::string path;
|
||||
|
||||
// TODO: Move this to an error namespace somewhere.
|
||||
int file_is_missing = int();
|
||||
|
||||
void log(llvm::raw_ostream &os) const {
|
||||
os << "File does not exist: " << path << "\n";
|
||||
}
|
||||
|
||||
MissingFileError(llvm::StringRef path) : path(path.str()){};
|
||||
std::error_code convertToErrorCode() const {
|
||||
return make_error_code(errc::no_such_file_or_directory);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace reader
|
||||
} // namespace serene
|
||||
#endif
|
|
@ -25,8 +25,7 @@
|
|||
#ifndef SERENE_LOCATION_H
|
||||
#define SERENE_LOCATION_H
|
||||
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
|
||||
#include <mlir/IR/Diagnostics.h>
|
||||
#include <mlir/IR/Location.h>
|
||||
#include <string>
|
||||
|
||||
|
@ -60,7 +59,8 @@ struct Location {
|
|||
llvm::Optional<llvm::StringRef> fname = llvm::None,
|
||||
const char *c = nullptr, unsigned short int line = 0,
|
||||
unsigned short int col = 0, bool knownLocation = true)
|
||||
: ns(ns), filename(fname), c(c), line(line), col(col){};
|
||||
: ns(ns), filename(fname), c(c), line(line), col(col),
|
||||
knownLocation(knownLocation){};
|
||||
|
||||
Location clone();
|
||||
Location clone() const;
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#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"
|
||||
|
||||
|
|
|
@ -1,42 +1,24 @@
|
|||
set(HEADER_LIST
|
||||
"${INCLUDE_DIR}/serene/serene.h"
|
||||
"${INCLUDE_DIR}/serene/utils.h"
|
||||
"${INCLUDE_DIR}/serene/context.h"
|
||||
"${INCLUDE_DIR}/serene/environment.h"
|
||||
"${INCLUDE_DIR}/serene/traits.h"
|
||||
"${INCLUDE_DIR}/serene/diagnostics.h"
|
||||
|
||||
"${INCLUDE_DIR}/serene/exprs/expression.h"
|
||||
"${INCLUDE_DIR}/serene/exprs/symbol.h"
|
||||
"${INCLUDE_DIR}/serene/exprs/list.h"
|
||||
"${INCLUDE_DIR}/serene/exprs/number.h"
|
||||
"${INCLUDE_DIR}/serene/exprs/def.h"
|
||||
"${INCLUDE_DIR}/serene/exprs/fn.h"
|
||||
"${INCLUDE_DIR}/serene/exprs/traits.h"
|
||||
"${INCLUDE_DIR}/serene/exprs/call.h"
|
||||
|
||||
# Reader
|
||||
"${INCLUDE_DIR}/serene/reader/reader.h"
|
||||
"${INCLUDE_DIR}/serene/reader/location.h"
|
||||
"${INCLUDE_DIR}/serene/reader/errors.h"
|
||||
"${INCLUDE_DIR}/serene/reader/semantics.h"
|
||||
"${INCLUDE_DIR}/serene/reader/traits.h"
|
||||
|
||||
"${INCLUDE_DIR}/serene/errors.h"
|
||||
"${INCLUDE_DIR}/serene/errors/error.h"
|
||||
"${INCLUDE_DIR}/serene/errors/errc.h"
|
||||
"${INCLUDE_DIR}/serene/errors/constants.h"
|
||||
"${INCLUDE_DIR}/serene/errors/traits.h"
|
||||
|
||||
|
||||
"${INCLUDE_DIR}/serene/slir/slir.h"
|
||||
"${INCLUDE_DIR}/serene/slir/dialect.h"
|
||||
"${INCLUDE_DIR}/serene/slir/generatable.h"
|
||||
"${INCLUDE_DIR}/serene/slir/utils.h"
|
||||
"${INCLUDE_DIR}/serene/namespace.h"
|
||||
"${INCLUDE_DIR}/serene/jit.h"
|
||||
"${INCLUDE_DIR}/serene/source_mgr.h"
|
||||
"${INCLUDE_DIR}/serene/passes.h")
|
||||
# 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.
|
||||
|
||||
# Make an automatic library - will be static or dynamic based on user setting
|
||||
add_library(serene
|
||||
|
@ -48,7 +30,6 @@ add_library(serene
|
|||
exprs/fn.cpp
|
||||
exprs/call.cpp
|
||||
|
||||
|
||||
context.cpp
|
||||
serene.cpp
|
||||
namespace.cpp
|
||||
|
@ -59,7 +40,6 @@ add_library(serene
|
|||
# Reader
|
||||
reader/reader.cpp
|
||||
reader/location.cpp
|
||||
reader/errors.cpp
|
||||
reader/semantics.cpp
|
||||
|
||||
# Errors
|
||||
|
@ -74,13 +54,12 @@ add_library(serene
|
|||
slir/ops.cpp
|
||||
passes/slir_lowering.cpp
|
||||
passes/to_llvm_dialect.cpp
|
||||
${HEADER_LIST})
|
||||
|
||||
)
|
||||
#${HEADER_LIST}
|
||||
|
||||
# Make sure to generate files related to the dialects first
|
||||
add_dependencies(serene SereneDialectGen)
|
||||
|
||||
|
||||
if (CPP_20_SUPPORT)
|
||||
target_compile_features(serene PUBLIC cxx_std_20)
|
||||
else()
|
||||
|
@ -89,7 +68,7 @@ endif()
|
|||
|
||||
|
||||
# We need this directory, and users of our library will need it too
|
||||
target_include_directories(serene PRIVATE ${INCLUDE_DIR})
|
||||
target_include_directories(serene PUBLIC ${INCLUDE_DIR})
|
||||
target_include_directories(serene PUBLIC ${PROJECT_BINARY_DIR})
|
||||
|
||||
|
||||
|
@ -99,7 +78,7 @@ get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
|
|||
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS)
|
||||
# This depends on (header only) boost
|
||||
target_link_libraries(serene
|
||||
PRIVATE
|
||||
PUBLIC
|
||||
${dialect_libs}
|
||||
${conversion_libs}
|
||||
MLIRAnalysis
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "serene/context.h"
|
||||
#include "serene/reader/location.h"
|
||||
#include "serene/source_mgr.h"
|
||||
#include "serene/utils.h"
|
||||
|
||||
#include <llvm/ADT/StringRef.h>
|
||||
#include <llvm/Support/FormatAdapters.h>
|
||||
|
@ -155,7 +156,10 @@ void Diagnostic::print(llvm::raw_ostream &os, llvm::StringRef prefix) {
|
|||
DiagnosticEngine::DiagnosticEngine(SereneContext &ctx)
|
||||
: ctx(ctx), diagEngine(ctx.mlirContext.getDiagEngine()){};
|
||||
|
||||
void DiagnosticEngine::print(llvm::raw_ostream &os, Diagnostic &d){};
|
||||
void DiagnosticEngine::print(llvm::raw_ostream &os, Diagnostic &d) {
|
||||
UNUSED(os);
|
||||
UNUSED(d);
|
||||
};
|
||||
|
||||
Diagnostic DiagnosticEngine::toDiagnostic(reader::LocationRange loc,
|
||||
errors::ErrorVariant &e,
|
||||
|
|
|
@ -30,10 +30,11 @@
|
|||
#include "serene/exprs/list.h"
|
||||
#include "serene/exprs/symbol.h"
|
||||
#include "serene/reader/semantics.h"
|
||||
#include "serene/utils.h"
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
#include <llvm/Support/Casting.h>
|
||||
#include <llvm/Support/ErrorHandling.h>
|
||||
#include <llvm/Support/FormatVariadic.h>
|
||||
|
||||
namespace serene {
|
||||
namespace exprs {
|
||||
|
@ -45,7 +46,10 @@ std::string Call::toString() const {
|
|||
astToString(&this->params));
|
||||
}
|
||||
|
||||
MaybeNode Call::analyze(SereneContext &ctx) { return EmptyNode; };
|
||||
MaybeNode Call::analyze(SereneContext &ctx) {
|
||||
UNUSED(ctx);
|
||||
return EmptyNode;
|
||||
};
|
||||
|
||||
bool Call::classof(const Expression *e) {
|
||||
return e->getType() == ExprType::Call;
|
||||
|
|
|
@ -45,7 +45,10 @@ std::string Def::toString() const {
|
|||
this->value->toString());
|
||||
}
|
||||
|
||||
MaybeNode Def::analyze(SereneContext &ctx) { return EmptyNode; };
|
||||
MaybeNode Def::analyze(SereneContext &ctx) {
|
||||
UNUSED(ctx);
|
||||
return EmptyNode;
|
||||
};
|
||||
|
||||
bool Def::classof(const Expression *e) {
|
||||
return e->getType() == ExprType::Def;
|
||||
|
|
|
@ -56,7 +56,10 @@ std::string Fn::toString() const {
|
|||
this->body.empty() ? "<>" : astToString(&this->body));
|
||||
}
|
||||
|
||||
MaybeNode Fn::analyze(SereneContext &ctx) { return EmptyNode; };
|
||||
MaybeNode Fn::analyze(SereneContext &ctx) {
|
||||
UNUSED(ctx);
|
||||
return EmptyNode;
|
||||
};
|
||||
|
||||
bool Fn::classof(const Expression *e) { return e->getType() == ExprType::Fn; };
|
||||
|
||||
|
|
|
@ -38,7 +38,10 @@ std::string Number::toString() const {
|
|||
return llvm::formatv("<Number {0}>", value);
|
||||
}
|
||||
|
||||
MaybeNode Number::analyze(SereneContext &ctx) { return EmptyNode; };
|
||||
MaybeNode Number::analyze(SereneContext &ctx) {
|
||||
UNUSED(ctx);
|
||||
return EmptyNode;
|
||||
};
|
||||
|
||||
bool Number::classof(const Expression *e) {
|
||||
return e->getType() == ExprType::Number;
|
||||
|
|
|
@ -26,8 +26,7 @@
|
|||
|
||||
#include "serene/exprs/expression.h"
|
||||
|
||||
#include "llvm/Support/Casting.h"
|
||||
|
||||
#include <llvm/Support/Casting.h>
|
||||
#include <llvm/Support/FormatVariadic.h>
|
||||
|
||||
namespace serene {
|
||||
|
@ -39,7 +38,10 @@ std::string Symbol::toString() const {
|
|||
return llvm::formatv("<Symbol {0}>", this->name);
|
||||
}
|
||||
|
||||
MaybeNode Symbol::analyze(SereneContext &ctx) { return EmptyNode; };
|
||||
MaybeNode Symbol::analyze(SereneContext &ctx) {
|
||||
UNUSED(ctx);
|
||||
return EmptyNode;
|
||||
};
|
||||
|
||||
bool Symbol::classof(const Expression *e) {
|
||||
return e->getType() == ExprType::Symbol;
|
||||
|
|
|
@ -206,6 +206,7 @@ MaybeJIT JIT::make(Namespace &ns,
|
|||
// process and dynamically linked libraries.
|
||||
auto objectLinkingLayerCreator = [&](llvm::orc::ExecutionSession &session,
|
||||
const llvm::Triple &tt) {
|
||||
UNUSED(tt);
|
||||
auto objectLayer =
|
||||
std::make_unique<llvm::orc::RTDyldObjectLinkingLayer>(session, []() {
|
||||
return std::make_unique<llvm::SectionMemoryManager>();
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
/* -*- C++ -*-
|
||||
* Serene programming language.
|
||||
*
|
||||
* Copyright (c) 2019-2021 Sameer Rahmani <lxsameer@gnu.org>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "serene/reader/errors.h"
|
||||
|
||||
namespace serene {
|
||||
namespace reader {
|
||||
/// This one should be here, llvm's rules
|
||||
char MissingFileError::ID;
|
||||
}; // namespace reader
|
||||
}; // namespace serene
|
Loading…
Reference in New Issue