Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
16d8faa
Update header to <csignal> and use `const`.
ramonasuncion Dec 11, 2025
2f3625c
Remove deprecated Path from RemoveFileOnSignal
ramonasuncion Dec 11, 2025
d4ad0f3
Update generateBinary and helper to modern LLVM
ramonasuncion Dec 11, 2025
fc70c2e
Add header files
ramonasuncion Dec 11, 2025
bb45fb6
Use modern versions to find OS type
ramonasuncion Dec 11, 2025
85052ef
Use getMainExecutable from filesystem
ramonasuncion Dec 11, 2025
0e6d332
Remove the temporary object from generateBinary
ramonasuncion Dec 11, 2025
32fe90b
Use modern features of C++
ramonasuncion Dec 11, 2025
9016c71
Remove namespace to std and use C++ iostream
ramonasuncion Dec 11, 2025
fae00b5
Remove unused header files. Define them in each transition unit.
ramonasuncion Dec 11, 2025
f690e77
Specify a minimum version (a guess?)
ramonasuncion Dec 11, 2025
26c0d39
Don't create unnecessary object
ramonasuncion Dec 11, 2025
e9b63a6
Use standard error_code to fix F_Binary
ramonasuncion Dec 11, 2025
22cc213
Add all missing LLVM related header files from clay.cpp
ramonasuncion Dec 11, 2025
cd1ca33
Rename the dsymutilPath to camelCase
ramonasuncion Dec 11, 2025
cddbd9d
Use standard error_code to fix F_Binary
ramonasuncion Dec 11, 2025
23e2eee
Update clay.cpp: modern llvm migration
ramonasuncion Dec 11, 2025
aa6c366
Remove quotes and export compile commands
ramonasuncion Dec 11, 2025
be072f4
Pass through with clang-tidy on clay.cpp
ramonasuncion Dec 11, 2025
7ea7509
Remove CLAY_CXXFLAGS
ramonasuncion Dec 11, 2025
a2e97ab
Fix the issues with error.cpp (getDebugLineCol still needs work)
ramonasuncion Dec 11, 2025
a8c0747
Fix formatting
ramonasuncion Dec 11, 2025
3c3392b
Remove const ref from llvm::Tripe in clay.cpp
ramonasuncion Dec 12, 2025
ebcf884
Refactor REPL JIT from ExecutionEngine to LLJit framework
ramonasuncion Dec 12, 2025
060cf37
Complete AssertionError
ramonasuncion Dec 13, 2025
7fc9408
Fix warnings with refcounted_ut.cpp
ramonasuncion Dec 13, 2025
4d1531b
Mark getRefCount() with [[nodiscard]]
ramonasuncion Dec 13, 2025
3b5e594
Add missing header for analyzer_op.cpp
ramonasuncion Dec 13, 2025
c26ef44
Fix errors in claydoc.cpp
ramonasuncion Dec 13, 2025
8cd3c15
Small edit in claydoc.hpp with `const`
ramonasuncion Dec 13, 2025
5742811
Fix errors with strings in lambdas.cpp
ramonasuncion Dec 13, 2025
56d5f3b
Update const ref to lambdas.hpp
ramonasuncion Dec 13, 2025
7c04e76
Add printer.hpp header file to analyzer.cpp
ramonasuncion Dec 13, 2025
160c4a3
Update the use of `auto` in lambdas.cpp
ramonasuncion Dec 13, 2025
f91cb78
Remove `const` from `setSearchPath` in loader.hpp
ramonasuncion Dec 13, 2025
924f194
Update `staticPValue` and remove unused header in analyzer.hpp
ramonasuncion Dec 13, 2025
1fb70fd
Fix warnings found in parser.cpp
ramonasuncion Dec 13, 2025
624e359
Add missing printer.hpp header file for invoketables.cpp
ramonasuncion Dec 13, 2025
7d19e8d
Add const ref to header to match definitions
ramonasuncion Dec 13, 2025
7597805
Change out the deprecated isX86_MMXTy call
ramonasuncion Dec 13, 2025
b9e892c
Update the IITDescriptor::Vector case in analyzer.cpp
ramonasuncion Dec 13, 2025
ff31c4c
Fix some ambiguous function calls using const ref in types.cpp
ramonasuncion Dec 13, 2025
52f7b75
Use TrackingMDNodeRef for DISubprogram debug info and fix warnings
ramonasuncion Dec 13, 2025
f561ea2
Apply .get() on buffer in desugar.cpp
ramonasuncion Dec 13, 2025
e3a3f96
Define modern AttributeList and include FoldingSet
ramonasuncion Dec 13, 2025
0ccd673
Add .gitattributes
ramonasuncion Dec 14, 2025
70ccdef
Fix the header situation with llvm in clay.hpp
ramonasuncion Dec 14, 2025
92bc083
Undo mistake of replaceall nullptr
ramonasuncion Dec 14, 2025
d4eff9e
Update .gitattributes to JS
ramonasuncion Dec 14, 2025
097dbc0
Remove const reference on recordType
ramonasuncion Dec 14, 2025
92d3582
Add toString to profiler.cpp
ramonasuncion Dec 14, 2025
6076eb7
Remove const reference from error.cpp
ramonasuncion Dec 14, 2025
47ae5ae
Add type to CreateLoad in codegen_op.cpp
ramonasuncion Dec 14, 2025
fe66014
Use new AtomicOrdering states
ramonasuncion Dec 14, 2025
cc2e897
Use DW_TAG_variable tag instead of old DW_TAG_arg_variable and DW_TAG…
ramonasuncion Dec 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.clay linguist-language=JavaScript
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")

