llvm/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch2/BUILD.bazel

# Description:
#   MLIR Tutorial

load("//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")

licenses(["notice"])

package(default_visibility = ["//visibility:public"])

td_library(
    name = "ToyOpsTdFiles",
    srcs = [
        "include/toy/Ops.td",
    ],
    includes = ["include"],
    deps = [
        "//mlir:FunctionInterfacesTdFiles",
        "//mlir:OpBaseTdFiles",
        "//mlir:SideEffectInterfacesTdFiles",
    ],
)

gentbl_cc_library(
    name = "ToyOpsIncGen",
    tbl_outs = [
        (
            ["-gen-op-decls"],
            "include/toy/Ops.h.inc",
        ),
        (
            ["-gen-op-defs"],
            "include/toy/Ops.cpp.inc",
        ),
        (
            ["-gen-dialect-decls"],
            "include/toy/Dialect.h.inc",
        ),
        (
            ["-gen-dialect-defs"],
            "include/toy/Dialect.cpp.inc",
        ),
    ],
    tblgen = "//mlir:mlir-tblgen",
    td_file = "include/toy/Ops.td",
    deps = [":ToyOpsTdFiles"],
)

cc_binary(
    name = "toyc-ch2",
    srcs = [
        "mlir/Dialect.cpp",
        "mlir/MLIRGen.cpp",
        "parser/AST.cpp",
        "toyc.cpp",
    ] + glob(["include/toy/*.h"]),
    includes = ["include/"],
    deps = [
        ":ToyOpsIncGen",
        "//llvm:Support",
        "//mlir:Analysis",
        "//mlir:BytecodeReader",
        "//mlir:FunctionInterfaces",
        "//mlir:IR",
        "//mlir:Parser",
        "//mlir:SideEffectInterfaces",
        "//mlir:Support",
    ],
)