Skip to content

Commit 6ddf7cf

Browse files
authored
[mlir][bazel] Allow gentbl_cc_library(tbl_outs) to be a dict. (#134271)
This makes the BUILD file shorter and more readable. I will follow up with converting the other instances.
1 parent a1bc979 commit 6ddf7cf

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,10 @@ gentbl_cc_library(
128128

129129
gentbl_cc_library(
130130
name = "TensorEncodingIncGen",
131-
tbl_outs = [
132-
(
133-
["-gen-attr-interface-decls"],
134-
"include/mlir/IR/TensorEncInterfaces.h.inc",
135-
),
136-
(
137-
["-gen-attr-interface-defs"],
138-
"include/mlir/IR/TensorEncInterfaces.cpp.inc",
139-
),
140-
],
131+
tbl_outs = {
132+
"include/mlir/IR/TensorEncInterfaces.h.inc": ["-gen-attr-interface-decls"],
133+
"include/mlir/IR/TensorEncInterfaces.cpp.inc": ["-gen-attr-interface-defs"],
134+
},
141135
tblgen = ":mlir-tblgen",
142136
td_file = "include/mlir/IR/TensorEncoding.td",
143137
deps = [":TensorOpsTdFiles"],

utils/bazel/llvm-project-overlay/mlir/tblgen.bzl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,9 @@ def gentbl_cc_library(
397397
name: The name of the generated cc_library rule for use in dependencies.
398398
tblgen: The binary used to produce the output.
399399
td_file: The primary table definitions file.
400-
tbl_outs: A list of tuples ([opts], out), where each 'opts' is a list of
401-
options passed to tblgen, each option being a string, and 'out' is the
402-
corresponding output file produced.
400+
tbl_outs: Either a dict {out: [opts]} or a list of tuples ([opts], out),
401+
where each 'opts' is a list of options passed to tblgen, each option
402+
being a string, and 'out' is the corresponding output file produced.
403403
td_srcs: See gentbl_rule.td_srcs
404404
includes: See gentbl_rule.includes
405405
deps: See gentbl_rule.deps
@@ -409,6 +409,8 @@ def gentbl_cc_library(
409409
**kwargs: Extra keyword arguments to pass to all generated rules.
410410
"""
411411

412+
if type(tbl_outs) == type({}):
413+
tbl_outs = [(v, k) for k, v in tbl_outs.items()]
412414
filegroup_name = name + "_filegroup"
413415
gentbl_filegroup(
414416
name = filegroup_name,

0 commit comments

Comments
 (0)