Skip to content

Commit

Permalink
Merge pull request #164 from asraa:comb-dialect
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 569213837
  • Loading branch information
copybara-github committed Sep 28, 2023
2 parents 6c24366 + 8b443c0 commit 93d62ea
Show file tree
Hide file tree
Showing 12 changed files with 871 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .pre-commit-search-and-replace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@
# filesystem.
- search: '/^#include "mlir\/(?!include\/mlir\/)/'
replacement: '#include "mlir/include/mlir/'
# Same for llvm paths.
- search: '/^#include "llvm\/(?!include\/llvm\/)/'
replacement: '#include "llvm/include/llvm/'
# Ensure that all C++ mlir include paths include a "// from @llvm-project"
# comment import into Google's internal filesystem.
- search: '/^#include ("mlir\/.*")$/'
replacement: '#include \1 // from @llvm-project'
# Same for llvm paths.
- search: '/^#include ("llvm\/.*")$/'
replacement: '#include \1 // from @llvm-project'
140 changes: 140 additions & 0 deletions include/Dialect/Comb/IR/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")

package(
default_applicable_licenses = ["@heir//:license"],
default_visibility = ["//visibility:public"],
)

exports_files(
glob(["*.h"]),
)

td_library(
name = "td_files",
srcs = [
"Comb.td",
"Combinational.td",
],
includes = ["include"],
deps = [
"@llvm-project//mlir:BuiltinDialectTdFiles",
"@llvm-project//mlir:ControlFlowInterfacesTdFiles",
"@llvm-project//mlir:FunctionInterfacesTdFiles",
"@llvm-project//mlir:InferTypeOpInterfaceTdFiles",
"@llvm-project//mlir:OpBaseTdFiles",
"@llvm-project//mlir:SideEffectInterfacesTdFiles",
],
)

gentbl_cc_library(
name = "dialect_inc_gen",
includes = ["include"],
tbl_outs = [
(
[
"-gen-dialect-decls",
"-dialect=comb",
],
"CombDialect.h.inc",
),
(
[
"-gen-dialect-defs",
"-dialect=comb",
],
"CombDialect.cpp.inc",
),
(
["-gen-dialect-doc"],
"CombDialect.md",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "Comb.td",
deps = [
":td_files",
":type_inc_gen",
],
)

gentbl_cc_library(
name = "ops_inc_gen",
includes = ["include"],
tbl_outs = [
(
[
"-gen-op-decls",
],
"Comb.h.inc",
),
(
[
"-gen-op-defs",
],
"Comb.cpp.inc",
),
(
["-gen-op-doc"],
"CombOps.md",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "Comb.td",
deps = [
":dialect_inc_gen",
":td_files",
],
)

gentbl_cc_library(
name = "type_inc_gen",
includes = ["include"],
tbl_outs = [
(
[
"-gen-typedef-decls",
],
"CombTypes.h.inc",
),
(
[
"-gen-typedef-defs",
],
"CombTypes.cpp.inc",
),
(
["-gen-typedef-doc"],
"CombTypes.md",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "Comb.td",
deps = [
":td_files",
],
)

gentbl_cc_library(
name = "enum_inc_gen",
includes = ["include"],
tbl_outs = [
(
[
"-gen-enum-decls",
],
"CombEnums.h.inc",
),
(
[
"-gen-enum-defs",
],
"CombEnums.cpp.inc",
),
],
tblgen = "@llvm-project//mlir:mlir-tblgen",
td_file = "Comb.td",
deps = [
":dialect_inc_gen",
":td_files",
],
)
42 changes: 42 additions & 0 deletions include/Dialect/Comb/IR/Comb.td
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//===- Comb.td - Comb dialect definition --------------------*- 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
//
//===----------------------------------------------------------------------===//
//
// This is the top level file for the Comb dialect.
//
//===----------------------------------------------------------------------===//

#ifndef HEIR_INCLUDE_DIALECT_COMB_COMB_TD
#define HEIR_INCLUDE_DIALECT_COMB_COMB_TD

include "mlir/IR/OpBase.td"
include "mlir/Interfaces/SideEffectInterfaces.td"
include "mlir/IR/OpAsmInterface.td"
include "mlir/IR/SymbolInterfaces.td"

def CombDialect : Dialect {
let name = "comb";

let summary = "Types and operations for comb dialect";
let description = [{
This dialect defines the `comb` dialect, which is intended to be a generic
representation of combinational logic outside of a particular use-case.
}];
let cppNamespace = "::mlir::heir::comb";

// This will be the default after next LLVM bump.
let usePropertiesForAttributes = 1;

}

// Base class for the operation in this dialect.
class CombOp<string mnemonic, list<Trait> traits = []> :
Op<CombDialect, mnemonic, traits>;

include "Combinational.td"

#endif // HEIR_INCLUDE_DIALECT_COMB_COMB_TD
25 changes: 25 additions & 0 deletions include/Dialect/Comb/IR/CombDialect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//===- CombDialect.h - Comb dialect declaration -----------------*- 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
//
//===----------------------------------------------------------------------===//
//
// This file defines the Combinational MLIR dialect.
//
//===----------------------------------------------------------------------===//

#ifndef HEIR_INCLUDE_DIALECT_COMB_COMBDIALECT_H
#define HEIR_INCLUDE_DIALECT_COMB_COMBDIALECT_H

#include "mlir/include/mlir/IR/BuiltinAttributes.h" // from @llvm-project
#include "mlir/include/mlir/IR/Dialect.h" // from @llvm-project

// Pull in the Dialect definition.
#include "include/Dialect/Comb/IR/CombDialect.h.inc"

// Pull in all enum type definitions and utility function declarations.
#include "include/Dialect/Comb/IR/CombEnums.h.inc"

#endif // HEIR_INCLUDE_DIALECT_COMB_COMBDIALECT_H
36 changes: 36 additions & 0 deletions include/Dialect/Comb/IR/CombOps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//===- CombOps.h - Declare Comb dialect operations --------------*- 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
//
//===----------------------------------------------------------------------===//
//
// This file declares the operation classes for the Comb dialect.
//
//===----------------------------------------------------------------------===//

#ifndef HEIR_INCLUDE_DIALECT_COMB_COMBOPS_H
#define HEIR_INCLUDE_DIALECT_COMB_COMBOPS_H

#include "include/Dialect/Comb/IR/CombDialect.h"
#include "mlir/include/mlir/Bytecode/BytecodeOpInterface.h" // from @llvm-project
#include "mlir/include/mlir/IR/BuiltinOps.h" // from @llvm-project
#include "mlir/include/mlir/IR/OpImplementation.h" // from @llvm-project
#include "mlir/include/mlir/Interfaces/FunctionInterfaces.h" // from @llvm-project
#include "mlir/include/mlir/Interfaces/InferTypeOpInterface.h" // from @llvm-project
#include "mlir/include/mlir/Interfaces/SideEffectInterfaces.h" // from @llvm-project
#include "mlir/include/mlir/Support/LLVM.h" // from @llvm-project

namespace llvm {
struct KnownBits;
}

namespace mlir {
class PatternRewriter;
}

#define GET_OP_CLASSES
#include "include/Dialect/Comb/IR/Comb.h.inc"

#endif // HEIR_INCLUDE_DIALECT_COMB_COMBOPS_H
Loading

0 comments on commit 93d62ea

Please sign in to comment.