Skip to content

Commit c662687

Browse files
dplassgitcopybara-github
authored andcommitted
[Proc-scoped channels] In ir converter main, if the lower_to_proc_scoped_channels flag is specified at all, use it. Otherwise, use false (instead of the default in ConvertOptions). This will allow targets to force the flag to "false" even if the default is "true".
Updated most BUILD files that use `xls_dslx_ir` or `xls_dslx_opt_ir` to specify the flag as true or false instead of defaulting to the default when it's not specified. PiperOrigin-RevId: 861203007
1 parent 01837c4 commit c662687

File tree

26 files changed

+102
-17
lines changed

26 files changed

+102
-17
lines changed

xls/build_rules/tests/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,12 +296,14 @@ xls_dslx_library(
296296
xls_dslx_ir(
297297
name = "add_one_dslx_ir",
298298
dslx_top = "main",
299+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
299300
library = ":add_one_dslx",
300301
)
301302

302303
xls_dslx_opt_ir(
303304
name = "add_one_dslx_opt_ir",
304305
dslx_top = "main",
306+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
305307
library = ":add_one_dslx",
306308
)
307309

@@ -655,6 +657,7 @@ xls_dslx_opt_ir(
655657
name = "simple_example_5_top_five",
656658
srcs = ["simple_example_five.x"],
657659
dslx_top = "five",
660+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
658661
deps = [":simple_example_4_dslx"],
659662
)
660663

@@ -886,6 +889,7 @@ xls_dslx_opt_ir(
886889
name = "die_if_odd",
887890
srcs = ["die_if_odd.x"],
888891
dslx_top = "die_if_odd",
892+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
889893
ir_file = "die_if_odd.ir",
890894
opt_ir_file = "die_if_odd.opt.ir",
891895
)

xls/dslx/ir_convert/ir_converter_main.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ absl::Status RealMain(absl::Span<const std::string_view> paths) {
101101
bool warnings_as_errors = ir_converter_options.warnings_as_errors();
102102
bool type_inference_v2 = ir_converter_options.type_inference_v2();
103103
bool lower_to_proc_scoped_channels =
104-
ir_converter_options.lower_to_proc_scoped_channels();
104+
ir_converter_options.has_lower_to_proc_scoped_channels()
105+
? ir_converter_options.lower_to_proc_scoped_channels()
106+
: false;
105107
bool force_implicit_token_calling_convention =
106108
ir_converter_options.force_implicit_token_calling_convention();
107109
bool emit_trace = ir_converter_options.emit_trace();

xls/dslx/ir_convert/ir_converter_options_flags.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ absl::StatusOr<bool> SetOptionsFromFlags(IrConverterOptionsFlagsProto& proto) {
112112
any_flags_set |= FLAGS_##__x.IsSpecifiedOnCommandLine(); \
113113
proto.set_##__x(absl::GetFlag(FLAGS_##__x)); \
114114
}
115+
#define POPULATE_FLAG_IF_SPECIFIED(__x) \
116+
{ \
117+
if (FLAGS_##__x.IsSpecifiedOnCommandLine()) { \
118+
any_flags_set = true; \
119+
proto.set_##__x(absl::GetFlag(FLAGS_##__x)); \
120+
} \
121+
}
115122
#define POPULATE_OPTIONAL_FLAG(__x) \
116123
{ \
117124
any_flags_set |= FLAGS_##__x.IsSpecifiedOnCommandLine(); \
@@ -143,7 +150,7 @@ absl::StatusOr<bool> SetOptionsFromFlags(IrConverterOptionsFlagsProto& proto) {
143150
POPULATE_OPTIONAL_FLAG(interface_proto_file);
144151
POPULATE_OPTIONAL_FLAG(interface_textproto_file);
145152
POPULATE_FLAG(type_inference_v2);
146-
POPULATE_FLAG(lower_to_proc_scoped_channels);
153+
POPULATE_FLAG_IF_SPECIFIED(lower_to_proc_scoped_channels);
147154
POPULATE_FLAG(force_implicit_token_calling_convention);
148155
POPULATE_REPEATED_FLAG(configured_values);
149156
POPULATE_FLAG(emit_assert);

xls/dslx/stdlib/BUILD

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ xls_dslx_test(
146146
xls_dslx_opt_ir(
147147
name = "bfloat16_add",
148148
dslx_top = "add",
149+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
149150
ir_file = "bfloat16_add.ir",
150151
library = "bfloat16_dslx",
151152
)
@@ -172,6 +173,7 @@ xls_benchmark_ir(
172173
xls_dslx_opt_ir(
173174
name = "bfloat16_sub",
174175
dslx_top = "sub",
176+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
175177
ir_file = "bfloat16_sub.ir",
176178
library = "bfloat16_dslx",
177179
)
@@ -198,6 +200,7 @@ xls_benchmark_ir(
198200
xls_dslx_opt_ir(
199201
name = "bfloat16_mul",
200202
dslx_top = "mul",
203+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
201204
ir_file = "bfloat16_mul.ir",
202205
library = "bfloat16_dslx",
203206
opt_ir_file = "bfloat16_mul.opt.ir",
@@ -255,6 +258,7 @@ xls_dslx_test(
255258
xls_dslx_opt_ir(
256259
name = "float32_add",
257260
dslx_top = "add",
261+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
258262
ir_file = "float32_add.ir",
259263
library = ":float32_dslx",
260264
opt_ir_file = "float32_add.opt.ir",
@@ -297,6 +301,7 @@ cc_xls_ir_jit_wrapper(
297301
xls_dslx_opt_ir(
298302
name = "float32",
299303
dslx_top = "sub",
304+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
300305
ir_file = "float32_sub.ir",
301306
library = ":float32_dslx",
302307
opt_ir_file = "float32_sub.opt.ir",
@@ -324,6 +329,7 @@ xls_benchmark_ir(
324329
xls_dslx_opt_ir(
325330
name = "float32_mul",
326331
dslx_top = "mul",
332+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
327333
ir_file = "float32_mul.ir",
328334
library = ":float32_dslx",
329335
opt_ir_file = "float32_mul.opt.ir",
@@ -353,6 +359,7 @@ xls_dslx_opt_ir(
353359
name = "float32_to_int32",
354360
srcs = ["float32.x"],
355361
dslx_top = "to_int32",
362+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
356363
deps = [
357364
":apfloat_dslx",
358365
],
@@ -372,6 +379,7 @@ xls_dslx_opt_ir(
372379
name = "float32_from_int32",
373380
srcs = ["float32.x"],
374381
dslx_top = "from_int32",
382+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
375383
deps = [
376384
":apfloat_dslx",
377385
],
@@ -390,6 +398,7 @@ cc_xls_ir_jit_wrapper(
390398
xls_dslx_opt_ir(
391399
name = "float32_fma",
392400
dslx_top = "fma",
401+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
393402
library = ":float32_dslx",
394403
opt_ir_file = "float32_fma.opt.ir",
395404
)
@@ -424,6 +433,7 @@ cc_xls_ir_jit_wrapper(
424433
xls_dslx_opt_ir(
425434
name = "float32_ldexp",
426435
dslx_top = "ldexp",
436+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
427437
ir_file = "float32_ldexp.ir",
428438
library = ":float32_dslx",
429439
opt_ir_file = "float32_ldexp.opt.ir",
@@ -441,6 +451,7 @@ cc_xls_ir_jit_wrapper(
441451
xls_dslx_opt_ir(
442452
name = "float32_fast_rsqrt",
443453
dslx_top = "fast_rsqrt",
454+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
444455
ir_file = "float32_fast_rsqrt.ir",
445456
library = ":float32_dslx",
446457
opt_ir_file = "float32_fast_rsqrt.opt.ir",
@@ -486,6 +497,7 @@ xls_dslx_test(
486497
xls_dslx_opt_ir(
487498
name = "float64_add",
488499
dslx_top = "add",
500+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
489501
ir_file = "float64_add.ir",
490502
library = "float64_dslx",
491503
opt_ir_file = "float64_add.opt.ir",
@@ -514,6 +526,7 @@ cc_xls_ir_jit_wrapper(
514526
xls_dslx_opt_ir(
515527
name = "float64_sub",
516528
dslx_top = "sub",
529+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
517530
ir_file = "float64_sub.ir",
518531
library = ":float64_dslx",
519532
opt_ir_file = "float64_sub.opt.ir",
@@ -534,6 +547,7 @@ xls_benchmark_ir(
534547
xls_dslx_opt_ir(
535548
name = "float64_mul",
536549
dslx_top = "mul",
550+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
537551
ir_file = "float64_mul.ir",
538552
library = ":float64_dslx",
539553
opt_ir_file = "float64_mul.opt.ir",
@@ -562,6 +576,7 @@ cc_xls_ir_jit_wrapper(
562576
xls_dslx_opt_ir(
563577
name = "float64_fma",
564578
dslx_top = "fma",
579+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
565580
ir_file = "float64_fma.ir",
566581
library = ":float64_dslx",
567582
opt_ir_file = "float64_fma.opt.ir",
@@ -591,6 +606,7 @@ cc_xls_ir_jit_wrapper(
591606
xls_dslx_opt_ir(
592607
name = "float32_ceil",
593608
dslx_top = "ceil_with_denorms",
609+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
594610
ir_file = "float32_ceil.ir",
595611
library = ":float32_dslx",
596612
opt_ir_file = "float32_ceil.opt.ir",
@@ -608,6 +624,7 @@ cc_xls_ir_jit_wrapper(
608624
xls_dslx_opt_ir(
609625
name = "float32_floor",
610626
dslx_top = "floor_with_denorms",
627+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
611628
ir_file = "float32_floor.ir",
612629
library = ":float32_dslx",
613630
opt_ir_file = "float32_floor.opt.ir",
@@ -625,6 +642,7 @@ cc_xls_ir_jit_wrapper(
625642
xls_dslx_opt_ir(
626643
name = "float32_trunc",
627644
dslx_top = "trunc",
645+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
628646
ir_file = "float32_trunc.ir",
629647
library = ":float32_dslx",
630648
opt_ir_file = "float32_trunc.opt.ir",

xls/dslx/stdlib/tests/BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ xls_dslx_opt_ir(
3838
name = "umul_with_overflow_21_21_18",
3939
srcs = ["umul_instances.x"],
4040
dslx_top = "umul_with_overflow_21_21_18",
41+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
4142
)
4243

4344
cc_xls_ir_jit_wrapper(
@@ -54,6 +55,7 @@ xls_dslx_opt_ir(
5455
name = "umul_with_overflow_35_32_18",
5556
srcs = ["umul_instances.x"],
5657
dslx_top = "umul_with_overflow_35_32_18",
58+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
5759
)
5860

5961
cc_xls_ir_jit_wrapper(
@@ -184,6 +186,7 @@ xls_dslx_opt_ir(
184186
name = "float32_downcast",
185187
srcs = ["float32_downcast_test.x"],
186188
dslx_top = "f64_to_f32",
189+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
187190
ir_file = "float32_downcast.ir",
188191
opt_ir_file = "float32_downcast.opt.ir",
189192
)
@@ -219,6 +222,7 @@ xls_dslx_opt_ir(
219222
name = "float32_upcast",
220223
srcs = ["float32_upcast_test.x"],
221224
dslx_top = "f32_to_f64",
225+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
222226
ir_file = "float32_upcast.ir",
223227
opt_ir_file = "float32_upcast.opt.ir",
224228
)
@@ -516,6 +520,7 @@ BFLOAT16_CMP_TOPS = [
516520
name = "bfloat16_" + top,
517521
srcs = ["//xls/dslx/stdlib:bfloat16.x"],
518522
dslx_top = top,
523+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
519524
),
520525
cc_xls_ir_jit_wrapper(
521526
name = "bfloat16_" + top + "_jit_wrapper",
@@ -550,6 +555,7 @@ xls_dslx_opt_ir(
550555
name = "bfloat16_full_precision_mul",
551556
srcs = ["//xls/dslx/stdlib:bfloat16.x"],
552557
dslx_top = "full_precision_mul",
558+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
553559
)
554560

555561
cc_xls_ir_jit_wrapper(

xls/dslx/tests/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ xls_dslx_opt_ir(
802802
name = "mod_parametric_id_user_opt_ir",
803803
srcs = ["mod_parametric_id_user.x"],
804804
dslx_top = "main",
805+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
805806
deps = [":mod_parametric_id_dslx"],
806807
)
807808

@@ -1036,6 +1037,7 @@ xls_dslx_opt_ir(
10361037
name = "mod_const_importer_opt_ir",
10371038
srcs = ["mod_const_importer.x"],
10381039
dslx_top = "main",
1040+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
10391041
deps = [":mod_simple_const_dslx"],
10401042
)
10411043

@@ -1093,6 +1095,7 @@ xls_dslx_opt_ir(
10931095
name = "mod_const_array_of_enum_importer_opt_ir",
10941096
srcs = ["mod_const_array_of_enum_importer.x"],
10951097
dslx_top = "main",
1098+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
10961099
deps = [":mod_simple_const_array_of_enums_dslx"],
10971100
)
10981101

@@ -1107,6 +1110,7 @@ xls_dslx_opt_ir(
11071110
name = "simple_enum_usage_opt_ir",
11081111
srcs = ["simple_enum_usage.x"],
11091112
dslx_top = "main",
1113+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
11101114
)
11111115

11121116
xls_dslx_opt_ir_test(

xls/dslx/tests/trace_fmt_repro_issue_652/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ xls_dslx_opt_ir(
4141
# the project consuming the Verilog.
4242
ir_conv_args = {
4343
"emit_assert": "false",
44+
"lower_to_proc_scoped_channels": "false",
4445
},
4546
library = ":trace_fmt_repro_dslx",
4647
)
4748

4849
xls_dslx_opt_ir(
4950
name = "trace_fmt_repro_no_conv_args",
5051
dslx_top = "foo",
52+
ir_conv_args = {"lower_to_proc_scoped_channels": "false"},
5153
library = ":trace_fmt_repro_dslx",
5254
)
5355

0 commit comments

Comments
 (0)