@@ -7,7 +7,16 @@ project(
77 DESCRIPTION "Compiler for the GraphAlg language"
88 LANGUAGES CXX )
99
10- # LLVM
10+ # =============================== BEGIN OPTIONS ================================
11+ # NOTE: If LLVM is built with RTTI disabled (the default), we must also disable
12+ # it. If the LLVM build enables RTTI, we are free to choose.
13+ option (GRAPHALG_ENABLE_RTTI "Enable run time type information" OFF )
14+
15+ option (ENABLE_WASM "Enable wasm-only targets" OFF )
16+ # ================================ END OPTIONS =================================
17+
18+ # ================================= BEGIN LLVM =================================
19+
1120find_package (LLVM REQUIRED CONFIG )
1221message (STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} " )
1322message (STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR} " )
@@ -20,7 +29,9 @@ include(AddLLVM)
2029
2130llvm_map_components_to_libnames (llvm_libs support )
2231
23- # MLIR
32+ # ================================== END LLVM ==================================
33+
34+ # ================================= BEGIN MLIR =================================
2435find_package (MLIR ${LLVM_PACKAGE_VERSION} REQUIRED CONFIG
2536 HINTS "${LLVM_INSTALL_PREFIX} /lib/cmake"
2637)
@@ -35,6 +46,7 @@ if(DEFINED SET_MLIR_TABLEGEN_PATH)
3546endif ()
3647
3748include (AddMLIR )
49+ # ================================== END MLIR ==================================
3850
3951# Directories with MLIR dialects
4052add_subdirectory (include /graphalg )
@@ -87,6 +99,9 @@ target_link_libraries(
8799# Suppress -Wdangling-assignment-gsl for generated code from MLIR tablegen
88100# The warning is triggered by template instantiations in GraphAlgOps.cpp.inc
89101target_compile_options (graphalg_lib PRIVATE -Wno-dangling-assignment-gsl )
102+ if (NOT GRAPHALG_ENABLE_RTTI)
103+ target_compile_options (graphalg_lib PUBLIC -fno-rtti )
104+ endif ()
90105
91106add_library (graphalg_parse STATIC
92107 src/graphalg/parse/Lexer.cpp
@@ -123,17 +138,45 @@ target_link_libraries(graphalg-exec PRIVATE
123138 MLIRParser
124139)
125140
126- set (ENABLE_WASM OFF CACHE BOOL "Enable wasm-only targets" FORCE )
141+ add_executable (graphalg-playground src/graphalg-playground.cpp )
142+ target_link_libraries (graphalg-playground PRIVATE
143+ ${llvm_libs}
144+ graphalg_lib
145+ graphalg_parse
146+ )
127147
128148if (ENABLE_WASM)
129- add_executable (wasm_parse src/wasm_parse.cpp )
130- target_link_libraries (wasm_parse PRIVATE
131- ${llvm_libs}
132- graphalg_lib
133- graphalg_parse
149+ set (PLAYGROUND_EXPORTED_FUNCTIONS
150+ _ga_new
151+ _ga_free
152+ _ga_parse
153+ _ga_diag_count
154+ _ga_diag_line_start
155+ _ga_diag_line_end
156+ _ga_diag_col_start
157+ _ga_diag_col_end
158+ _ga_diag_msg
159+ _ga_desugar
160+ _ga_add_arg
161+ _ga_set_dims
162+ _ga_set_arg_bool
163+ _ga_set_arg_int
164+ _ga_set_arg_real
165+ _ga_evaluate
166+ _ga_get_res_ring
167+ _ga_get_res_rows
168+ _ga_get_res_cols
169+ _ga_get_res_bool
170+ _ga_get_res_int
171+ _ga_get_res_real
172+ _ga_get_res_inf
134173 )
135- target_link_options (wasm_parse PRIVATE
136- -sEXPORTED_FUNCTIONS=_ga_parse
137- -sEXPORTED_RUNTIME_METHODS=cwrap
138- -sMODULARIZE )
174+ string (REPLACE ";" "," PLAYGROUND_EXPORTED_FUNCTIONS_STR "${PLAYGROUND_EXPORTED_FUNCTIONS} " )
175+
176+
177+ target_link_options (graphalg-playground PRIVATE
178+ -sEXPORTED_FUNCTIONS=${PLAYGROUND_EXPORTED_FUNCTIONS_STR}
179+ -sEXPORTED_RUNTIME_METHODS=cwrap,UTF8ToString
180+ -sMODULARIZE
181+ -sEXPORT_ES6 )
139182endif ()
0 commit comments