Skip to content

Commit ec1d2d3

Browse files
mlir, cpp20
1 parent 2128437 commit ec1d2d3

File tree

107 files changed

+8465
-752
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+8465
-752
lines changed

.clang-tidy

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Checks: '-*,clang-diagnostic-*,misc-*,modernize-*,readability-*,performace-*,cppcoreguidelines-*,cert-*,bugprone-*,-readability-braces-around-statements,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-misc-unused-parameters,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-readability-named-parameter'
1+
Checks: '-*,clang-diagnostic-*,misc-*,modernize-*,readability-*,performace-*,cppcoreguidelines-*,cert-*,bugprone-*,-readability-braces-around-statements,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-owning-memory,-modernize-use-trailing-return-type,-misc-unused-parameters,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-readability-named-parameter,-readability-identifier-length,-modernize-return-braced-init-list'
22
CheckOptions:
33
- key: readability-identifier-naming.ClassCase
44
value: CamelCase

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ tags
99
build
1010
release
1111
.clangd
12+
.cache
1213
.idea
1314

1415
# User-specific stuff

.vimrc

+10-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let CCOMPILER = "gcc"
55
let BUILD_TYPE = "Debug"
66
let EXTRA_CONFIG = ""
77
let GENERATOR = "Ninja"
8-
let TARGET = "parser"
8+
let TARGET = "dialect"
99
let RUN_ARGS = ""
1010
let TEST = g:TARGET . "Test"
1111
let LINKER = "gold"
@@ -14,8 +14,11 @@ let PLOTTER = "./plot.py"
1414

1515
let g:ale_enabled = 0
1616

17-
let DBGLLVM_LOC = "/home/massimo/Documents/Programs/llvmDebug/usr/local/lib/cmake/llvm"
18-
let RELLLVM_LOC = "/usr/local/lib/cmake/llvm"
17+
let DBGLLVM_LOC = "/home/massimo/Documents/llvm-project/install-debug/lib/cmake/llvm"
18+
let RELLLVM_LOC = "/home/massimo/Documents/llvm-project/install-release/lib/cmake/llvm"
19+
20+
let g:ycm_clangd_binary_path = exepath("/home/massimo/llvm_install/bin/clangd")
21+
1922

2023
let g:ctrlp_custom_ignore = '\v[\/](docs|release|build|gli|glbinding|benchmark|googletest|boostGraph|glfw|glm)|(\.(swp|ico|git|svn|lock))$'
2124