find_package(Git)
Expand Down Expand Up @@ -35,17 +36,20 @@ if(UNIX)
if (NOT ${LLVM_CONFIG_VERSION_RESULT} EQUAL 0)
message(FATAL_ERROR "${LLVM_CONFIG} failed")
endif()
if(LLVM_VERSION VERSION_LESS 18.0)
message(FATAL_ERROR "LLVM 18 or newer is required. Found ${LLVM_VERSION}")
endif()

execute_process(
COMMAND ${LLVM_CONFIG} --cxxflags
OUTPUT_VARIABLE LLVM_CXXFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS}")
set(LLVM_CXXFLAGS ${LLVM_CXXFLAGS})
separate_arguments(LLVM_CXXFLAGS)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LLVM_CXXFLAGS "${LLVM_CXXFLAGS} -O0")
list(APPEND LLVM_CXXFLAGS -O0)
endif()

execute_process(
Expand Down Expand Up @@ -79,7 +83,7 @@ if(UNIX)
OUTPUT_VARIABLE LLVM_INCLUDEDIR
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(LLVM_INCLUDEDIR "${LLVM_INCLUDEDIR}")
set(LLVM_INCLUDEDIR ${LLVM_INCLUDEDIR})

message("-- Using LLVM: ${LLVM_DIR}")
message("-- LLVM include dir: ${LLVM_INCLUDEDIR}")
Expand Down
63 changes: 39 additions & 24 deletions compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,41 +54,56 @@ if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
COMPILE_DEFINITIONS "GIT_ID=\"${GIT_WC_ID}\"")
endif()

# Compiler flags
# Targets
add_library(compiler STATIC ${COMPILER_SOURCES})
add_executable(clay ${CLAY_SOURCES})
add_executable(claydoc ${CLAYDOC_SOURCES})
add_executable(ut ${UT_SOURCES})

# compiler flags
target_compile_options(compiler PRIVATE ${LLVM_CXXFLAGS})
target_compile_options(clay PRIVATE ${LLVM_CXXFLAGS})
target_compile_options(claydoc PRIVATE ${LLVM_CXXFLAGS})
target_compile_options(ut PRIVATE ${LLVM_CXXFLAGS})

# include directories
target_include_directories(compiler PRIVATE ${LLVM_INCLUDEDIR})
target_include_directories(clay PRIVATE ${LLVM_INCLUDEDIR})
target_include_directories(claydoc PRIVATE ${LLVM_INCLUDEDIR})
target_include_directories(ut PRIVATE ${LLVM_INCLUDEDIR})

if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CLAY_CXXFLAGS "${LLVM_CXXFLAGS} -UNDEBUG")
target_compile_definitions(compiler PRIVATE UNDEBUG)
target_compile_definitions(clay PRIVATE UNDEBUG)
target_compile_definitions(claydoc PRIVATE UNDEBUG)
target_compile_definitions(ut PRIVATE UNDEBUG)
else()
set(CLAY_CXXFLAGS "${LLVM_CXXFLAGS} -DNDEBUG")
target_compile_definitions(compiler PRIVATE NDEBUG)
target_compile_definitions(clay PRIVATE NDEBUG)
target_compile_definitions(claydoc PRIVATE NDEBUG)
target_compile_definitions(ut PRIVATE NDEBUG)
endif()
if (NOT MSVC)
set(CLAY_CXXFLAGS "${CLAY_CXXFLAGS} -fexceptions")

if(NOT MSVC)
target_compile_options(compiler PRIVATE -fexceptions)
target_compile_options(clay PRIVATE -fexceptions)
target_compile_options(claydoc PRIVATE -fexceptions)
target_compile_options(ut PRIVATE -fexceptions)
endif()

