Skip to content

Commit 0572db9

Browse files
committed
init commit for sql dialect
1 parent e5d8b2b commit 0572db9

File tree

13 files changed

+250
-0
lines changed

13 files changed

+250
-0
lines changed

include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
add_subdirectory(polygeist)
2+
add_subdirectory(sql)

include/sql/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
add_mlir_dialect(SQLOps sql)
2+
# add_mlir_doc(SQLDialect -gen-dialect-doc SQLDialect SQL/)
3+
# add_mlir_doc(SQLOps -gen-op-doc SQLOps SQL/)

include/sql/SQLDialect.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//===- BFVDialect.h - BFV dialect -----------------*- C++ -*-===//
2+
//
3+
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef SQL_DIALECT
10+
#define SQL_DIALECT
11+
12+
#include "mlir/IR/Dialect.h"
13+
14+
#include "sql/SQLOpsDialect.h.inc"
15+
16+
#endif

include/sql/SQLDialect.td

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//===- BFVDialect.td - BFV dialect -----------*- tablegen -*-===//
2+
//
3+
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef SQL_DIALECT
10+
#define SQL_DIALECT
11+
12+
13+
include "mlir/IR/OpBase.td"
14+
include "mlir/IR/FunctionInterfaces.td"
15+
include "mlir/IR/SymbolInterfaces.td"
16+
include "mlir/Interfaces/SideEffectInterfaces.td"
17+
18+
include "mlir/Interfaces/CallInterfaces.td"
19+
include "mlir/Interfaces/CastInterfaces.td"
20+
21+
22+
def SQL_Dialect : Dialect {
23+
let summary = "A dialect for SQL languages in MLIR.";
24+
let description = [{
25+
TBD
26+
}];
27+
let name = "sql";
28+
let cppNamespace = "::mlir::sql";
29+
}
30+
31+
32+
//===----------------------------------------------------------------------===//
33+
// SQL Operations
34+
//===----------------------------------------------------------------------===//
35+
36+
class SQL_Op<string mnemonic, list<Trait> traits = []>
37+
: Op<SQL_Dialect, mnemonic, traits>;
38+
39+
#endif // SQL_DIALECT
40+
41+
42+
43+
44+

include/sql/SQLOps.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===- Polygeistps.h - Polygeist dialect ops --------------------*- C++ -*-===//
2+
//
3+
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef SQLOPS_H
10+
#define SQLOPS_H
11+
12+
#include "mlir/IR/BuiltinTypes.h"
13+
#include "mlir/IR/Dialect.h"
14+
#include "mlir/IR/OpDefinition.h"
15+
#include "mlir/IR/PatternMatch.h"
16+
#include "mlir/Interfaces/SideEffectInterfaces.h"
17+
#include "mlir/Interfaces/ViewLikeInterface.h"
18+
#include "llvm/Support/CommandLine.h"
19+
20+
#define GET_OP_CLASSES
21+
#include "sql/SQLOps.h.inc"
22+
23+
#endif

include/sql/SQLOps.td

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//===- SQLOps.td - Polygeist dialect ops ----------------*- tablegen -*-===//
2+
//
3+
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// #ifndef SQL_OPS
10+
// #define SQL_OPS
11+
12+
include "mlir/IR/AttrTypeBase.td"
13+
include "SQLDialect.td"
14+
15+
def SelectOp : SQL_Op<"select", [Pure]> {
16+
let summary = "select";
17+
18+
// TODO: limit (optional), where clauses, join, etc
19+
let arguments = (ins StrArrayAttr:$column, StrAttr:$table);
20+
let results = (outs Index : $result);
21+
22+
let hasFolder = 0;
23+
let hasCanonicalizer = 0;
24+
}
25+
26+
def ExecuteOp : SQL_Op<"execute", []> {
27+
let summary = "execute query";
28+
29+
let arguments = (ins Index:$handle);
30+
let results = (outs Index:$result);
31+
32+
let hasFolder = 0;
33+
let hasCanonicalizer = 0;
34+
}
35+
36+
def NumResultsOp : SQL_Op<"num_results", [Pure]> {
37+
let summary = "number of results";
38+
39+
let arguments = (ins Index:$handle);
40+
let results = (outs Index:$result);
41+
42+
let hasFolder = 0;
43+
let hasCanonicalizer = 0;
44+
}
45+
46+
def ResultOp : SQL_Op<"get_result", [Pure]> {
47+
let summary = "get results of execution";
48+
49+
let arguments = (ins Index:$handle, StrAttr:$column, Index:$row);
50+
let results = (outs AnyType:$result);
51+
52+
let hasFolder = 0;
53+
let hasCanonicalizer = 0;
54+
}
55+
56+
57+
// #endif

