Skip to content

Commit

Permalink
Add more than a single 'source-location' to the ir_to_csvs output
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 720335763
  • Loading branch information
allight authored and copybara-github committed Jan 27, 2025
1 parent 007a6ce commit dc5a335
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions xls/visualization/ir_viz/ir_to_csvs_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "absl/status/statusor.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/str_join.h"
#include "riegeli/bytes/fd_writer.h"
#include "riegeli/csv/csv_record.h"
#include "riegeli/csv/csv_writer.h"
Expand Down Expand Up @@ -97,7 +98,8 @@ constexpr riegeli::CsvHeaderConstant kNodeHeader = {"name",
"area_um",
"file",
"line",
"range"};
"range",
"all_locs"};
riegeli::CsvRecord NodeRecord(const viz::Node& node) {
return riegeli::CsvRecord(
*kNodeHeader,
Expand Down Expand Up @@ -131,7 +133,6 @@ riegeli::CsvRecord NodeRecord(const viz::Node& node) {
node.attributes().has_area_um()
? ToFieldValue(static_cast<int64_t>(node.attributes().area_um()))
: "",
// TODO(allight): Handle nodes with multiple associated locations.
node.loc_size() >= 1 && absl::c_all_of(node.loc(),
[&](auto loc) {
return loc.file() ==
Expand All @@ -141,6 +142,10 @@ riegeli::CsvRecord NodeRecord(const viz::Node& node) {
: "",
node.loc_size() == 1 ? ToFieldValue(node.loc()[0].line()) : "",
node.attributes().has_ranges() ? node.attributes().ranges() : "",
absl::StrJoin(node.loc(), "\n",
[](std::string* out, const auto& loc) {
absl::StrAppend(out, loc.file(), ":", loc.line());
}),
});
}

Expand Down

0 comments on commit dc5a335

Please sign in to comment.