Skip to content

Commit 3afdbd4

Browse files
allightcopybara-github
authored andcommitted
Fully remove xls/passes from dependency chain of c_api.
Don't include the passes as early. This makes it easier to use the c-api in some circumstances by making it simpler to avoid dependency loops. If passes and estimators are needed link in the xls/public:passes_and_estimators target. PiperOrigin-RevId: 834924569
1 parent 71d0bf2 commit 3afdbd4

File tree

13 files changed

+45
-18
lines changed

13 files changed

+45
-18
lines changed

xls/codegen/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ cc_test(
848848
"//xls/ir:value_utils",
849849
"//xls/ir:xls_type_cc_proto",
850850
"//xls/jit:block_jit",
851+
"//xls/passes",
851852
"//xls/public:ir_parser",
852853
"//xls/scheduling:scheduling_options",
853854
"//xls/tools:codegen",
@@ -1170,6 +1171,7 @@ cc_test(
11701171
"//xls/common/status:matchers",
11711172
"//xls/common/status:ret_check",
11721173
"//xls/common/status:status_macros",
1174+
"//xls/estimators",
11731175
"//xls/estimators/delay_model:delay_estimator",
11741176
"//xls/interpreter:block_evaluator",
11751177
"//xls/interpreter:ir_interpreter",
@@ -1188,6 +1190,7 @@ cc_test(
11881190
"//xls/ir:source_location",
11891191
"//xls/ir:value",
11901192
"//xls/ir:verifier",
1193+
"//xls/passes",
11911194
"//xls/scheduling:pipeline_schedule",
11921195
"//xls/scheduling:run_pipeline_schedule",
11931196
"//xls/scheduling:scheduling_options",
@@ -1792,6 +1795,7 @@ cc_test(
17921795
"//xls/ir:source_location",
17931796
"//xls/ir:type",
17941797
"//xls/ir:value",
1798+
"//xls/passes",
17951799
"//xls/passes:optimization_pass",
17961800
"//xls/passes:pass_base",
17971801
"//xls/scheduling:pipeline_schedule",

xls/codegen/side_effect_condition_pass_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ class SideEffectConditionPassTest
120120
SchedulingOptions scheduling_options = kDefaultSchedulingOptions) {
121121
// First, schedule.
122122
OptimizationContext optimization_context;
123-
std::unique_ptr<SchedulingPass> scheduling_pipeline =
124-
CreateSchedulingPassPipeline(optimization_context, scheduling_options);
123+
XLS_ASSIGN_OR_RETURN(
124+
std::unique_ptr<SchedulingPass> scheduling_pipeline,
125+
CreateSchedulingPassPipeline(optimization_context, scheduling_options),
126+
_ << "Unable to create scheduling pass pipeline");
125127
XLS_RET_CHECK(p->GetTop().has_value());
126128
FunctionBase* top = p->GetTop().value();
127129
auto scheduling_context =

xls/codegen_v_1_5/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ cc_test(
132132
"//xls/common:xls_gunit_main",
133133
"//xls/common/status:matchers",
134134
"//xls/common/status:status_macros",
135+
"//xls/estimators",
135136
"//xls/ir:function_builder",
136137
"//xls/ir:ir_test_base",
138+
"//xls/passes",
137139
"//xls/scheduling:scheduling_options",
138140
"@googletest//:gtest",
139141
],
@@ -292,9 +294,11 @@ cc_test(
292294
"//xls/common/status:matchers",
293295
"//xls/common/status:ret_check",
294296
"//xls/common/status:status_macros",
297+
"//xls/estimators",
295298
"//xls/ir",
296299
"//xls/ir:ir_parser",
297300
"//xls/ir:ir_test_base",
301+
"//xls/passes",
298302
"//xls/passes:pass_base",
299303
"//xls/scheduling:scheduling_options",
300304
"//xls/scheduling:scheduling_result",

xls/contrib/mlir/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ cc_library(
362362
":xls_transforms_passes_inc_gen",
363363
":xls_translate_lib",
364364
"//xls/passes:pass_pipeline_cc_proto",
365+
"//xls/public:passes_and_estimators",
365366
"//xls/tools:opt",
366367
"@com_google_absl//absl/status",
367368
"@com_google_protobuf//:protobuf",
@@ -538,6 +539,7 @@ cc_library(
538539
"//xls/public:function_builder",
539540
"//xls/public:ir",
540541
"//xls/public:ir_parser",
542+
"//xls/public:passes_and_estimators",
541543
"//xls/public:runtime_codegen_actions",
542544
"//xls/public:runtime_dslx_actions",
543545
"//xls/scheduling:pipeline_schedule_cc_proto",

xls/contrib/xlscc/unit_tests/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ cc_library(
6060
"//xls/ir:state_element",
6161
"//xls/ir:value",
6262
"//xls/ir:value_utils",
63+
"//xls/passes",
6364
"//xls/simulation:sim_test_base",
6465
"//xls/tools:codegen",
6566
"//xls/tools:codegen_flags_cc_proto",

xls/dev_tools/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,7 @@ cc_binary(
696696
"//xls/estimators/delay_model:delay_estimator",
697697
"//xls/ir",
698698
"//xls/ir:ir_parser",
699+
"//xls/passes",
699700
"//xls/scheduling:pipeline_schedule",
700701
"//xls/scheduling:scheduling_options",
701702
"//xls/scheduling:scheduling_result",

xls/fuzzer/verilog_fuzzer/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ cc_test(
4848
":verilog_fuzz_domain",
4949
"//xls/common:xls_gunit_main",
5050
"//xls/common/fuzzing:fuzztest",
51+
"//xls/estimators",
52+
"//xls/passes",
5153
"//xls/tools:codegen_flags_cc_proto",
5254
"//xls/tools:scheduling_options_flags_cc_proto",
5355
"@com_google_absl//absl/status",

xls/scheduling/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ cc_test(
120120
"//xls/ir",
121121
"//xls/ir:ir_test_base",
122122
"//xls/ir:op",
123+
"//xls/passes",
123124
"//xls/passes:optimization_pass",
124125
"//xls/passes:pass_base",
125126
"//xls/tools:scheduling_options_flags_cc_proto",
@@ -454,11 +455,12 @@ cc_library(
454455
":scheduling_options",
455456
":scheduling_pass",
456457
":scheduling_wrapper_pass",
457-
"//xls/passes",
458+
"//xls/common/status:status_macros",
458459
"//xls/passes:dce_pass",
459460
"//xls/passes:optimization_pass",
460461
"//xls/passes:optimization_pass_pipeline",
461462
"@com_google_absl//absl/log:check",
463+
"@com_google_absl//absl/status:statusor",
462464
],
463465
)
464466

xls/scheduling/scheduling_options_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ top proc main(__state: bits[1], init={0}) {
9494
SchedulingContext sched_ctx =
9595
SchedulingContext::CreateForWholePackage(p.get());
9696
PassResults results;
97-
XLS_ASSERT_OK(CreateSchedulingPassPipeline(opt_ctx, options)
98-
->Run(p.get(), pass_options, &results, sched_ctx));
97+
XLS_ASSERT_OK_AND_ASSIGN(auto pipeline,
98+
CreateSchedulingPassPipeline(opt_ctx, options));
99+
XLS_ASSERT_OK(pipeline->Run(p.get(), pass_options, &results, sched_ctx));
99100
XLS_ASSERT_OK_AND_ASSIGN(Proc * proc, p->GetTopAsProc());
100101
EXPECT_EQ(NumberOfOp(proc, Op::kSend), merge_on_mutual_exclusion ? 1 : 2);
101102
}

xls/scheduling/scheduling_pass_pipeline.cc

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <utility>
2222

2323
#include "absl/log/check.h"
24+
#include "xls/common/status/status_macros.h"
2425
#include "xls/passes/dce_pass.h"
2526
#include "xls/passes/optimization_pass.h"
2627
#include "xls/passes/optimization_pass_pipeline.h"
@@ -34,8 +35,9 @@
3435

3536
namespace xls {
3637

37-
std::unique_ptr<SchedulingCompoundPass> CreateSchedulingPassPipeline(
38-
OptimizationContext& context, const SchedulingOptions& options) {
38+
absl::StatusOr<std::unique_ptr<SchedulingCompoundPass>>
39+
CreateSchedulingPassPipeline(OptimizationContext& context,
40+
const SchedulingOptions& options) {
3941
auto top = std::make_unique<SchedulingCompoundPass>(
4042
"scheduling", "Top level scheduling pass pipeline");
4143
top->AddInvariantChecker<SchedulingChecker>();
@@ -53,11 +55,13 @@ std::unique_ptr<SchedulingCompoundPass> CreateSchedulingPassPipeline(
5355
// TODO(allight): We might want to move this pre-scheduling mutex pass (and
5456
// the earlier legalization pass) into the opt-main pipeline to avoid
5557
// needing to do this.
56-
auto pipeline =
57-
GetOptimizationPipelineGenerator().GeneratePipeline("scheduling-opt");
58-
CHECK_OK(pipeline.status())
59-
<< "Unable to create scheduling-opt pass. This is a bug.";
60-
top->Add<SchedulingWrapperPass>(*std::move(pipeline), context,
58+
XLS_ASSIGN_OR_RETURN(
59+
auto pipeline,
60+
GetOptimizationPipelineGenerator().GeneratePipeline("scheduling-opt"),
61+
_ << "Unable to create scheduling-opt pass. The linked passes must "
62+
"include a pass named 'scheduling-opt'. Did you link "
63+
"'//xls/passes'?");
64+
top->Add<SchedulingWrapperPass>(std::move(pipeline), context,
6165
options.opt_level(), eliminate_noop_next);
6266
}
6367
top->Add<SchedulingWrapperPass>(std::make_unique<DeadCodeEliminationPass>(),

0 commit comments

Comments
 (0)