Skip to content

Commit a324331

Browse files
committed
fix build issue & cleanup names
1 parent 2e7bb44 commit a324331

File tree

5 files changed

+43
-14
lines changed

5 files changed

+43
-14
lines changed

CMakeLists.txt

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ cmake_minimum_required(VERSION 3.10)
22

33
include(CheckCXXSourceCompiles)
44

5-
set(POLYGEIST_ENABLE_CUDA 0 CACHE BOOL "Enable CUDA frontend and backend")
6-
set(POLYGEIST_ENABLE_ROCM 0 CACHE BOOL "Enable ROCM backend")
5+
set(POLYGEIST_ENABLE_CUDA 0 CACHE BOOL "Enable CUDA compilation support")
76

87
if(POLICY CMP0068)
98
cmake_policy(SET CMP0068 NEW)
@@ -21,16 +20,11 @@ endif()
2120
option(LLVM_INCLUDE_TOOLS "Generate build targets for the LLVM tools." ON)
2221
option(LLVM_BUILD_TOOLS "Build the LLVM tools. If OFF, just generate build targets." ON)
2322

23+
option(ENABLE_SQL "Build SQL dialect" OFF)
24+
2425
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
2526
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
2627

27-
find_program(XXD_BIN xxd)
28-
29-
# TODO should depend on OS
30-
set(POLYGEIST_PGO_DEFAULT_DATA_DIR "/var/tmp/polygeist/pgo/" CACHE STRING "Directory for PGO data")
31-
set(POLYGEIST_PGO_ALTERNATIVE_ENV_VAR "POLYGEIST_PGO_ALTERNATIVE" CACHE STRING "Env var name to specify alternative to profile")
32-
set(POLYGEIST_PGO_DATA_DIR_ENV_VAR "POLYGEIST_PGO_DATA_DIR" CACHE STRING "Env var name to specify PGO data dir")
33-
3428
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
3529
project(polygeist LANGUAGES CXX C)
3630

@@ -112,6 +106,40 @@ set(LLVM_LIT_ARGS "-sv" CACHE STRING "lit default options")
112106
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules")
113107
include(sanitizers)
114108

109+
if (ENABLE_SQL)
110+
include(FetchContent)
111+
include(ExternalProject)
112+
113+
FetchContent_Declare(sqlparser_ext
114+
GIT_REPOSITORY https://github.com/wsmoses/sql-parser
115+
GIT_TAG c2471248cef8cd33081e698e8ac65d691283dbd4
116+
)
117+
118+
FetchContent_GetProperties(sqlparser_ext)
119+
120+
FetchContent_MakeAvailable(sqlparser_ext)
121+
122+
ExternalProject_Add(sqlparser
123+
SOURCE_DIR ${sqlparser_ext_SOURCE_DIR}
124+
INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/sql/install
125+
CONFIGURE_COMMAND ""
126+
BUILD_COMMAND ${CMAKE_COMMAND} -E env
127+
CXX=${CMAKE_CXX_COMPILER}
128+
make static=yes -C ${sqlparser_ext_SOURCE_DIR}
129+
BUILD_IN_SOURCE TRUE
130+
INSTALL_COMMAND ""
131+
BUILD_BYPRODUCTS ${sqlparser_ext_SOURCE_DIR}/libsqlparser.a
132+
)
133+
134+
135+
add_library(sqlparse_lib INTERFACE)
136+
137+
target_include_directories(sqlparse_lib INTERFACE "${sqlparser_ext_SOURCE_DIR}/src")
138+
target_link_libraries(sqlparse_lib INTERFACE ${sqlparser_ext_SOURCE_DIR}/libsqlparser.a)
139+
add_dependencies(sqlparse_lib sqlparser)
140+
141+
endif()
142+
115143
add_subdirectory(include)
116144
add_subdirectory(lib)
117145
add_subdirectory(tools)

include/sql/SQLDialect.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef SQL_DIALECT
10-
#define SQL_DIALECT
9+
#ifndef SQL_DIALECT_H
10+
#define SQL_DIALECT_H
1111

1212
#include "mlir/IR/Dialect.h"
1313

include/sql/SQLOps.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,4 @@ def ResultOp : SQL_Op<"get_result", [Pure]> {
5353
let hasCanonicalizer = 0;
5454
}
5555

56-
57-
#endif
56+
#endif // SQL_OPS

lib/sql/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ MLIRSQLOpsIncGen
1111
LINK_LIBS PUBLIC
1212
MLIRIR
1313
)
14+
15+
add_subdirectory(Passes)

test/polygeist-opt/sql.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: polygeist-opt %s | FileCheck %s
2-
2+
// -lower-sql
33
module {
44
func.func private @run() -> i32 {
55
%c0 = arith.constant 0 : index

0 commit comments

Comments
 (0)