lib/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
add_subdirectory(polygeist)
2+
add_subdirectory(sql)

lib/sql/CMakeLists.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
add_mlir_dialect_library(MLIRSQL
2+
Dialect.cpp
3+
Ops.cpp
4+
5+
ADDITIONAL_HEADER_DIRS
6+
${PROJECT_SOURCE_DIR}/include/sql
7+
8+
DEPENDS
9+
MLIRSQLOpsIncGen
10+
11+
LINK_LIBS PUBLIC
12+
MLIRIR
13+
MLIRMemRefDialect
14+
MLIRLLVMDialect
15+
MLIROpenMPDialect
16+
MLIRAffineDialect
17+
MLIRSupport
18+
MLIRSCFTransforms
19+
)

lib/sql/Dialect.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//===- PolygeistDialect.cpp - Polygeist dialect ---------------*- C++ -*-===//
2+
//
3+
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "sql/SQLDialect.h"
10+
#include "mlir/IR/DialectImplementation.h"
11+
#include "sql/SQLOps.h"
12+
13+
using namespace mlir;
14+
using namespace mlir::sql;
15+
16+
//===----------------------------------------------------------------------===//
17+
// Polygeist dialect.
18+
//===----------------------------------------------------------------------===//
19+
20+
void SQLDialect::initialize() {
21+
addOperations<
22+
#define GET_OP_LIST
23+
#include "sql/SQLOps.cpp.inc"
24+
>();
25+
}
26+
27+
#include "sql/SQLOpsDialect.cpp.inc"

lib/sql/Ops.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===- PolygeistOps.cpp - BFV dialect ops ---------------*- C++ -*-===//
2+
//
3+
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "sql/SQLOps.h"
10+
#include "mlir/Dialect/Arith/IR/Arith.h"
11+
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
12+
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
13+
#include "mlir/IR/AffineExpr.h"
14+
#include "mlir/IR/Builders.h"
15+
#include "mlir/IR/OpImplementation.h"
16+
#include "mlir/Interfaces/SideEffectInterfaces.h"
17+
#include "sql/SQLDialect.h"
18+
19+
#define GET_OP_CLASSES
20+
#include "sql/SQLOps.cpp.inc"
21+
22+
#include "mlir/Dialect/Affine/IR/AffineOps.h"
23+
#include "mlir/Dialect/Arith/Utils/Utils.h"
24+
#include "mlir/Dialect/Func/IR/FuncOps.h"
25+
#include "mlir/Dialect/MemRef/IR/MemRef.h"
26+
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
27+
#include "mlir/Dialect/SCF/IR/SCF.h"
28+
#include "mlir/IR/BlockAndValueMapping.h"
29+
#include "mlir/IR/Dominance.h"
30+
#include "mlir/IR/IntegerSet.h"
31+
#include "mlir/Transforms/SideEffectUtils.h"
32+
33+
#include "llvm/ADT/SetVector.h"
34+
#include "llvm/Support/Debug.h"
35+
36+
#define DEBUG_TYPE "sql"
37+
38+
using namespace mlir;
39+
using namespace sql;
40+
using namespace mlir::arith;
41+
42+

0 commit comments

Comments
 (0)