Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 608b1d9
Showing
42 changed files
with
1,124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
cmake_minimum_required(VERSION 3.13.4) | ||
project(mlir-goes-relational LANGUAGES CXX C) | ||
|
||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to") | ||
|
||
find_package(MLIR REQUIRED CONFIG) | ||
|
||
message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}") | ||
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}") | ||
|
||
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin) | ||
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib) | ||
set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR}) | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}") | ||
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") | ||
include(TableGen) | ||
include(AddLLVM) | ||
include(AddMLIR) | ||
include(HandleLLVMOptions) | ||
|
||
include_directories(${LLVM_INCLUDE_DIRS}) | ||
include_directories(${MLIR_INCLUDE_DIRS}) | ||
include_directories(${PROJECT_SOURCE_DIR}/include) | ||
include_directories(${PROJECT_BINARY_DIR}/include) | ||
link_directories(${LLVM_BUILD_LIBRARY_DIR}) | ||
add_definitions(${LLVM_DEFINITIONS}) | ||
set(LLVM_LINK_COMPONENTS | ||
Support | ||
Core | ||
) | ||
|
||
add_subdirectory(include) | ||
add_subdirectory(lib) | ||
|
||
|
||
|
||
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS) | ||
get_property(conversion_libs GLOBAL PROPERTY MLIR_CONVERSION_LIBS) | ||
get_property(translation_libs GLOBAL PROPERTY MLIR_TRANSLATION_LIBS) | ||
|
||
set(LIBS | ||
${dialect_libs} | ||
${conversion_libs} | ||
${translation_libs} | ||
MLIROptLib | ||
MLIRRelAlg | ||
MLIRDB | ||
MLIRIR | ||
MLIRParser | ||
MLIRPass | ||
|
||
MLIRTranslation | ||
MLIRSupport | ||
MLIRAnalysis | ||
MLIRCallInterfaces | ||
MLIRSideEffectInterfaces | ||
MLIRTransforms | ||
) | ||
|
||
|
||
add_llvm_executable(mlir-db-opt mlir-opt.cpp) | ||
target_link_libraries(mlir-db-opt PUBLIC ${LIBS}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module @testmodule { | ||
func @main() -> !db.int { | ||
%0 = db.constant( 2 ) : !db.int | ||
%1 = relalg.basetable @abctable {table_identifier = "abc"} columns: {col1 => @col1({name = "abc", type = !db.int}), col2 => @col2({name = "dupp", type = !db.bool})} | ||
%2 = relalg.selection %1 (%arg0: !relalg.tuple){ | ||
%3 = relalg.getattr %arg0, @abctable::@col1 : !db.int | ||
%4 = db.compare "eq", %0 :!db.int,%3:!db.int | ||
relalg.return %4 : !db.bool | ||
} | ||
return %0 : !db.int | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(mlir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(Dialect) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
add_subdirectory(RelAlg) | ||
add_subdirectory(DB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
set(LLVM_TARGET_DEFINITIONS DBOps.td) | ||
mlir_tablegen(DBOpsDialect.h.inc -gen-dialect-decls) | ||
mlir_tablegen(DBOps.h.inc -gen-op-decls) | ||
mlir_tablegen(DBOps.cpp.inc -gen-op-defs) | ||
mlir_tablegen(DBOpsEnums.h.inc -gen-enum-decls) | ||
mlir_tablegen(DBOpsEnums.cpp.inc -gen-enum-defs) | ||
mlir_tablegen(DBOpsTypes.h.inc --gen-typedef-decls) | ||
mlir_tablegen(DBOpsTypes.cpp.inc --gen-typedef-defs) | ||
|
||
set(LLVM_TARGET_DEFINITIONS DBInterfaces.td) | ||
mlir_tablegen(DBOpsInterfaces.h.inc -gen-op-interface-decls) | ||
mlir_tablegen(DBOpsInterfaces.cpp.inc -gen-op-interface-defs) | ||
add_public_tablegen_target(MLIRDBOpsIncGen) | ||
add_mlir_doc(DBDialect -gen-dialect-doc DBDialect DB/) | ||
add_mlir_doc(DBOps -gen-op-doc DBOps DB/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef DB_DBDIALECT_H | ||
#define DB_DBDIALECT_H | ||
|
||
#include "mlir/IR/Dialect.h" | ||
|
||
#include "mlir/Dialect/DB/IR/DBOpsDialect.h.inc" | ||
|
||
#endif// DB_DBDIALECT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef Interfaces | ||
#define Interfaces | ||
include "mlir/IR/OpBase.td" | ||
|
||
|
||
#endif// Interfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef DB_DBOPS_H | ||
#define DB_DBOPS_H | ||
|
||
|
||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/Interfaces/SideEffectInterfaces.h" | ||
|
||
#include "mlir/Dialect/DB/IR/DBOpsEnums.h" | ||
#include "mlir/Dialect/DB/IR/DBTypes.h" | ||
|
||
#include "mlir/Dialect/DB/IR/DBOpsInterfaces.h" | ||
|
||
|
||
#include "mlir/Dialect/StandardOps/IR/Ops.h" | ||
#include "mlir/IR/Builders.h" | ||
|
||
#define GET_OP_CLASSES | ||
#include "mlir/Dialect/DB/IR/DBOps.h.inc" | ||
|
||
#endif// DB_DBOPS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#ifndef OPS | ||
#define OPS | ||
|
||
include "mlir/IR/OpBase.td" | ||
include "mlir/Interfaces/SideEffectInterfaces.td" | ||
include "mlir/Interfaces/LoopLikeInterface.td" | ||
include "DBInterfaces.td" | ||
|
||
//===----------------------------------------------------------------------===// | ||
// DB dialect definition. | ||
//===----------------------------------------------------------------------===// | ||
|
||
def DB_Dialect : Dialect { | ||
let name = "db"; | ||
let summary = "A db out-of-tree MLIR dialect."; | ||
let description = [{ | ||
This dialect is an example of an out-of-tree MLIR dialect designed to | ||
illustrate the basic setup required to develop MLIR-based tools without | ||
working inside of the LLVM source tree. | ||
}]; | ||
let cppNamespace = "::mlir::db"; | ||
} | ||
|
||
class DB_Op<string mnemonic, list<OpTrait> traits = []> : | ||
Op<DB_Dialect, mnemonic, traits>{ | ||
let printer = [{ return ::print(p, *this); }]; | ||
let parser = [{ return ::parse$cppClass(parser, result); }]; | ||
} | ||
|
||
class DB_Type<string name, string typeMnemonic> : TypeDef<DB_Dialect, name,"::mlir::db::DBType"> { | ||
let mnemonic = typeMnemonic; | ||
} | ||
def DBType : Type<CPred<"$_self.isa<::mlir::db::DBType>()">,"DB dialect type">; | ||
|
||
|
||
def DB_BoolType : DB_Type<"Bool","bool"> { | ||
let summary = "database boolean type"; | ||
} | ||
def DB_IntType : DB_Type<"Int","int"> { | ||
let summary = "database integer type"; | ||
} | ||
|
||
def DB_ConstantOp : DB_Op<"constant", | ||
[ConstantLike, NoSideEffect]> { | ||
let summary = "constant"; | ||
|
||
|
||
let arguments = (ins AnyAttr:$value); | ||
let results = (outs DBType); | ||
|
||
let extraClassDeclaration = [{ | ||
Attribute getValue() { return (*this)->getAttr("value"); } | ||
}]; | ||
|
||
} | ||
|
||
class DB_BinaryOp<string mnemonic, list<OpTrait> traits = []> : | ||
Op<DB_Dialect, mnemonic, | ||
!listconcat(traits, [NoSideEffect, | ||
SameOperandsAndResultType])>,Arguments<(ins DBType:$lhs, DBType:$rhs)> { | ||
let results = (outs AnyType:$result); | ||
let parser = [{ | ||
return impl::parseOneResultSameOperandTypeOp(parser, result); | ||
}]; | ||
|
||
let printer = [{ | ||
return printStandardBinaryOp(this->getOperation(), p); | ||
}]; | ||
} | ||
class DB_UnaryOp<string mnemonic, list<OpTrait> traits = []> : | ||
Op<DB_Dialect, mnemonic, | ||
!listconcat(traits, [NoSideEffect, | ||
SameOperandsAndResultType])>,Arguments<(ins DBType:$val)> { | ||
let results = (outs AnyType:$result); | ||
let parser = [{ | ||
return impl::parseOneResultSameOperandTypeOp(parser, result); | ||
}]; | ||
|
||
let printer = [{ | ||
return printStandardBinaryOp(this->getOperation(), p); | ||
}]; | ||
} | ||
def DB_AddOp : DB_BinaryOp<"add"> {} | ||
def DB_SubOp : DB_BinaryOp<"sub"> {} | ||
def DB_MulOp : DB_BinaryOp<"mul"> {} | ||
def DB_DivOp : DB_BinaryOp<"div"> {} | ||
def DB_ModOp : DB_BinaryOp<"mod"> {} | ||
def DB_NegOp : DB_BinaryOp<"neg"> {} | ||
|
||
def DB_CMP_P_EQ : I64EnumAttrCase<"eq", 0>; | ||
def DB_CMP_P_NE : I64EnumAttrCase<"ne", 1>; | ||
def DB_CMP_P_SLT : I64EnumAttrCase<"slt", 2>; | ||
def DB_CMP_P_SLE : I64EnumAttrCase<"sle", 3>; | ||
def DB_CMP_P_SGT : I64EnumAttrCase<"sgt", 4>; | ||
def DB_CMP_P_SGE : I64EnumAttrCase<"sge", 5>; | ||
def DB_CMP_P_ULT : I64EnumAttrCase<"ult", 6>; | ||
def DB_CMP_P_ULE : I64EnumAttrCase<"ule", 7>; | ||
def DB_CMP_P_UGT : I64EnumAttrCase<"ugt", 8>; | ||
def DB_CMP_P_UGE : I64EnumAttrCase<"uge", 9>; | ||
|
||
def DB_CmpPredicateAttr : I64EnumAttr< | ||
"DBCmpPredicate", "", | ||
[DB_CMP_P_EQ, DB_CMP_P_NE, DB_CMP_P_SLT, DB_CMP_P_SLE, DB_CMP_P_SGT, | ||
DB_CMP_P_SGE, DB_CMP_P_ULT, DB_CMP_P_ULE, DB_CMP_P_UGT, DB_CMP_P_UGE]> { | ||
let cppNamespace = "::mlir::db"; | ||
} | ||
|
||
def DB_CmpOp : DB_Op<"compare", | ||
[NoSideEffect, SameTypeOperands]> { | ||
let summary = "integer comparison operation"; | ||
|
||
let arguments = (ins | ||
DB_CmpPredicateAttr:$predicate, | ||
DBType:$lhs, | ||
DBType:$rhs | ||
); | ||
let results = (outs DB_BoolType:$result); | ||
|
||
let builders = [ | ||
OpBuilderDAG<(ins "CmpIPredicate":$predicate, "Value":$lhs, | ||
"Value":$rhs), [{ | ||
::buildDBCmpOp($_builder, $_state, predicate, lhs, rhs); | ||
}]>]; | ||
|
||
let extraClassDeclaration = [{ | ||
static StringRef getPredicateAttrName() { return "predicate"; } | ||
static CmpIPredicate getPredicateByName(StringRef name); | ||
|
||
CmpIPredicate getPredicate() { | ||
return (CmpIPredicate)(*this)->getAttrOfType<IntegerAttr>( | ||
getPredicateAttrName()).getInt(); | ||
} | ||
}]; | ||
let assemblyFormat = "$predicate `,` $lhs `:` type($lhs) `,` $rhs `:` type($rhs) attr-dict"; | ||
} | ||
#endif// OPS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef DB_DBENUMS_H | ||
#define DB_DBENUMS_H | ||
|
||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
|
||
|
||
#define GET_OP_CLASSES | ||
#include "mlir/Dialect/DB/IR/DBOpsEnums.h.inc" | ||
|
||
#endif// DB_DBENUMS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef DB_DBInterfaces | ||
#define DB_DBInterfaces | ||
|
||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
|
||
|
||
#define GET_OP_CLASSES | ||
#include "mlir/Dialect/DB/IR/DBOpsInterfaces.h.inc" | ||
|
||
#endif// DB_DBInterfaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef MLIR_GOES_RELATIONAL_DBTYPE_H | ||
#define MLIR_GOES_RELATIONAL_DBTYPE_H | ||
|
||
namespace mlir::db{ | ||
class DBType : public mlir::Type { | ||
public: | ||
using Type::Type; | ||
}; | ||
} | ||
|
||
#endif // MLIR_GOES_RELATIONAL_DBTYPE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#ifndef DB_DBTYPES_H | ||
#define DB_DBTYPES_H | ||
|
||
#include "mlir/IR/Dialect.h" | ||
#include "mlir/IR/OpDefinition.h" | ||
#include "mlir/Dialect/DB/IR/DBType.h" | ||
|
||
#define GET_TYPEDEF_CLASSES | ||
#include "mlir/Dialect/DB/IR/DBOpsTypes.h.inc" | ||
|
||
#endif// DB_DBTYPES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#ifndef MLIR_DB_PASSES_H | ||
#define MLIR_DB_PASSES_H | ||
|
||
#include "mlir/Pass/Pass.h" | ||
#include <memory> | ||
|
||
namespace mlir { | ||
namespace db { | ||
std::unique_ptr<Pass> createLowerToLLVMPass(db::Database &db); | ||
}// end namespace db | ||
}// end namespace mlir | ||
|
||
#endif// MLIR_DB_PASSES_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
add_subdirectory(IR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
set(LLVM_TARGET_DEFINITIONS RelAlgOps.td) | ||
mlir_tablegen(RelAlgOpsDialect.h.inc -gen-dialect-decls) | ||
mlir_tablegen(RelAlgOps.h.inc -gen-op-decls) | ||
mlir_tablegen(RelAlgOps.cpp.inc -gen-op-defs) | ||
mlir_tablegen(RelAlgOpsEnums.h.inc -gen-enum-decls) | ||
mlir_tablegen(RelAlgOpsEnums.cpp.inc -gen-enum-defs) | ||
mlir_tablegen(RelAlgOpsTypes.h.inc --gen-typedef-decls) | ||
mlir_tablegen(RelAlgOpsTypes.cpp.inc --gen-typedef-defs) | ||
set(LLVM_TARGET_DEFINITIONS RelAlgInterfaces.td) | ||
mlir_tablegen(RelAlgOpsInterfaces.h.inc -gen-op-interface-decls) | ||
mlir_tablegen(RelAlgOpsInterfaces.cpp.inc -gen-op-interface-defs) | ||
add_public_tablegen_target(MLIRRelAlgOpsIncGen) | ||
add_mlir_doc(RelAlgDialect -gen-dialect-doc RelAlgDialect RelAlg/) | ||
add_mlir_doc(RelAlgOps -gen-op-doc RelAlgOps RelAlg/) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef RelAlg_RelAlgDIALECT_H | ||
#define RelAlg_RelAlgDIALECT_H | ||
|
||
#include "mlir/IR/Dialect.h" | ||
|
||
#include "mlir/Dialect/RelAlg/IR/RelAlgOpsDialect.h.inc" | ||
|
||
#endif// RelAlg_RelAlgDIALECT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef Interfaces | ||
#define Interfaces | ||
include "mlir/IR/OpBase.td" | ||
|
||
|
||
#endif// Interfaces |
Oops, something went wrong.