Skip to content

Commit f56cccd

Browse files
rupprechtwsmoses
authored andcommitted
[bazel] Fully replace gentbl with gentbl_cc_library
Enzyme uses tablegen generators from both llvm/tblgen.bzl and mlir/tblgen.bzl. This consolidates usage so that we only use one of them (from MLIR). Later we may delete the llvm/tblgen.bzl entirely. This is mostly mechanical, but as a side effect, we need to adjust `includes` to pick up `bundled_includes.h`. It was probably relying on an `includes` config from the llvm/tblgen.bzl implementation that is no longer being provided. See also llvm/llvm-project#124996.
1 parent 8eda577 commit f56cccd

File tree

1 file changed

+64
-88
lines changed

1 file changed

+64
-88
lines changed

enzyme/BUILD

Lines changed: 64 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
load("@llvm-project//llvm:tblgen.bzl", "gentbl")
2-
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
31
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
2+
load("@llvm-project//mlir:tblgen.bzl", "gentbl_cc_library", "td_library")
43

54
licenses(["notice"])
65

@@ -31,92 +30,97 @@ cc_binary(
3130
],
3231
)
3332

34-
gentbl(
33+
td_library(
34+
name = "BlasDerivativesTdFiles",
35+
srcs = ["Enzyme/BlasDerivatives.td"],
36+
)
37+
38+
gentbl_cc_library(
3539
name = "call-derivatives",
3640
tbl_outs = [(
37-
"-gen-call-derivatives",
41+
["-gen-call-derivatives"],
3842
"CallDerivatives.inc",
3943
)],
4044
tblgen = ":enzyme-tblgen",
4145
td_file = "Enzyme/InstructionDerivatives.td",
42-
td_srcs = ["Enzyme/BlasDerivatives.td"],
46+
deps = [":BlasDerivativesTdFiles"],
4347
)
4448

45-
gentbl(
49+
gentbl_cc_library(
4650
name = "inst-derivatives",
4751
tbl_outs = [(
48-
"-gen-inst-derivatives",
52+
["-gen-inst-derivatives"],
4953
"InstructionDerivatives.inc",
5054
)],
5155
tblgen = ":enzyme-tblgen",
5256
td_file = "Enzyme/InstructionDerivatives.td",
53-
td_srcs = ["Enzyme/BlasDerivatives.td"],
57+
deps = [":BlasDerivativesTdFiles"],
5458
)
5559

56-
gentbl(
60+
gentbl_cc_library(
5761
name = "intr-derivatives",
5862
tbl_outs = [(
59-
"-gen-intr-derivatives",
63+
["-gen-intr-derivatives"],
6064
"IntrinsicDerivatives.inc",
6165
)],
6266
tblgen = ":enzyme-tblgen",
6367
td_file = "Enzyme/InstructionDerivatives.td",
64-
td_srcs = ["Enzyme/BlasDerivatives.td"],
68+
deps = [":BlasDerivativesTdFiles"],
6569
)
6670

67-
gentbl(
71+
gentbl_cc_library(
6872
name = "binop-derivatives",
6973
tbl_outs = [(
70-
"-gen-binop-derivatives",
74+
["-gen-binop-derivatives"],
7175
"BinopDerivatives.inc",
7276
)],
7377
tblgen = ":enzyme-tblgen",
7478
td_file = "Enzyme/InstructionDerivatives.td",
75-
td_srcs = ["Enzyme/BlasDerivatives.td"],
79+
deps = [":BlasDerivativesTdFiles"],
7680
)
7781

78-
gentbl(
82+
gentbl_cc_library(
7983
name = "blas-derivatives",
8084
tbl_outs = [(
81-
"-gen-blas-derivatives",
85+
["-gen-blas-derivatives"],
8286
"BlasDerivatives.inc",
8387
)],
8488
tblgen = ":enzyme-tblgen",
8589
td_file = "Enzyme/InstructionDerivatives.td",
86-
td_srcs = ["Enzyme/BlasDerivatives.td"],
90+
deps = [":BlasDerivativesTdFiles"],
8791
)
8892

89-
gentbl(
93+
gentbl_cc_library(
9094
name = "blas-attributor",
9195
tbl_outs = [(
92-
"-update-blas-declarations",
96+
["-update-blas-declarations"],
9397
"BlasAttributor.inc",
9498
)],
9599
tblgen = ":enzyme-tblgen",
96100
td_file = "Enzyme/InstructionDerivatives.td",
97-
td_srcs = ["Enzyme/BlasDerivatives.td"],
101+
deps = [":BlasDerivativesTdFiles"],
98102
)
99103

100-
gentbl(
104+
gentbl_cc_library(
101105
name = "blas-typeanalysis",
102106
tbl_outs = [(
103-
"-gen-blas-typeanalysis",
107+
["-gen-blas-typeanalysis"],
104108
"BlasTA.inc",
105109
)],
106110
tblgen = ":enzyme-tblgen",
107111
td_file = "Enzyme/InstructionDerivatives.td",
108-
td_srcs = ["Enzyme/BlasDerivatives.td"],
112+
deps = [":BlasDerivativesTdFiles"],
109113
)
110114

111-
gentbl(
115+
gentbl_cc_library(
112116
name = "blas-diffuseanalysis",
113117
tbl_outs = [(
114-
"-gen-blas-diffuseanalysis",
118+
["-gen-blas-diffuseanalysis"],
115119
"BlasDiffUse.inc",
116120
)],
117121
tblgen = ":enzyme-tblgen",
118122
td_file = "Enzyme/InstructionDerivatives.td",
119-
td_srcs = ["Enzyme/BlasDerivatives.td"],
123+
deps = [":BlasDerivativesTdFiles"],
120124
)
121125

122126
cc_library(
@@ -142,6 +146,9 @@ cc_library(
142146
"-Wno-return-type",
143147
],
144148
data = ["@llvm-project//clang:builtin_headers_gen"],
149+
includes = [
150+
".", # for bundled_includes.h
151+
],
145152
visibility = ["//visibility:public"],
146153
deps = [
147154
":binop-derivatives",
@@ -235,7 +242,6 @@ td_library(
235242
srcs = [
236243
"Enzyme/MLIR/Dialect/Dialect.td",
237244
],
238-
includes = ["."],
239245
deps = [
240246
"@llvm-project//mlir:ControlFlowInterfacesTdFiles",
241247
"@llvm-project//mlir:FunctionInterfacesTdFiles",
@@ -395,144 +401,114 @@ td_library(
395401
],
396402
)
397403

398-
gentbl(
404+
gentbl_cc_library(
399405
name = "affine-derivatives",
400406
tbl_outs = [(
401-
"-gen-mlir-derivatives",
407+
["-gen-mlir-derivatives"],
402408
"Enzyme/MLIR/Implementations/AffineDerivatives.inc",
403409
)],
404410
tblgen = ":enzyme-tblgen",
405411
td_file = "Enzyme/MLIR/Implementations/AffineDerivatives.td",
406-
td_srcs = [
407-
"Enzyme/MLIR/Implementations/AffineDerivatives.td",
408-
"Enzyme/MLIR/Implementations/Common.td",
409-
],
412+
deps = [":ImplementationsCommonTdFiles"],
410413
)
411414

412-
gentbl(
415+
gentbl_cc_library(
413416
name = "arith-derivatives",
414417
tbl_outs = [(
415-
"-gen-mlir-derivatives",
418+
["-gen-mlir-derivatives"],
416419
"Enzyme/MLIR/Implementations/ArithDerivatives.inc",
417420
)],
418421
tblgen = ":enzyme-tblgen",
419422
td_file = "Enzyme/MLIR/Implementations/ArithDerivatives.td",
420-
td_srcs = [
421-
"Enzyme/MLIR/Implementations/ArithDerivatives.td",
422-
"Enzyme/MLIR/Implementations/Common.td",
423-
],
423+
deps = [":ImplementationsCommonTdFiles"],
424424
)
425425

426-
gentbl(
426+
gentbl_cc_library(
427427
name = "complex-derivatives",
428428
tbl_outs = [(
429-
"-gen-mlir-derivatives",
429+
["-gen-mlir-derivatives"],
430430
"Enzyme/MLIR/Implementations/ComplexDerivatives.inc",
431431
)],
432432
tblgen = ":enzyme-tblgen",
433433
td_file = "Enzyme/MLIR/Implementations/ComplexDerivatives.td",
434-
td_srcs = [
435-
"Enzyme/MLIR/Implementations/ComplexDerivatives.td",
436-
"Enzyme/MLIR/Implementations/Common.td",
437-
],
434+
deps = [":ImplementationsCommonTdFiles"],
438435
)
439436

440-
gentbl(
437+
gentbl_cc_library(
441438
name = "llvm-derivatives",
442439
tbl_outs = [(
443-
"-gen-mlir-derivatives",
440+
["-gen-mlir-derivatives"],
444441
"Enzyme/MLIR/Implementations/LLVMDerivatives.inc",
445442
)],
446443
tblgen = ":enzyme-tblgen",
447444
td_file = "Enzyme/MLIR/Implementations/LLVMDerivatives.td",
448-
td_srcs = [
449-
"Enzyme/MLIR/Implementations/LLVMDerivatives.td",
450-
"Enzyme/MLIR/Implementations/Common.td",
451-
],
445+
deps = [":ImplementationsCommonTdFiles"],
452446
)
453447

454-
gentbl(
448+
gentbl_cc_library(
455449
name = "nvvm-derivatives",
456450
tbl_outs = [(
457-
"-gen-mlir-derivatives",
451+
["-gen-mlir-derivatives"],
458452
"Enzyme/MLIR/Implementations/NVVMDerivatives.inc",
459453
)],
460454
tblgen = ":enzyme-tblgen",
461455
td_file = "Enzyme/MLIR/Implementations/NVVMDerivatives.td",
462-
td_srcs = [
463-
"Enzyme/MLIR/Implementations/NVVMDerivatives.td",
464-
"Enzyme/MLIR/Implementations/Common.td",
465-
],
456+
deps = [":ImplementationsCommonTdFiles"],
466457
)
467458

468-
gentbl(
459+
gentbl_cc_library(
469460
name = "scf-derivatives",
470461
tbl_outs = [(
471-
"-gen-mlir-derivatives",
462+
["-gen-mlir-derivatives"],
472463
"Enzyme/MLIR/Implementations/SCFDerivatives.inc",
473464
)],
474465
tblgen = ":enzyme-tblgen",
475466
td_file = "Enzyme/MLIR/Implementations/SCFDerivatives.td",
476-
td_srcs = [
477-
"Enzyme/MLIR/Implementations/SCFDerivatives.td",
478-
"Enzyme/MLIR/Implementations/Common.td",
479-
],
467+
deps = [":ImplementationsCommonTdFiles"],
480468
)
481469

482-
gentbl(
470+
gentbl_cc_library(
483471
name = "cf-derivatives",
484472
tbl_outs = [(
485-
"-gen-mlir-derivatives",
473+
["-gen-mlir-derivatives"],
486474
"Enzyme/MLIR/Implementations/CFDerivatives.inc",
487475
)],
488476
tblgen = ":enzyme-tblgen",
489477
td_file = "Enzyme/MLIR/Implementations/CFDerivatives.td",
490-
td_srcs = [
491-
"Enzyme/MLIR/Implementations/CFDerivatives.td",
492-
"Enzyme/MLIR/Implementations/Common.td",
493-
],
478+
deps = [":ImplementationsCommonTdFiles"],
494479
)
495480

496-
gentbl(
481+
gentbl_cc_library(
497482
name = "memref-derivatives",
498483
tbl_outs = [(
499-
"-gen-mlir-derivatives",
484+
["-gen-mlir-derivatives"],
500485
"Enzyme/MLIR/Implementations/MemRefDerivatives.inc",
501486
)],
502487
tblgen = ":enzyme-tblgen",
503488
td_file = "Enzyme/MLIR/Implementations/MemRefDerivatives.td",
504-
td_srcs = [
505-
"Enzyme/MLIR/Implementations/MemRefDerivatives.td",
506-
"Enzyme/MLIR/Implementations/Common.td",
507-
],
489+
deps = [":ImplementationsCommonTdFiles"],
508490
)
509491

510-
gentbl(
492+
gentbl_cc_library(
511493
name = "math-derivatives",
512494
tbl_outs = [(
513-
"-gen-mlir-derivatives",
495+
["-gen-mlir-derivatives"],
514496
"Enzyme/MLIR/Implementations/MathDerivatives.inc",
515497
)],
516498
tblgen = ":enzyme-tblgen",
517499
td_file = "Enzyme/MLIR/Implementations/MathDerivatives.td",
518-
td_srcs = [
519-
"Enzyme/MLIR/Implementations/MathDerivatives.td",
520-
"Enzyme/MLIR/Implementations/Common.td",
521-
],
500+
deps = [":ImplementationsCommonTdFiles"],
522501
)
523502

524-
gentbl(
503+
gentbl_cc_library(
525504
name = "func-derivatives",
526505
tbl_outs = [(
527-
"-gen-mlir-derivatives",
506+
["-gen-mlir-derivatives"],
528507
"Enzyme/MLIR/Implementations/FuncDerivatives.inc",
529508
)],
530509
tblgen = ":enzyme-tblgen",
531510
td_file = "Enzyme/MLIR/Implementations/FuncDerivatives.td",
532-
td_srcs = [
533-
"Enzyme/MLIR/Implementations/FuncDerivatives.td",
534-
"Enzyme/MLIR/Implementations/Common.td",
535-
],
511+
deps = [":ImplementationsCommonTdFiles"],
536512
)
537513

538514
cc_library(
@@ -606,8 +582,8 @@ cc_library(
606582
"@llvm-project//mlir:LinalgStructuredOpsIncGen",
607583
"@llvm-project//mlir:LinalgTransforms",
608584
"@llvm-project//mlir:MathDialect",
609-
"@llvm-project//mlir:MemorySlotInterfaces",
610585
"@llvm-project//mlir:MemRefDialect",
586+
"@llvm-project//mlir:MemorySlotInterfaces",
611587
"@llvm-project//mlir:NVVMDialect",
612588
"@llvm-project//mlir:OpenMPDialect",
613589
"@llvm-project//mlir:Pass",

0 commit comments

Comments
 (0)