llvm/utils/bazel/llvm-project-overlay/mlir/examples/toy/Ch5/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",
        "include/toy/ShapeInferenceInterface.td",
    ],
    includes = ["include"],
    deps = [
        "//mlir:CallInterfacesTdFiles",
        "//mlir:CastInterfacesTdFiles",
        "//mlir:FunctionInterfacesTdFiles",
        "//mlir:OpBaseTdFiles",
        "//mlir:SideEffectInterfacesTdFiles",
    ],
)

gentbl_cc_library(
    name = "ToyInterfacesIncGen",
    tbl_outs = [
        (
            ["-gen-op-interface-decls"],
            "include/toy/ShapeInferenceOpInterfaces.h.inc",
        ),
        (
            ["-gen-op-interface-defs"],
            "include/toy/ShapeInferenceOpInterfaces.cpp.inc",
        ),
    ],
    tblgen = "//mlir:mlir-tblgen",
    td_file = "include/toy/ShapeInferenceInterface.td",
    deps = [":ToyOpsTdFiles"],
)

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"],
)

gentbl_cc_library(
    name = "ToyCombineIncGen",
    strip_include_prefix = "mlir",
    tbl_outs = [
        (
            ["-gen-rewriters"],
            "mlir/ToyCombine.inc",
        ),
    ],
    tblgen = "//mlir:mlir-tblgen",
    td_file = "mlir/ToyCombine.td",
    deps = [":ToyOpsTdFiles"],
)

cc_binary(
    name = "toyc-ch5",
    srcs = [
        "mlir/Dialect.cpp",
        "mlir/LowerToAffineLoops.cpp",
        "mlir/MLIRGen.cpp",
        "mlir/ShapeInferencePass.cpp",
        "mlir/ToyCombine.cpp",
        "parser/AST.cpp",
        "toyc.cpp",
    ] + glob(["include/toy/*.h"]),
    includes = ["include/"],
    deps = [
        ":ToyCombineIncGen",
        ":ToyInterfacesIncGen",
        ":ToyOpsIncGen",
        "//llvm:Support",
        "//mlir:AffineDialect",
        "//mlir:AffineTransforms",
        "//mlir:AllPassesAndDialects",
        "//mlir:Analysis",
        "//mlir:ArithDialect",
        "//mlir:BytecodeReader",
        "//mlir:CallOpInterfaces",
        "//mlir:CastInterfaces",
        "//mlir:FuncDialect",
        "//mlir:FuncExtensions",
        "//mlir:FunctionInterfaces",
        "//mlir:IR",
        "//mlir:InliningUtils",
        "//mlir:MemRefDialect",
        "//mlir:Parser",
        "//mlir:Pass",
        "//mlir:SideEffectInterfaces",
        "//mlir:Support",
        "//mlir:TransformUtils",
        "//mlir:Transforms",
    ],
)