set(ENABLE_PCH False CACHE BOOL
"Use precompiled headers when building the compiler. (experimental)")
"Use precompiled headers when building the compiler. (experimental)")

if(ENABLE_PCH)
precompile_header(clay.hpp SOURCES pch.cpp "${CLAY_CXXFLAGS}")
precompile_header(clay.hpp SOURCES pch.cpp ${LLVM_CXXFLAGS})
endif(ENABLE_PCH)

# Targets
add_library(compiler STATIC ${COMPILER_SOURCES})
add_executable(clay ${CLAY_SOURCES})
add_executable(claydoc ${CLAYDOC_SOURCES})
add_executable(ut ${UT_SOURCES})

# compiler flags
target_compile_options(compiler PRIVATE "${CLAY_CXXFLAGS}")
target_compile_options(clay PRIVATE "${CLAY_CXXFLAGS}")
target_compile_options(claydoc PRIVATE "${CLAY_CXXFLAGS}")
target_compile_options(ut PRIVATE "${CLAY_CXXFLAGS}")

if (UNIX)
target_link_options(compiler PRIVATE "${LLVM_LDFLAGS}")
target_link_options(clay PRIVATE "${LLVM_LDFLAGS}")
target_link_options(claydoc PRIVATE "${LLVM_LDFLAGS}")
target_link_options(ut PRIVATE "${LLVM_LDFLAGS}")
endif(UNIX)
target_link_options(compiler PRIVATE ${LLVM_LDFLAGS})
target_link_options(clay PRIVATE ${LLVM_LDFLAGS})
target_link_options(claydoc PRIVATE ${LLVM_LDFLAGS})
target_link_options(ut PRIVATE ${LLVM_LDFLAGS})
endif()

# Libraries
target_link_libraries(clay PRIVATE compiler ${LLVM_LIBS})
Expand Down
13 changes: 5 additions & 8 deletions compiler/analyzer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include "clay.hpp"
#include "evaluator.hpp"
#include "codegen.hpp"
Expand Down Expand Up @@ -55,8 +54,7 @@ namespace clay {
params(params), varParam(varParam), expr(expr) {
}

GlobalVariable::~GlobalVariable() {
}
GlobalVariable::~GlobalVariable() = default;

static StatementAnalysis analyzeStatement(StatementPtr stmt, EnvPtr env, AnalysisContext *ctx);

Expand Down Expand Up @@ -219,8 +217,7 @@ namespace clay {
static vector<CompileContextEntry> analysisErrorCompileContext;

struct ClearAnalysisError {
ClearAnalysisError() {
}
ClearAnalysisError() = default;

~ClearAnalysisError() {
analysisErrorLocation = Location();
Expand Down Expand Up @@ -1442,7 +1439,7 @@ namespace clay {
}
return;
case IITDescriptor::MMX:
if (!Ty->isX86_MMXTy()) {
if (!Ty->isX86_AMXTy()) {
errors << "intrinsic argument " << (ai + 1)
<< " must match LLVM MMX type, but got ";
Ty->print(errors);
Expand Down Expand Up @@ -1479,11 +1476,11 @@ namespace clay {
return;
case IITDescriptor::Vector: {
llvm::VectorType *VT = dyn_cast<llvm::VectorType>(Ty);
if (VT == 0) {
if (VT == nullptr) {
errors << "intrinsic argument " << (ai + 1)
<< " must be of an LLVM vector type, but got ";
Ty->print(errors);
} else if (VT->getNumElements() != D.Vector_Width) {
} else if (VT->getElementCount() != D.Vector_Width) {
errors << "intrinsic argument " << (ai + 1)
<< " must be of an LLVM vector type with "
<< D.Vector_Width
Expand Down
5 changes: 2 additions & 3 deletions compiler/analyzer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include "clay.hpp"

// #include "invoketables.hpp"
#include "types.hpp"

namespace clay {
Expand All @@ -24,9 +23,9 @@ namespace clay {
bool staticToCallingConv(ObjectPtr x, CallingConv &out);
CallingConv staticToCallingConv(MultiStaticPtr x, unsigned index);

static inline PVData staticPValue(ObjectPtr x) {
static PVData staticPValue(const ObjectPtr& x) {
const TypePtr t = staticType(x);
return PVData(t, true);
return {t, true};
}

enum BoolKind {
Expand Down
3 changes: 1 addition & 2 deletions compiler/analyzer_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#include "constructors.hpp"
#include "loader.hpp"
#include "env.hpp"

#include "analyzer.hpp"

#include "analyzer_op.hpp"
#include "invoketables.hpp"

namespace clay {
static size_t staticToSizeTOrIntValue(MultiPValue *args, size_t index) {
Expand Down
Loading