From 21d8ebf5aab16df03028489bbdb760480849e6f7 Mon Sep 17 00:00:00 2001 From: David Plass Date: Wed, 7 Jan 2026 13:00:00 -0800 Subject: [PATCH] [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` to specify the flag as true or false instead of defaulting to the default when it's not specified. PiperOrigin-RevId: 853379668 --- xls/build_rules/tests/BUILD | 1 + xls/dslx/ir_convert/ir_converter_main.cc | 4 +++- xls/dslx/ir_convert/ir_converter_options_flags.cc | 9 ++++++++- xls/dslx/tests/trace_fmt_array/BUILD | 1 + xls/examples/BUILD | 14 +++++--------- xls/examples/assertions/BUILD | 1 + xls/examples/dslx_module/BUILD | 2 ++ xls/examples/parameterized/BUILD | 1 + xls/examples/protobuf/BUILD | 1 + xls/jit/BUILD | 2 ++ xls/jit/testdata/v1/BUILD | 2 ++ xls/jit/testdata/v2/BUILD | 2 ++ xls/modules/aes/BUILD | 5 +++++ xls/modules/rle/BUILD | 2 ++ xls/tools/testdata/BUILD | 4 ++++ 15 files changed, 40 insertions(+), 11 deletions(-) diff --git a/xls/build_rules/tests/BUILD b/xls/build_rules/tests/BUILD index 94d0395eea..7e47ce1059 100644 --- a/xls/build_rules/tests/BUILD +++ b/xls/build_rules/tests/BUILD @@ -296,6 +296,7 @@ xls_dslx_library( xls_dslx_ir( name = "add_one_dslx_ir", dslx_top = "main", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":add_one_dslx", ) diff --git a/xls/dslx/ir_convert/ir_converter_main.cc b/xls/dslx/ir_convert/ir_converter_main.cc index 0b933cf3a1..908a1afbfc 100644 --- a/xls/dslx/ir_convert/ir_converter_main.cc +++ b/xls/dslx/ir_convert/ir_converter_main.cc @@ -101,7 +101,9 @@ absl::Status RealMain(absl::Span paths) { bool warnings_as_errors = ir_converter_options.warnings_as_errors(); bool type_inference_v2 = ir_converter_options.type_inference_v2(); bool lower_to_proc_scoped_channels = - ir_converter_options.lower_to_proc_scoped_channels(); + ir_converter_options.has_lower_to_proc_scoped_channels() + ? ir_converter_options.lower_to_proc_scoped_channels() + : false; bool force_implicit_token_calling_convention = ir_converter_options.force_implicit_token_calling_convention(); bool emit_trace = ir_converter_options.emit_trace(); diff --git a/xls/dslx/ir_convert/ir_converter_options_flags.cc b/xls/dslx/ir_convert/ir_converter_options_flags.cc index 07b9e801ad..192473a706 100644 --- a/xls/dslx/ir_convert/ir_converter_options_flags.cc +++ b/xls/dslx/ir_convert/ir_converter_options_flags.cc @@ -112,6 +112,13 @@ absl::StatusOr SetOptionsFromFlags(IrConverterOptionsFlagsProto& proto) { any_flags_set |= FLAGS_##__x.IsSpecifiedOnCommandLine(); \ proto.set_##__x(absl::GetFlag(FLAGS_##__x)); \ } +#define POPULATE_FLAG_IF_SPECIFIED(__x) \ + { \ + if (FLAGS_##__x.IsSpecifiedOnCommandLine()) { \ + any_flags_set = true; \ + proto.set_##__x(absl::GetFlag(FLAGS_##__x)); \ + } \ + } #define POPULATE_OPTIONAL_FLAG(__x) \ { \ any_flags_set |= FLAGS_##__x.IsSpecifiedOnCommandLine(); \ @@ -143,7 +150,7 @@ absl::StatusOr SetOptionsFromFlags(IrConverterOptionsFlagsProto& proto) { POPULATE_OPTIONAL_FLAG(interface_proto_file); POPULATE_OPTIONAL_FLAG(interface_textproto_file); POPULATE_FLAG(type_inference_v2); - POPULATE_FLAG(lower_to_proc_scoped_channels); + POPULATE_FLAG_IF_SPECIFIED(lower_to_proc_scoped_channels); POPULATE_FLAG(force_implicit_token_calling_convention); POPULATE_REPEATED_FLAG(configured_values); POPULATE_FLAG(emit_assert); diff --git a/xls/dslx/tests/trace_fmt_array/BUILD b/xls/dslx/tests/trace_fmt_array/BUILD index a1b426a126..0a197ddaa5 100644 --- a/xls/dslx/tests/trace_fmt_array/BUILD +++ b/xls/dslx/tests/trace_fmt_array/BUILD @@ -34,6 +34,7 @@ xls_dslx_library( xls_dslx_ir( name = "test_target", dslx_top = "traceit", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":test_target_library", ) diff --git a/xls/examples/BUILD b/xls/examples/BUILD index a8a524bf7a..b981c8cf20 100644 --- a/xls/examples/BUILD +++ b/xls/examples/BUILD @@ -961,9 +961,7 @@ xls_dslx_test( xls_dslx_ir( name = "delay_loopback_channel_ir", dslx_top = "Delay", - ir_conv_args = { - "lower_to_proc_scoped_channels": "true", - }, + ir_conv_args = {"lower_to_proc_scoped_channels": "true"}, ir_file = "delay_loopback_channel.ir", library = ":delay_loopback_channel_dslx", ) @@ -1048,6 +1046,7 @@ xls_dslx_test( xls_dslx_ir( name = "constraint_ir", dslx_top = "main", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ir_file = "constraint.ir", library = ":constraint_dslx", ) @@ -1242,6 +1241,7 @@ xls_dslx_test( xls_dslx_ir( name = "serialized_decomposer_ir", dslx_top = "serialized_decomposer", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ir_file = "serialized_decomposer.ir", library = ":serialized_decomposer_dslx", ) @@ -1391,9 +1391,7 @@ xls_dslx_test( xls_dslx_ir( name = "proc_network_ir", dslx_top = "Initiator", - ir_conv_args = { - "lower_to_proc_scoped_channels": "false", - }, + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ir_file = "proc_network.ir", library = ":proc_network_dslx", ) @@ -1401,9 +1399,7 @@ xls_dslx_ir( xls_dslx_ir( name = "proc_network_proc_scoped_ir", dslx_top = "Initiator", - ir_conv_args = { - "lower_to_proc_scoped_channels": "true", - }, + ir_conv_args = {"lower_to_proc_scoped_channels": "true"}, ir_file = "proc_network_proc_scoped.ir", library = ":proc_network_dslx", ) diff --git a/xls/examples/assertions/BUILD b/xls/examples/assertions/BUILD index f1a26d67df..84fdec0445 100644 --- a/xls/examples/assertions/BUILD +++ b/xls/examples/assertions/BUILD @@ -48,6 +48,7 @@ xls_dslx_test( xls_dslx_ir( name = "assertions_ir", dslx_top = "main", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ir_file = "assertions.ir", library = ":assertions_dslx", ) diff --git a/xls/examples/dslx_module/BUILD b/xls/examples/dslx_module/BUILD index 94575d3a5b..8f3983baea 100644 --- a/xls/examples/dslx_module/BUILD +++ b/xls/examples/dslx_module/BUILD @@ -65,6 +65,7 @@ xls_dslx_ir( name = "some_caps_streaming_configured_ir", dslx_top = "some_caps_specialized", ir_conv_args = { + "lower_to_proc_scoped_channels": "false", # Set fifo config for multi-proc codegen. # It needs to know what configuration to use for the fifo. "default_fifo_config": "depth: 4, bypass: true, " + @@ -91,6 +92,7 @@ xls_dslx_opt_ir( # liveness instead of spawn tree. This is done to avoid having to deal with mangled names. dslx_top = "manual_chan_caps_specialized", ir_conv_args = { + "lower_to_proc_scoped_channels": "false", # Set fifo config for multi-proc codegen. # It needs to know what configuration to use for the fifo. "default_fifo_config": "depth: 4, bypass: true, " + diff --git a/xls/examples/parameterized/BUILD b/xls/examples/parameterized/BUILD index 647a872376..e7e4f250bc 100644 --- a/xls/examples/parameterized/BUILD +++ b/xls/examples/parameterized/BUILD @@ -62,6 +62,7 @@ xls_dslx_library( xls_dslx_ir( name = "design_ir", dslx_top = "design_top", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ir_file = "design.ir", library = "design_lib", ) diff --git a/xls/examples/protobuf/BUILD b/xls/examples/protobuf/BUILD index 0bd5911861..32686751ce 100644 --- a/xls/examples/protobuf/BUILD +++ b/xls/examples/protobuf/BUILD @@ -47,6 +47,7 @@ xls_dslx_test( xls_dslx_ir( name = "verint_encode_ir", dslx_top = "varint_encode_u32", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ir_file = "varint_encode.ir", library = ":varint_encode_dslx", ) diff --git a/xls/jit/BUILD b/xls/jit/BUILD index f5fd376d3a..7b760ec872 100644 --- a/xls/jit/BUILD +++ b/xls/jit/BUILD @@ -1217,6 +1217,7 @@ xls_dslx_library( xls_dslx_ir( name = "multi_function", dslx_top = "multi_function_one", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":multi_function_dslx", ) @@ -1285,6 +1286,7 @@ xls_dslx_library( xls_dslx_ir( name = "multi_function_with_trace", dslx_top = "multi_function_one", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":multi_function_with_trace_dslx", ) diff --git a/xls/jit/testdata/v1/BUILD b/xls/jit/testdata/v1/BUILD index 46c6932abb..a18e14329b 100644 --- a/xls/jit/testdata/v1/BUILD +++ b/xls/jit/testdata/v1/BUILD @@ -28,12 +28,14 @@ xls_dslx_ir( name = "test_ir", srcs = ["test.x"], dslx_top = "main", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ) xls_dslx_ir( name = "multi_proc_ir", srcs = ["multi_proc.x"], dslx_top = "proc_ten", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ) xls_dslx_ir( diff --git a/xls/jit/testdata/v2/BUILD b/xls/jit/testdata/v2/BUILD index dc9b79801e..13957074d6 100644 --- a/xls/jit/testdata/v2/BUILD +++ b/xls/jit/testdata/v2/BUILD @@ -28,12 +28,14 @@ xls_dslx_ir( name = "test_ir", srcs = ["test.x"], dslx_top = "main", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ) xls_dslx_ir( name = "multi_proc_ir", srcs = ["multi_proc.x"], dslx_top = "proc_ten", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ) xls_dslx_ir( diff --git a/xls/modules/aes/BUILD b/xls/modules/aes/BUILD index 5978ce89bd..2ecb33473c 100644 --- a/xls/modules/aes/BUILD +++ b/xls/modules/aes/BUILD @@ -69,6 +69,7 @@ xls_dslx_test( xls_dslx_ir( name = "aes_ctr", dslx_top = "aes_ctr", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":aes_ctr_dslx", ) @@ -112,6 +113,7 @@ cc_test( xls_dslx_ir( name = "aes_decrypt", dslx_top = "decrypt", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":aes_dslx", ) @@ -133,6 +135,7 @@ xls_dslx_library( xls_dslx_ir( name = "aes_encrypt", dslx_top = "encrypt", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":aes_dslx", ) @@ -165,6 +168,7 @@ xls_dslx_test( xls_dslx_ir( name = "aes_gcm", dslx_top = "aes_gcm", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":aes_gcm_dslx", ) @@ -231,6 +235,7 @@ xls_dslx_test( xls_dslx_ir( name = "aes_ghash", dslx_top = "ghash", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":ghash_dslx", ) diff --git a/xls/modules/rle/BUILD b/xls/modules/rle/BUILD index bc76c22b8a..52ab42014e 100644 --- a/xls/modules/rle/BUILD +++ b/xls/modules/rle/BUILD @@ -131,6 +131,7 @@ xls_dslx_test( xls_dslx_ir( name = "rle_enc_ir", dslx_top = "RunLengthEncoder32", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ir_file = "rle_enc.ir", library = "rle_enc_dslx", ) @@ -258,6 +259,7 @@ xls_dslx_test( xls_dslx_ir( name = "rle_dec_ir", dslx_top = "RunLengthDecoder32", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, ir_file = "rle_dec.ir", library = "rle_dec_dslx", ) diff --git a/xls/tools/testdata/BUILD b/xls/tools/testdata/BUILD index 4b2d31d78d..f6b126b2df 100644 --- a/xls/tools/testdata/BUILD +++ b/xls/tools/testdata/BUILD @@ -82,6 +82,7 @@ xls_dslx_ir( xls_dslx_ir( name = "eval_proc_main_test_ir", dslx_top = "test_proc", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":eval_proc_main_test", ) @@ -166,6 +167,7 @@ xls_dslx_library( xls_dslx_ir( name = "eval_proc_main_zero_size_test_ir", dslx_top = "test_proc", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":eval_proc_main_zero_size_test", ) @@ -246,6 +248,7 @@ xls_dslx_library( xls_dslx_ir( name = "eval_proc_main_conditional_test_ir", dslx_top = "test_proc", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":eval_proc_main_conditional_test", ) @@ -339,6 +342,7 @@ xls_dslx_library( xls_dslx_ir( name = "eval_proc_main_test_memory", dslx_top = "test_proc", + ir_conv_args = {"lower_to_proc_scoped_channels": "false"}, library = ":eval_proc_main_test_memory_lib", )