blob: f85b21b1db4e5823ba27cc20fa89211e3274d961 [file] [log] [blame]
load("//third_party/flex:flex.bzl", "genlex")
load("//third_party/bison:bison.bzl", "genyacc")
load("//third_party/llvm/llvm-project/mlir:tblgen.bzl", "gentbl")
package(
default_visibility = [":friends"],
)
package_group(
name = "friends",
packages = [
"//learning/brain/experimental/mlir/...",
],
)
filegroup(
name = "LAVMDialectTdFiles",
srcs = [
"LAVMDialect.td",
"//third_party/llvm/llvm-project/mlir:OpBaseTdFiles",
],
)
gentbl(
name = "LAVMDialectIncGen",
tbl_outs = [
(
"-gen-op-decls",
"LAVMDialect.h.inc",
),
(
"-gen-op-defs",
"LAVMDialect.cpp.inc",
),
],
tblgen = "//third_party/llvm/llvm-project/mlir:mlir-tblgen",
td_file = "LAVMDialect.td",
td_srcs = [
":LAVMDialectTdFiles",
],
)
cc_library(
name = "LAVMDialect",
srcs = [
"LAVMDialect.cpp",
],
hdrs = [
"LAVMDialect.h",
],
deps = [
":LAVMDialectIncGen",
"//third_party/llvm/llvm-project/llvm:support",
"//third_party/llvm/llvm-project/mlir:IR",
"//third_party/llvm/llvm-project/mlir:StandardOps",
"//third_party/llvm/llvm-project/mlir:Support",
],
)
cc_library(
name = "LAVMDialectRegistration",
srcs = [
"LAVMDialectRegistration.cpp",
],
deps = [
":LAVMDialect",
"//third_party/llvm/llvm-project/mlir:IR",
],
alwayslink = 1,
)
cc_library(
name = "LAVMTarget",
srcs = [
"LAVMTarget.cpp",
"LAVMTargetParser.cpp",
],
hdrs = [
"LAVMTarget.h",
"Lexer.h",
],
deps = [
":LAVMDialect",
":md_grammar",
"//third_party/llvm/llvm-project/llvm:support",
"//third_party/llvm/llvm-project/mlir:IR",
],
)
gentbl(
name = "LAVMPassIncGen",
tbl_outs = [
(
"-gen-rewriters",
"LAVMPass.cpp.inc",
),
],
tblgen = "//third_party/llvm/llvm-project/mlir:mlir-tblgen",
td_file = "LAVMPass.td",
td_srcs = [
":LAVMDialectTdFiles",
"//third_party/llvm/llvm-project/mlir:StdOpsTdFiles",
],
)
cc_library(
name = "LAVMPass",
srcs = [
"LAVMPass.cpp",
],
deps = [
":LAVMDialect",
":LAVMPassIncGen",
":LAVMTarget",
"//third_party/llvm/llvm-project/llvm:support",
"//third_party/llvm/llvm-project/mlir:IR",
"//third_party/llvm/llvm-project/mlir:Pass",
"//third_party/llvm/llvm-project/mlir:StandardOps",
"//third_party/llvm/llvm-project/mlir:Transforms",
],
alwayslink = 1,
)
cc_library(
name = "LAVMMain",
srcs = [
"LAVMMain.cpp",
],
deps = [
"//third_party/llvm/llvm-project/llvm:support",
"//third_party/llvm/llvm-project/mlir:Parser",
"//third_party/llvm/llvm-project/mlir:Pass",
"//third_party/llvm/llvm-project/mlir:Support",
],
)
cc_binary(
name = "lavm",
deps = [
":LAVMDialectRegistration",
":LAVMMain",
":LAVMPass",
"//learning/brain/experimental/mlir/tpu:op_registration",
"//learning/brain/experimental/mlir/tpu:transforms",
"//third_party/llvm/llvm-project/llvm:support",
"//third_party/llvm/llvm-project/mlir:AllPassesAndDialectsNoRegistration",
"//third_party/llvm/llvm-project/mlir:MlirOptLib",
],
)
# Machine-description grammar (scanning and parsing).
genlex(
name = "md_scanner",
src = "md_scanner.lex",
out = "md_scanner.lex.cpp",
includes = ["md_parser.y.h"],
visibility = ["//visibility:private"],
)
genyacc(
name = "md_parser",
src = "md_parser.y",
header_out = "md_parser.y.h",
source_out = "md_parser.y.cpp",
visibility = ["//visibility:private"],
)
cc_library(
name = "md_grammar",
srcs = [
"md_grammar.cpp",
"md_parser.y.cpp",
"md_scanner.lex.cpp",
],
hdrs = [
"md_grammar.h",
"md_parser.y.h",
],
copts = ["-Wno-implicit-fallthrough"],
visibility = ["//visibility:private"],
)