From d6e14d20189edf6b3e6f13e72950002ba9aa3111 Mon Sep 17 00:00:00 2001 From: Mark Heffernan Date: Thu, 5 Sep 2024 14:30:17 -0700 Subject: [PATCH] Move IR minimizer from xls/tools to xls/dev_tools. PiperOrigin-RevId: 671512083 --- docs_src/tools.md | 2 +- xls/dev_tools/BUILD | 79 +++++++++++++++++++ xls/{tools => dev_tools}/ir_minimizer_main.cc | 0 .../ir_minimizer_main_test.py | 2 +- xls/fuzzer/BUILD | 2 +- xls/fuzzer/cpp_run_fuzz.cc | 2 +- xls/tools/BUILD | 79 ------------------- 7 files changed, 83 insertions(+), 83 deletions(-) rename xls/{tools => dev_tools}/ir_minimizer_main.cc (100%) rename xls/{tools => dev_tools}/ir_minimizer_main_test.py (99%) diff --git a/docs_src/tools.md b/docs_src/tools.md index a428429fdd..a0a0fa9d9c 100644 --- a/docs_src/tools.md +++ b/docs_src/tools.md @@ -85,7 +85,7 @@ between versions. If possible, LLVM tools built at the same commit as the JIT should be used to interact with the generated llvm bytecode. This can be done by building the LLVM tools using `bazel build` from the XLS repo. -## [`ir_minimizer_main`](https://github.com/google/xls/tree/main/xls/tools/ir_minimizer_main.cc) +## [`ir_minimizer_main`](https://github.com/google/xls/tree/main/xls/dev_tools/ir_minimizer_main.cc) Tool for reducing IR to a minimal test case based on an external test. diff --git a/xls/dev_tools/BUILD b/xls/dev_tools/BUILD index af9d476300..6c6656a71b 100644 --- a/xls/dev_tools/BUILD +++ b/xls/dev_tools/BUILD @@ -527,3 +527,82 @@ filegroup( srcs = ["check_ir_equivalence.sh"], visibility = ["//xls:xls_users"], ) + +cc_binary( + name = "ir_minimizer_main", + srcs = ["ir_minimizer_main.cc"], + data = [ + "//xls/tools:opt_main", + ], + deps = [ + "@com_google_absl//absl/algorithm:container", + "@com_google_absl//absl/container:btree", + "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/flags:flag", + "@com_google_absl//absl/log", + "@com_google_absl//absl/log:check", + "@com_google_absl//absl/random:bit_gen_ref", + "@com_google_absl//absl/random:distributions", + "@com_google_absl//absl/status", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_absl//absl/strings:str_format", + "@com_google_absl//absl/types:span", + "//xls/common:exit_status", + "//xls/common:init_xls", + "//xls/common:subprocess", + "//xls/common/file:filesystem", + "//xls/common/file:temp_file", + "//xls/common/logging:log_lines", + "//xls/common/status:ret_check", + "//xls/common/status:status_macros", + "//xls/data_structures:binary_search", + "//xls/data_structures:inline_bitmap", + "//xls/dev_tools:extract_segment", + "//xls/interpreter:ir_interpreter", + "//xls/ir", + "//xls/ir:channel", + "//xls/ir:channel_ops", + "//xls/ir:events", + "//xls/ir:function_builder", + "//xls/ir:ir_parser", + "//xls/ir:node_util", + "//xls/ir:op", + "//xls/ir:source_location", + "//xls/ir:type", + "//xls/ir:value", + "//xls/ir:value_utils", + "//xls/ir:verifier", + "//xls/jit:function_jit", + "//xls/passes:arith_simplification_pass", + "//xls/passes:array_simplification_pass", + "//xls/passes:bit_slice_simplification_pass", + "//xls/passes:concat_simplification_pass", + "//xls/passes:constant_folding_pass", + "//xls/passes:cse_pass", + "//xls/passes:dataflow_simplification_pass", + "//xls/passes:dce_pass", + "//xls/passes:dfe_pass", + "//xls/passes:inlining_pass", + "//xls/passes:map_inlining_pass", + "//xls/passes:optimization_pass", + "//xls/passes:optimization_pass_pipeline", + "//xls/passes:pass_base", + "//xls/passes:proc_state_flattening_pass", + "//xls/passes:proc_state_optimization_pass", + "//xls/passes:unroll_pass", + ], +) + +py_test( + name = "ir_minimizer_main_test", + srcs = ["ir_minimizer_main_test.py"], + data = ["ir_minimizer_main"], + python_version = "PY3", + srcs_version = "PY3", + deps = [ + "@com_google_absl_py//absl/testing:absltest", + "//xls/common:runfiles", + ], +) diff --git a/xls/tools/ir_minimizer_main.cc b/xls/dev_tools/ir_minimizer_main.cc similarity index 100% rename from xls/tools/ir_minimizer_main.cc rename to xls/dev_tools/ir_minimizer_main.cc diff --git a/xls/tools/ir_minimizer_main_test.py b/xls/dev_tools/ir_minimizer_main_test.py similarity index 99% rename from xls/tools/ir_minimizer_main_test.py rename to xls/dev_tools/ir_minimizer_main_test.py index 01f0e6f6fe..825980732e 100644 --- a/xls/tools/ir_minimizer_main_test.py +++ b/xls/dev_tools/ir_minimizer_main_test.py @@ -20,7 +20,7 @@ from absl.testing import absltest from xls.common import runfiles -IR_MINIMIZER_MAIN_PATH = runfiles.get_path('xls/tools/ir_minimizer_main') +IR_MINIMIZER_MAIN_PATH = runfiles.get_path('xls/dev_tools/ir_minimizer_main') ADD_IR = """package foo diff --git a/xls/fuzzer/BUILD b/xls/fuzzer/BUILD index d24b5e2272..3521860cac 100644 --- a/xls/fuzzer/BUILD +++ b/xls/fuzzer/BUILD @@ -957,7 +957,7 @@ cc_library( data = [ ":find_failing_input_main", ":sample_runner_main", - "//xls/tools:ir_minimizer_main", + "//xls/dev_tools:ir_minimizer_main", ], deps = [ ":sample", diff --git a/xls/fuzzer/cpp_run_fuzz.cc b/xls/fuzzer/cpp_run_fuzz.cc index e1db1cc834..a11aacc7e7 100644 --- a/xls/fuzzer/cpp_run_fuzz.cc +++ b/xls/fuzzer/cpp_run_fuzz.cc @@ -36,7 +36,7 @@ namespace xls { namespace { absl::StatusOr GetIrMinimizerMainPath() { - return GetXlsRunfilePath("xls/tools/ir_minimizer_main"); + return GetXlsRunfilePath("xls/dev_tools/ir_minimizer_main"); } absl::StatusOr GetSampleRunnerMainPath() { diff --git a/xls/tools/BUILD b/xls/tools/BUILD index 88691cd031..e76a64f6a5 100644 --- a/xls/tools/BUILD +++ b/xls/tools/BUILD @@ -460,73 +460,6 @@ py_test( ], ) -cc_binary( - name = "ir_minimizer_main", - srcs = ["ir_minimizer_main.cc"], - data = [ - ":opt_main", - ], - deps = [ - "//xls/common:exit_status", - "//xls/common:init_xls", - "//xls/common:subprocess", - "//xls/common/file:filesystem", - "//xls/common/file:temp_file", - "//xls/common/logging:log_lines", - "//xls/common/status:ret_check", - "//xls/common/status:status_macros", - "//xls/data_structures:binary_search", - "//xls/data_structures:inline_bitmap", - "//xls/dev_tools:extract_segment", - "//xls/interpreter:ir_interpreter", - "//xls/ir", - "//xls/ir:channel", - "//xls/ir:channel_ops", - "//xls/ir:events", - "//xls/ir:function_builder", - "//xls/ir:ir_parser", - "//xls/ir:node_util", - "//xls/ir:op", - "//xls/ir:source_location", - "//xls/ir:type", - "//xls/ir:value", - "//xls/ir:value_utils", - "//xls/ir:verifier", - "//xls/jit:function_jit", - "//xls/passes:arith_simplification_pass", - "//xls/passes:array_simplification_pass", - "//xls/passes:bit_slice_simplification_pass", - "//xls/passes:concat_simplification_pass", - "//xls/passes:constant_folding_pass", - "//xls/passes:cse_pass", - "//xls/passes:dataflow_simplification_pass", - "//xls/passes:dce_pass", - "//xls/passes:dfe_pass", - "//xls/passes:inlining_pass", - "//xls/passes:map_inlining_pass", - "//xls/passes:optimization_pass", - "//xls/passes:optimization_pass_pipeline", - "//xls/passes:pass_base", - "//xls/passes:proc_state_flattening_pass", - "//xls/passes:proc_state_optimization_pass", - "//xls/passes:unroll_pass", - "@com_google_absl//absl/algorithm:container", - "@com_google_absl//absl/container:btree", - "@com_google_absl//absl/container:flat_hash_map", - "@com_google_absl//absl/container:flat_hash_set", - "@com_google_absl//absl/flags:flag", - "@com_google_absl//absl/log", - "@com_google_absl//absl/log:check", - "@com_google_absl//absl/random:bit_gen_ref", - "@com_google_absl//absl/random:distributions", - "@com_google_absl//absl/status", - "@com_google_absl//absl/status:statusor", - "@com_google_absl//absl/strings", - "@com_google_absl//absl/strings:str_format", - "@com_google_absl//absl/types:span", - ], -) - py_test( name = "mul_folding_overlarge", srcs = ["run_opt_main.py"], @@ -929,18 +862,6 @@ cc_binary( ], ) -py_test( - name = "ir_minimizer_main_test", - srcs = ["ir_minimizer_main_test.py"], - data = ["ir_minimizer_main"], - python_version = "PY3", - srcs_version = "PY3", - deps = [ - "//xls/common:runfiles", - "@com_google_absl_py//absl/testing:absltest", - ], -) - # TODO(b/147004555): Add a JIT (or legacy) version of this test once # the JIT supports enough functionality to pass. py_test(