Skip to content

Commit

Permalink
Added Foo dialect
Browse files Browse the repository at this point in the history
  • Loading branch information
Wheest committed Jan 11, 2024
1 parent 42204c9 commit 7c89cfe
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 0 deletions.
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/CMakeLists.txt
Expand Up @@ -12,6 +12,7 @@ add_subdirectory(ControlFlow)
add_subdirectory(DLTI)
add_subdirectory(EmitC)
add_subdirectory(Func)
add_subdirectory(Foo)
add_subdirectory(GPU)
add_subdirectory(Index)
add_subdirectory(IRDL)
Expand Down
2 changes: 2 additions & 0 deletions mlir/include/mlir/Dialect/Foo/CMakeLists.txt
@@ -0,0 +1,2 @@
add_mlir_dialect(FooOps foo)
add_mlir_doc(FooOps FooOps Dialects/ -gen-dialect-doc -dialect foo)
35 changes: 35 additions & 0 deletions mlir/include/mlir/Dialect/Foo/Foo.h
@@ -0,0 +1,35 @@
//===- Foo.h - Foo dialect ----------------------------------------*- C++-*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef MLIR_DIALECT_FOO_H_
#define MLIR_DIALECT_FOO_H_

#include "mlir/Bytecode/BytecodeOpInterface.h"
#include "mlir/Dialect/Arith/IR/Arith.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/OpImplementation.h"
#include "mlir/Interfaces/InferTypeOpInterface.h"
#include "mlir/Interfaces/SideEffectInterfaces.h"
#include "mlir/Interfaces/VectorInterfaces.h"

//===----------------------------------------------------------------------===//
// Foo Dialect
//===----------------------------------------------------------------------===//

#include "mlir/Dialect/Foo/FooOpsDialect.h.inc"

//===----------------------------------------------------------------------===//
// Foo Dialect Operations
//===----------------------------------------------------------------------===//

#define GET_OP_CLASSES
#include "mlir/Dialect/Foo/FooOps.h.inc"

#endif // MLIR_DIALECT_FOO_H_
18 changes: 18 additions & 0 deletions mlir/include/mlir/Dialect/Foo/FooBase.td
@@ -0,0 +1,18 @@
//===- FooBase.td - Base definitions for foo dialect --------*- tablegen -*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef FOO_BASE
#define FOO_BASE
include "mlir/IR/OpBase.td"
def Foo_Dialect : Dialect {
let name = "foo";
let cppNamespace = "::mlir::foo";
let description = [{
Lorem Ipsum
}];
}
#endif // FOO_BASE
17 changes: 17 additions & 0 deletions mlir/include/mlir/Dialect/Foo/FooOps.td
@@ -0,0 +1,17 @@
//===- FooOps.td - Foo op definitions ----------------------*- tablegen -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef FOO_OPS
#define FOO_OPS

include "mlir/Dialect/Foo/FooBase.td"
include "mlir/Interfaces/InferTypeOpInterface.td"
include "mlir/Interfaces/VectorInterfaces.td"
include "mlir/Interfaces/SideEffectInterfaces.td"

#endif // FOO_OPS
2 changes: 2 additions & 0 deletions mlir/include/mlir/InitAllDialects.h
Expand Up @@ -34,6 +34,7 @@
#include "mlir/Dialect/ControlFlow/Transforms/BufferizableOpInterfaceImpl.h"
#include "mlir/Dialect/DLTI/DLTI.h"
#include "mlir/Dialect/EmitC/IR/EmitC.h"
#include "mlir/Dialect/Foo/Foo.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
#include "mlir/Dialect/GPU/Transforms/BufferDeallocationOpInterfaceImpl.h"
Expand Down Expand Up @@ -112,6 +113,7 @@ inline void registerAllDialects(DialectRegistry &registry) {
complex::ComplexDialect,
DLTIDialect,
emitc::EmitCDialect,
foo::FooDialect,
func::FuncDialect,
gpu::GPUDialect,
index::IndexDialect,
Expand Down
1 change: 1 addition & 0 deletions mlir/lib/Dialect/CMakeLists.txt
Expand Up @@ -12,6 +12,7 @@ add_subdirectory(ControlFlow)
add_subdirectory(DLTI)
add_subdirectory(EmitC)
add_subdirectory(Func)
add_subdirectory(Foo)
add_subdirectory(GPU)
add_subdirectory(Index)
add_subdirectory(IRDL)
Expand Down
14 changes: 14 additions & 0 deletions mlir/lib/Dialect/Foo/CMakeLists.txt
@@ -0,0 +1,14 @@
add_mlir_dialect_library(MLIRFooDialect
FooDialect.cpp

ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/Dialect/Foo

DEPENDS
MLIRFooOpsIncGen

LINK_LIBS PUBLIC
MLIRDialect
MLIRIR
MLIRUBDialect
)
13 changes: 13 additions & 0 deletions mlir/lib/Dialect/Foo/FooDialect.cpp
@@ -0,0 +1,13 @@
#include "mlir/Dialect/Foo/Foo.h"

using namespace mlir;
using namespace mlir::foo;

#include "mlir/Dialect/Foo/FooOpsDialect.cpp.inc"

void mlir::foo::FooDialect::initialize() {
addOperations<
#define GET_OP_LIST
#include "mlir/Dialect/Foo/FooOps.cpp.inc"
>();
}

0 comments on commit 7c89cfe

Please sign in to comment.