Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: define Substrait_Attr base class #42

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions include/substrait-mlir/Dialect/Substrait/IR/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ mlir_tablegen(SubstraitEnums.cpp.inc -gen-enum-defs)
add_public_tablegen_target(MLIRSubstraitEnumsIncGen)
add_dependencies(MLIRSubstraitDialect MLIRSubstraitEnumsIncGen)

# Add custom type attributes
set(LLVM_TARGET_DEFINITIONS SubstraitTypes.td)
mlir_tablegen(SubstraitOpsAttrs.h.inc --gen-attrdef-decls)
mlir_tablegen(SubstraitOpsAttrs.cpp.inc --gen-attrdef-defs)
add_public_tablegen_target(MLIRSubstraitAttrsIncGen)
add_dependencies(MLIRSubstraitDialect MLIRSubstraitAttrsIncGen)

set(LLVM_TARGET_DEFINITIONS SubstraitInterfaces.td)
mlir_tablegen(SubstraitOpInterfaces.h.inc -gen-op-interface-decls)
mlir_tablegen(SubstraitOpInterfaces.cpp.inc -gen-op-interface-defs)
Expand Down
3 changes: 3 additions & 0 deletions include/substrait-mlir/Dialect/Substrait/IR/Substrait.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#define GET_TYPEDEF_CLASSES
#include "substrait-mlir/Dialect/Substrait/IR/SubstraitOpsTypes.h.inc" // IWYU: export

#define GET_ATTRDEF_CLASSES
#include "substrait-mlir/Dialect/Substrait/IR/SubstraitOpsAttrs.h.inc" // IWYU: export

#define GET_OP_CLASSES
#include "substrait-mlir/Dialect/Substrait/IR/SubstraitOps.h.inc" // IWYU: export

Expand Down
6 changes: 6 additions & 0 deletions include/substrait-mlir/Dialect/Substrait/IR/SubstraitTypes.td
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class Substrait_Type<string name, string typeMnemonic, list<Trait> traits = []>
let mnemonic = typeMnemonic;
}

// Base class for Substrait dialect attribute types.
class Substrait_Attr<string name, string typeMnemonic, list<Trait> traits = []>
: AttrDef<Substrait_Dialect, name, traits> {
let mnemonic = typeMnemonic;
}

/// Currently supported atomic types. These correspond directly to the types in
/// https://github.com/substrait-io/substrait/blob/main/proto/substrait/type.proto.
// TODO(ingomueller): Add the other low-hanging fruits here.
Expand Down
9 changes: 8 additions & 1 deletion lib/Dialect/Substrait/IR/Substrait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ void SubstraitDialect::initialize() {
#define GET_TYPEDEF_LIST
#include "substrait-mlir/Dialect/Substrait/IR/SubstraitOpsTypes.cpp.inc"
>();
addAttributes<
#define GET_ATTRDEF_LIST
#include "substrait-mlir/Dialect/Substrait/IR/SubstraitOpsAttrs.cpp.inc"
>();
}

#include "substrait-mlir/Dialect/Substrait/IR/SubstraitEnums.cpp.inc"
Expand Down Expand Up @@ -432,8 +436,11 @@ LogicalResult ProjectOp::verifyRegions() {
} // namespace mlir

//===----------------------------------------------------------------------===//
// Substrait types
// Substrait types and attributes
//===----------------------------------------------------------------------===//

#define GET_TYPEDEF_CLASSES
#include "substrait-mlir/Dialect/Substrait/IR/SubstraitOpsTypes.cpp.inc"

#define GET_ATTRDEF_CLASSES
#include "substrait-mlir/Dialect/Substrait/IR/SubstraitOpsAttrs.cpp.inc"
Loading