Skip to content

[mlir][bazel] Allow gentbl_cc_library(tbl_outs) to be a dict. #134271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,10 @@ gentbl_cc_library(

gentbl_cc_library(
name = "TensorEncodingIncGen",
tbl_outs = [
(
["-gen-attr-interface-decls"],
"include/mlir/IR/TensorEncInterfaces.h.inc",
),
(
["-gen-attr-interface-defs"],
"include/mlir/IR/TensorEncInterfaces.cpp.inc",
),
],
tbl_outs = {
"include/mlir/IR/TensorEncInterfaces.h.inc": ["-gen-attr-interface-decls"],
"include/mlir/IR/TensorEncInterfaces.cpp.inc": ["-gen-attr-interface-defs"],
},
tblgen = ":mlir-tblgen",
td_file = "include/mlir/IR/TensorEncoding.td",
deps = [":TensorOpsTdFiles"],
Expand Down
8 changes: 5 additions & 3 deletions utils/bazel/llvm-project-overlay/mlir/tblgen.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ def gentbl_cc_library(
name: The name of the generated cc_library rule for use in dependencies.
tblgen: The binary used to produce the output.
td_file: The primary table definitions file.
tbl_outs: A list of tuples ([opts], out), where each 'opts' is a list of
options passed to tblgen, each option being a string, and 'out' is the
corresponding output file produced.
tbl_outs: Either a dict {out: [opts]} or a list of tuples ([opts], out),
where each 'opts' is a list of options passed to tblgen, each option
being a string, and 'out' is the corresponding output file produced.
td_srcs: See gentbl_rule.td_srcs
includes: See gentbl_rule.includes
deps: See gentbl_rule.deps
Expand All @@ -409,6 +409,8 @@ def gentbl_cc_library(
**kwargs: Extra keyword arguments to pass to all generated rules.
"""

if type(tbl_outs) == type({}):
tbl_outs = [(v, k) for k, v in tbl_outs.items()]
filegroup_name = name + "_filegroup"
gentbl_filegroup(
name = filegroup_name,
Expand Down