@@ -41,7 +44,7 @@ function! s:setType(val, cmakeBuildBir, cCompiler, cppCompiler, buildType, extra
4144
endfunction
4245

4346
function! s:getBuildCommand()
44-
let s:command = "!cmake -DCMAKE_BUILD_TYPE=" . g:BUILD_TYPE . " -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=./install" . " -DCMAKE_C_COMPILER=" . g:CCOMPILER . " -DCMAKE_CXX_COMPILER=" . g:CPPCOMPILER . " -G " . g:GENERATOR . " -DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=" . g:LINKER ."' " . g:EXTRA_CONFIG . " --build ../"
47+
let s:command = "!cmake -DCMAKE_BUILD_TYPE=" . g:BUILD_TYPE . " -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=./install" . " -DCMAKE_C_COMPILER=" . g:CCOMPILER . " -DCMAKE_CXX_COMPILER=" . g:CPPCOMPILER . " -G " . g:GENERATOR . " -DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=" . g:LINKER ."' " . g:EXTRA_CONFIG . " -S ../"
4548
return s:command
4649
endfunction
4750

@@ -121,7 +124,7 @@ function! s:genCoverage()
121124
endfunction
122125

123126
function! s:getFlags(otherArgs, extraCMargs)
124-
let l:ret = '-DCMAKE_CXX_FLAGS="-Werror -Wall -Wextra ' . a:otherArgs . '" '
127+
let l:ret = '-DCMAKE_CXX_FLAGS="' . a:otherArgs . '" '
125128
let l:ret = l:ret . a:extraCMargs
126129
return l:ret
127130
endfunction
@@ -140,8 +143,8 @@ endfunction
140143

141144
let EXTRA_CONFIG = s:getFlags('--coverage', "-DLLVM_DIR=".g:DBGLLVM_LOC)
142145

143-
command! -nargs=0 CMDEBUG call s:setType(0, "build", "gcc", "g++", "Debug", s:getFlags('--coverage ', "-DLLVM_DIR=".g:DBGLLVM_LOC), "Ninja")
144-
command! -nargs=0 CMRELEASE call s:setType(1, "release", "clang", "clang++", "Release", "", "Ninja")
146+
command! -nargs=0 CMDEBUG call s:setType(0, "build", "gcc", "g++", "Debug", s:getFlags('--coverage ', "-DLLVM_DIR=".g:DBGLLVM_LOC . " -DMLIR_DIR=".g:DBGLLVM_LOC . "/../mlir"), "Ninja")
147+
command! -nargs=0 CMRELEASE call s:setType(1, "release", "clang", "clang++", "Release", s:getFlags('', "-DLLVM_DIR=".g:RELLLVM_LOC . " -DMLIR_DIR=".g:RELLLVM_LOC . "/../mlir"), "Ninja")
145148
command! -nargs=0 CMASAN call s:setType(2, "build", "clang", "clang++", "Debug", s:getFlags(' -fsanitize=address -fno-omit-frame-pointer',"-DLLVM_DIR=".g:DBGLLVM_LOC ), "Ninja")
146149
command! -nargs=0 CMFUZZER call s:setType(5, "build", "clang", "clang++", "Debug", s:getFlags('', "-DBUILD_FUZZER=ON"), "Ninja")
147150
command! -nargs=0 CMTSAN call s:setType(3, "build", "clang", "clang++", "Debug", s:getFlags('-fsanitize=thread -O1', "-DLLVM_DIR=".g:DBGLLVM_LOC), "Ninja")

CMakeLists.txt

+21-8
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ SET(gtest_build_tests OFF CACHE INTERNAL "")
1313
SET(gtest_disable_pthreads OFF CACHE INTERNAL "")
1414
SET(gtest_hide_internal_symbols OFF CACHE INTERNAL "")
1515
SET(gtest_force_shared_crt OFF CACHE INTERNAL "")
16+
SET(GTEST_HAS_ABSL OFF CACHE INTERNAL "")
1617

1718
add_subdirectory(googletest)
1819

@@ -24,6 +25,17 @@ SET(BENCHMARK_ENABLE_RELEASE OFF CACHE INTERNAL "")
2425
SET(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE INTERNAL "")
2526
SET(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "")
2627
SET(BENCHMARK_ENABLE_GTEST_TESTS OFF CACHE INTERNAL "")
28+
SET(BENCHMARK_BUILD_32_BITS OFF CACHE INTERNAL "")
29+
SET(BENCHMARK_DOWNLOAD_DEPENDENCIES OFF CACHE INTERNAL "")
30+
SET(BENCHMARK_ENABLE_DOXYGEN OFF CACHE INTERNAL "")
31+
SET(BENCHMARK_ENABLE_ASSEMBLY_TESTS OFF CACHE INTERNAL "")
32+
SET(BENCHMARK_ENABLE_LTO OFF CACHE INTERNAL "")
33+
SET(BENCHMARK_ENABLE_LIBPFM OFF CACHE INTERNAL "")
34+
SET(BENCHMARK_INSTALL_DOCS OFF CACHE INTERNAL "")
35+
SET(BENCHMARK_USE_LIBCXX OFF CACHE INTERNAL "")
36+
SET(BENCHMARK_FORCE_WERROR OFF CACHE INTERNAL "")
37+
SET(BENCHMARK_ENABLE_WERROR ON CACHE INTERNAL "")
38+
SET(BENCHMARK_USE_BUNDLED_GTEST CACHE INTERNAL "")
2739

2840
add_subdirectory(benchmark)
2941

@@ -44,18 +56,19 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
4456
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
4557
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
4658
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
47-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter")
59+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable -Wno-unused-parameter -Wno-comment -Wno-unused-function")
60+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-int-float-conversion")
4861

4962
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
5063

51-
set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
64+
set_tests_properties(${noArgsTests} PROPERTIES TIMEOUT 10)
5265
include(macros.cmake)
5366

5467
find_package(LLVM REQUIRED CONFIG)
55-
add_definitions(${LLVM_DEFINITIONS})
5668
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
5769
include(AddLLVM)
58-
include_directories(${LLVM_INCLUDE_DIRS})
70+
71+
find_package(MLIR REQUIRED CONFIG)
5972

6073
##############################
6174
### Subfolders ###
@@ -76,7 +89,7 @@ if (DOXYGEN_FOUND)
7689
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
7790

7891
# note the option ALL which allows to build the docs together with the application
79-
add_custom_target(doc
92+
add_custom_target(doc
8093
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
8194
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
8295
COMMENT "Generating API documentation with Doxygen"
@@ -99,19 +112,19 @@ if (${CMAKE_CXX_FLAGS} MATCHES ".*--coverage.*")
99112
)
100113

101114
add_custom_command(
102-
OUTPUT filtered.info
115+
OUTPUT filtered.info
103116
COMMAND ${LCOV} --remove ./total.info "/usr/*" "*/googletest/*" "*/build/*" "*/benchmark/*" --output-file ./filtered.info
104117
DEPENDS total.info
105118
VERBATIM)
106119

107120
add_custom_command(
108-
OUTPUT total.info
121+
OUTPUT total.info
109122
COMMAND ${LCOV} --add-tracefile ./base.info --add-tracefile ./test.info --output-file ./total.info
110123
DEPENDS test.info base.info
111124
VERBATIM)
112125

113126
add_custom_command(
114-
OUTPUT test.info
127+
OUTPUT test.info
115128
COMMAND ${LCOV} --capture --directory . --output-file ./test.info
116129
VERBATIM)
117130

benchmark

Submodule benchmark updated 153 files

examples/declaration.rl

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
system call
2+
3+
fun a() -> int:
4+
let a = 0
5+
let b = a + 4
6+
return b
7+
8+
fun main() -> void:
9+
let x = a()

examples/flatt_simple.rl

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
ent Board:
2+
Int[9] slots
3+
Bool playerTurn
4+
5+
fun get(Board b, Int x, Int y) -> Int:
6+
return b.slots[x + (y*3)]
7+
8+
fun set(Board b, Int x, Int y, Int val):
9+
b.slots[x + (y * 3)] = val
10+
11+
fun full(Board b) -> Bool:
12+
let x = 0
13+
let y = 0
14+
15+
while x < 3:
16+
while y < 3:
17+
if b.get(x, y) == 0:
18+
return false
19+
y = y + 1
20+
x = x + 1
21+
22+
return true
23+
24+
fun three_in_a_line_player(Board b, Int player_id) -> Bool:
25+
let x = 0
26+
while x < 3:
27+
if b.get(x, 0) == b.get(x, 1) and b.get(x, 0) == b.get(x, 2) and b.get(x, 0) == player_id:
28+
return true
29+
30+
if b.get(0, x) == b.get(0, x) and b.get(0, x) == b.get(0, x) and b.get(0, x) == player_id:
31+
return true
32+
x = x + 1
33+
34+
if b.get(0, 0) == b.get(1, 1) and b.get(0, 0) == b.get(2, 2) and b.get(0, 0) == player_id:
35+
return true
36+
37+
if b.get(0, 2) == b.get(1, 1) and b.get(0, 2) == b.get(2, 0) and b.get(0, 2) == player_id:
38+
return true
39+
40+
return false
41+
42+
act play():
43+
let b : Board
44+
while !full(b):
45+
act mark(Int x, Int y)
46+
b.set(x, y, int(b.playerTurn) + 1)
47+
48+
if !b.three_in_a_line_player(int(b.playerTurn) + 1):
49+
return
50+
51+
b.playerTurn = !b.playerTurn
52+
53+
fun main() -> Int:
54+
let game = play()
55+
game.mark(0, 0)
56+
game.mark(1, 0)
57+
game.mark(1, 1)
58+
game.mark(2, 0)
59+
game.mark(2, 2)
60+
return int(game.b.three_in_a_line_player(1)) - 1

examples/simple.rl

+40-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,43 @@
1-
system ex
1+
ent Board:
2+
Int[3][3] slots
3+
Bool playerTurn
24

3-
ent example:
4-
float something
55

6-
fun f(float val) -> float:
7-
return val * val
6+
fun full(Board b) -> Bool:
7+
int x = 0
8+
int y = 0
89

9-
fun f2(example val) -> example:
10-
return val
10+
while x < 3:
11+
while y < 3:
12+
if b.slots[x][y] == 0:
13+
return false
14+
y = y + 1
15+
x = x + 1
16+
17+
return true
18+
19+
fun three_in_a_line_player(Board b, int player_id) -> Bool:
20+
int x = 0;
21+
while x < 3:
22+
if b.slots[x][0] == b.slots[x][1] and b.slots[x][0] == b.slots[x][2] and b.slots[x][0] == player_id:
23+
return true
24+
25+
if b.slots[0][x] == b.slots[0][x] and b.slots[0][x] == b.slots[0][x] and b.slots[0][x] == player_id:
26+
return true
27+
x = x + 1
28+
29+
if b.slots[0][0] == b.slots[1][1] and b.slots[0][0] == b.slots[2][2] and b.slots[0][0] == player_id:
30+
return true
31+
32+
if b.slots[0][2] == b.slots[1][1] and b.slots[0][2] == b.slots[2][0] and b.slots[0][2] == player_id:
33+
return true
34+
35+
return false
36+
37+
act play():
38+
let b : Board
39+
while !full(b) and !three_in_a_line_player(b, int(b.playerTurn) + 1) == 0:
40+
await b.mark(int x, int y)
41+
b.slots[x][y] = int(b.playerTurn) + 1
42+
43+
b.playerTurn = !b.playerTurn

googletest

Submodule googletest updated 279 files

lib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ add_subdirectory(utils)
22
add_subdirectory(ast)
33
add_subdirectory(parser)
44
add_subdirectory(lowerer)
5+
add_subdirectory(dialect)

lib/ast/CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
rlcAddLibrary(ast SHARED
1+
rlcAddLibrary(ast SHARED
22
src/Type.cpp
33
src/Constant.cpp
44
src/Call.cpp
55
src/Expression.cpp
6+
src/ArrayAccess.cpp
7+
src/ArgumentDeclaration.cpp
8+
src/ActionDeclaration.cpp
9+
src/ActionDefinition.cpp
610
src/Entity.cpp
711
src/Statement.cpp
812
src/FunctionDefinition.cpp

0 commit comments

Comments
 (0)