Skip to content

Commit

Permalink
Merge pull request #1413 from hzeller:ir-fix-include
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 634599228
  • Loading branch information
copybara-github committed May 17, 2024
2 parents 9a06d1d + fc87bf7 commit 3b61ec9
Show file tree
Hide file tree
Showing 33 changed files with 102 additions and 62 deletions.
17 changes: 16 additions & 1 deletion xls/ir/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,7 @@ cc_test(
":bits",
":bits_ops",
":bits_test_utils",
":format_preference",
":number_parser",
":value",
"//xls/common:bits_util",
Expand Down Expand Up @@ -611,11 +612,13 @@ cc_library(
deps = [
":channel",
":channel_ops",
":foreign_function_data_cc_proto",
":format_strings",
":ir",
":op",
":register",
":source_location",
":type",
":value",
":verifier",
"//xls/common:casts",
Expand Down Expand Up @@ -646,6 +649,7 @@ cc_test(
":ir_matcher",
":node_util",
":op",
":register",
":source_location",
":type",
":value",
Expand Down Expand Up @@ -917,10 +921,13 @@ cc_library(
":bits",
":type",
":value",
"//xls/common:bits_util",
"//xls/common/status:ret_check",
"//xls/common/status:status_macros",
"//xls/data_structures:leaf_type_tree",
"@com_google_absl//absl/base",
"@com_google_absl//absl/log",
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
],
Expand Down Expand Up @@ -991,6 +998,7 @@ cc_test(
name = "ir_test_base_test",
srcs = ["ir_test_base_test.cc"],
deps = [
":ir",
":ir_test_base",
"//xls/common:xls_gunit_main",
"//xls/common/status:matchers",
Expand Down Expand Up @@ -1051,6 +1059,7 @@ cc_library(
hdrs = ["format_strings.h"],
deps = [
":format_preference",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
Expand All @@ -1062,6 +1071,7 @@ cc_test(
name = "format_strings_test",
srcs = ["format_strings_test.cc"],
deps = [
":format_preference",
":format_strings",
"//xls/common:xls_gunit_main",
"//xls/common/status:matchers",
Expand Down Expand Up @@ -1208,6 +1218,7 @@ cc_library(
"//xls/common:string_to_int",
"//xls/common/status:ret_check",
"//xls/common/status:status_macros",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
Expand Down Expand Up @@ -1283,6 +1294,7 @@ cc_test(
deps = [
":bits",
":bits_ops",
":format_preference",
":number_parser",
"//xls/common:xls_gunit_main",
"//xls/common/status:matchers",
Expand All @@ -1298,6 +1310,7 @@ cc_test(
":big_int",
":bits",
":bits_ops",
":format_preference",
":number_parser",
"//xls/common:xls_gunit_main",
"//xls/common/status:matchers",
Expand Down Expand Up @@ -1417,6 +1430,7 @@ cc_library(
"//xls/common/status:status_macros",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings:str_format",
],
Expand Down Expand Up @@ -1594,6 +1608,7 @@ cc_test(
"//xls/common/status:matchers",
"//xls/common/status:ret_check",
"//xls/common/status:status_macros",
"@com_google_absl//absl/base",
"@com_google_absl//absl/status",
"@com_google_absl//absl/types:span",
"@com_google_googletest//:gtest",
Expand Down Expand Up @@ -1811,7 +1826,6 @@ cc_library(
"//xls/common/status:status_macros",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/base:nullability",
"@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/log",
Expand Down Expand Up @@ -1852,6 +1866,7 @@ cc_library(
hdrs = ["proc_elaboration.h"],
deps = [
":channel",
":channel_cc_proto",
":channel_ops",
":elaboration",
":ir",
Expand Down
1 change: 1 addition & 0 deletions xls/ir/big_int_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "xls/common/status/matchers.h"
#include "xls/ir/bits.h"
#include "xls/ir/bits_ops.h"
#include "xls/ir/format_preference.h"
#include "xls/ir/number_parser.h"

namespace xls {
Expand Down
1 change: 1 addition & 0 deletions xls/ir/bits_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "xls/data_structures/inline_bitmap.h"
#include "xls/ir/bits_ops.h"
#include "xls/ir/bits_test_utils.h"
#include "xls/ir/format_preference.h"
#include "xls/ir/number_parser.h"
#include "xls/ir/value.h"

Expand Down
2 changes: 2 additions & 0 deletions xls/ir/caret.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include "xls/common/file/filesystem.h"
#include "xls/common/status/ret_check.h"
#include "xls/common/status/status_macros.h"
#include "xls/ir/fileno.h"
#include "xls/ir/source_location.h"

namespace xls {

Expand Down
5 changes: 3 additions & 2 deletions xls/ir/caret_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "absl/strings/str_format.h"
#include "xls/common/file/temp_file.h"
#include "xls/common/status/matchers.h"
#include "xls/ir/fileno.h"
#include "xls/ir/package.h"
#include "xls/ir/source_location.h"

Expand Down Expand Up @@ -64,8 +65,8 @@ TEST(CaretTest, FileContent) {
2 | this is a line of code that does stuff
| ^
)";
std::string expected = absl::StrFormat(expected_format,
std::string(temp_file.path()));
std::string expected =
absl::StrFormat(expected_format, std::string(temp_file.path()));
EXPECT_EQ(
PrintCaret(LookUpInPackage(&p), loc, std::nullopt, std::nullopt, 60),
expected);
Expand Down
1 change: 1 addition & 0 deletions xls/ir/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "absl/types/variant.h"
#include "google/protobuf/text_format.h"
#include "xls/common/casts.h"
#include "xls/ir/channel.pb.h"
#include "xls/ir/channel_ops.h"
#include "xls/ir/type.h"
#include "xls/ir/value_utils.h"
Expand Down
3 changes: 3 additions & 0 deletions xls/ir/format_strings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
#include "xls/ir/format_strings.h"

#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <string>
#include <string_view>
#include <variant>
#include <vector>

#include "absl/status/status.h"
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "absl/strings/str_replace.h"
#include "absl/types/span.h"
#include "xls/ir/format_preference.h"

namespace xls {

Expand Down
1 change: 1 addition & 0 deletions xls/ir/format_strings_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "gtest/gtest.h"
#include "absl/status/status.h"
#include "xls/common/status/matchers.h"
#include "xls/ir/format_preference.h"

namespace xls {
namespace {
Expand Down
5 changes: 2 additions & 3 deletions xls/ir/function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ absl::StatusOr<Function*> Function::Clone(

// Clone parameters over first to maintain order.
for (Param* param : (const_cast<Function*>(this))->params()) {
XLS_ASSIGN_OR_RETURN(
original_to_clone[param],
param->CloneInNewFunction({}, cloned_function));
XLS_ASSIGN_OR_RETURN(original_to_clone[param],
param->CloneInNewFunction({}, cloned_function));
}
for (Node* node : TopoSort(const_cast<Function*>(this))) {
if (node->Is<Param>()) { // Params were already copied.
Expand Down
13 changes: 7 additions & 6 deletions xls/ir/function_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@
#include "xls/common/symbolized_stacktrace.h"
#include "xls/ir/channel.h"
#include "xls/ir/channel_ops.h"
#include "xls/ir/foreign_function_data.pb.h"
#include "xls/ir/format_strings.h"
#include "xls/ir/function.h"
#include "xls/ir/function_base.h"
#include "xls/ir/lsb_or_msb.h"
#include "xls/ir/nodes.h"
#include "xls/ir/op.h"
#include "xls/ir/package.h"
#include "xls/ir/proc.h"
#include "xls/ir/register.h"
#include "xls/ir/source_location.h"
#include "xls/ir/type.h"
#include "xls/ir/value.h"
#include "xls/ir/verifier.h"
#include "xls/ir/verify_node.h"
Expand Down Expand Up @@ -215,8 +218,7 @@ BValue BuilderBase::OneHot(BValue input, LsbOrMsb priority,

BValue BuilderBase::OneHotSelect(BValue selector,
absl::Span<const BValue> cases,
const SourceInfo& loc,
std::string_view name) {
const SourceInfo& loc, std::string_view name) {
if (ErrorPending()) {
return BValue();
}
Expand Down Expand Up @@ -1333,8 +1335,7 @@ BValue BuilderBase::AddBinOp(Op op, BValue lhs, BValue rhs,
}

BValue BuilderBase::AddCompareOp(Op op, BValue lhs, BValue rhs,
const SourceInfo& loc,
std::string_view name) {
const SourceInfo& loc, std::string_view name) {
if (ErrorPending()) {
return BValue();
}
Expand Down Expand Up @@ -1841,8 +1842,8 @@ absl::StatusOr<Block*> BlockBuilder::Build() {
}

BValue BlockBuilder::InstantiationInput(Instantiation* instantiation,
std::string_view port_name,
BValue data, const SourceInfo& loc,
std::string_view port_name, BValue data,
const SourceInfo& loc,
std::string_view name) {
if (ErrorPending()) {
return BValue();
Expand Down
5 changes: 3 additions & 2 deletions xls/ir/function_builder_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "xls/ir/nodes.h"
#include "xls/ir/op.h"
#include "xls/ir/package.h"
#include "xls/ir/register.h"
#include "xls/ir/source_location.h"
#include "xls/ir/type.h"
#include "xls/ir/value.h"
Expand Down Expand Up @@ -335,7 +336,8 @@ TEST(FunctionBuilderTest, MinDelayNegativeWithGetError) {
BValue token = fb.AfterAll({});
fb.MinDelay(token, /*delay=*/-5);

EXPECT_THAT(fb.GetError(),
EXPECT_THAT(
fb.GetError(),
status_testing::StatusIs(absl::StatusCode::kInvalidArgument,
testing::HasSubstr("Delay cannot be negative")));
}
Expand Down Expand Up @@ -1006,7 +1008,6 @@ TEST(FunctionBuilderTest, TraceWithVerbosity) {
EXPECT_EQ(f->return_value()->As<Trace>()->verbosity(), 1);
}


TEST(FunctionBuilderTest, TraceWrongTypeOperand0) {
Package p("p");
FunctionBuilder b("f", &p);
Expand Down
1 change: 1 addition & 0 deletions xls/ir/function_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "absl/status/status.h"
#include "xls/common/status/matchers.h"
#include "xls/ir/bits.h"
#include "xls/ir/dfs_visitor.h"
#include "xls/ir/function_builder.h"
#include "xls/ir/ir_test_base.h"
#include "xls/ir/node_util.h"
Expand Down
3 changes: 1 addition & 2 deletions xls/ir/fuzz_type_domain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ std::optional<int64_t> TypeProtoSize(const TypeProto& type_proto,
case TypeProto::TUPLE: {
int64_t total_size = 0;
for (const auto& element : type_proto.tuple_elements()) {
std::optional<int64_t> element_size =
TypeProtoSize(element, max_size);
std::optional<int64_t> element_size = TypeProtoSize(element, max_size);
if (!element_size.has_value()) {
return std::nullopt;
}
Expand Down
2 changes: 1 addition & 1 deletion xls/ir/interval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Interval Interval::ConvexHull(const Interval& lhs, const Interval& rhs) {
}

std::optional<Interval> Interval::Intersect(const Interval& lhs,
const Interval& rhs) {
const Interval& rhs) {
CHECK_EQ(lhs.BitCount(), rhs.BitCount());
CHECK(!lhs.IsImproper());
CHECK(!rhs.IsImproper());
Expand Down
1 change: 1 addition & 0 deletions xls/ir/interval_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "xls/ir/bits_ops.h"
#include "xls/ir/interval.h"
#include "xls/ir/interval_set.h"
#include "xls/ir/lsb_or_msb.h"
#include "xls/ir/node.h"
#include "xls/ir/ternary.h"
#include "xls/passes/ternary_evaluator.h"
Expand Down
2 changes: 0 additions & 2 deletions xls/ir/ir_parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

namespace xls {


using status_testing::StatusIs;
using ::testing::ElementsAre;
using ::testing::Eq;
Expand Down Expand Up @@ -1874,7 +1873,6 @@ block my_block(x: bits[32], y: bits[32]) {
ParsePackageAndCheckDump(input);
}


TEST(IrParserTest, ParseArrayIndex) {
const std::string input = R"(
fn foo(x: bits[32][6]) -> bits[32] {
Expand Down
7 changes: 4 additions & 3 deletions xls/ir/ir_scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "xls/common/status/status_macros.h"
#include "xls/ir/bits.h"
#include "xls/ir/number_parser.h"

namespace xls {
Expand Down Expand Up @@ -184,8 +185,8 @@ class Tokenizer {
int64_t content_start = index();
while (!EndOfString()) {
if (MatchSubstring(quote)) {
std::string_view content = std::string_view(
str_.data() + content_start, index() - content_start);
std::string_view content = std::string_view(str_.data() + content_start,
index() - content_start);
Advance(quote.size());
return content;
}
Expand Down Expand Up @@ -225,7 +226,7 @@ class Tokenizer {
// last matching character. min_chars is the minimum number of characters
// which are unconditionally captured.
std::string_view CaptureWhile(std::function<bool(char)> test_f,
int64_t min_chars = 0) {
int64_t min_chars = 0) {
int64_t start = index();
while (!EndOfString() &&
((index() < min_chars + start) || test_f(current()))) {
Expand Down
6 changes: 3 additions & 3 deletions xls/ir/ir_test_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ VerifiedPackage::~VerifiedPackage() {

absl::StatusOr<std::unique_ptr<VerifiedPackage>> IrTestBase::ParsePackage(
std::string_view text) {
XLS_ASSIGN_OR_RETURN(std::unique_ptr<VerifiedPackage> package,
Parser::ParseDerivedPackageNoVerify<VerifiedPackage>(
text, std::nullopt));
XLS_ASSIGN_OR_RETURN(
std::unique_ptr<VerifiedPackage> package,
Parser::ParseDerivedPackageNoVerify<VerifiedPackage>(text, std::nullopt));
XLS_RETURN_IF_ERROR(VerifyPackage(package.get()));
return std::move(package);
}
Expand Down
1 change: 1 addition & 0 deletions xls/ir/ir_test_base_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "gtest/gtest-spi.h"
#include "gtest/gtest.h"
#include "xls/common/status/matchers.h"
#include "xls/ir/function_base.h"

namespace xls {
namespace {
Expand Down
Loading

0 comments on commit 3b61ec9

Please sign in to comment.