Skip to content

Commit d5d5971

Browse files
committed
Add helper for specializing parametric functions
1 parent 70d7966 commit d5d5971

File tree

12 files changed

+1199
-13
lines changed

12 files changed

+1199
-13
lines changed

xls/dslx/frontend/BUILD

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,51 @@ cc_library(
5757
],
5858
)
5959

60+
cc_library(
61+
name = "function_specializer",
62+
srcs = ["function_specializer.cc"],
63+
hdrs = ["function_specializer.h"],
64+
deps = [
65+
":ast",
66+
":ast_cloner",
67+
":module",
68+
"//xls/common/status:ret_check",
69+
"//xls/common/status:status_macros",
70+
"//xls/ir:bits_ops",
71+
"//xls/ir:format_preference",
72+
"//xls/dslx/type_system:parametric_env",
73+
"@com_google_absl//absl/container:flat_hash_map",
74+
"@com_google_absl//absl/log:check",
75+
"@com_google_absl//absl/status",
76+
"@com_google_absl//absl/status:statusor",
77+
"@com_google_absl//absl/strings:str_format",
78+
"@com_google_absl//absl/types:span",
79+
],
80+
)
81+
82+
cc_test(
83+
name = "function_specializer_test",
84+
srcs = ["function_specializer_test.cc"],
85+
deps = [
86+
":ast",
87+
":function_specializer",
88+
":module",
89+
"//xls/common:casts",
90+
"//xls/common:xls_gunit_main",
91+
"//xls/common/status:matchers",
92+
"//xls/dslx:create_import_data",
93+
"//xls/dslx:interp_value",
94+
"//xls/dslx:parse_and_typecheck",
95+
"//xls/dslx:warning_collector",
96+
"//xls/dslx/type_system:parametric_env",
97+
"//xls/dslx/type_system:typecheck_module",
98+
"//xls/dslx:replace_invocations",
99+
"@com_google_absl//absl/container:flat_hash_map",
100+
"@com_google_absl//absl/strings",
101+
"@googletest//:gtest",
102+
],
103+
)
104+
60105
cc_test(
61106
name = "ast_cloner_test",
62107
srcs = ["ast_cloner_test.cc"],

xls/dslx/frontend/ast.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,6 +3005,7 @@ class Slice : public AstNode {
30053005

30063006
std::string ToString() const override;
30073007
std::optional<Span> GetSpan() const override { return span_; }
3008+
const Span& span() const { return span_; }
30083009

30093010
Expr* start() const { return start_; }
30103011
Expr* limit() const { return limit_; }
@@ -3598,6 +3599,7 @@ class WidthSlice : public AstNode {
35983599
Expr* start() const { return start_; }
35993600
TypeAnnotation* width() const { return width_; }
36003601
std::optional<Span> GetSpan() const override { return span_; }
3602+
const Span& span() const { return span_; }
36013603

36023604
private:
36033605
Span span_;

0 commit comments

Comments
 (0)