Modify SemanticsIR printing to produce stable output on builtin changes. (#2702)

These changes should make output more stable when builtins are added to semantics. By omitting them from nodes and printing nodes as "relative to the last builtin", I should be able to add and remove builtins without automatically affecting every test. Also by printing builtin nodes as `nodeNameOfBuiltin`, it's a little easier to understand what's going on (for me, at least).
This commit is contained in:
Jon Ross-Perkins
2023-03-22 10:24:03 -07:00
committed by GitHub
parent e89fb83e7e
commit 4ca2e81877
46 changed files with 604 additions and 813 deletions
+11 -2
View File
@@ -71,7 +71,8 @@ static auto PrintList(llvm::raw_ostream& out, llvm::StringLiteral name,
out << "]\n";
}
auto SemanticsIR::Print(llvm::raw_ostream& out) const -> void {
auto SemanticsIR::Print(llvm::raw_ostream& out, bool include_builtins) const
-> void {
out << "cross_reference_irs_size: " << cross_reference_irs_.size() << "\n";
PrintList(out, "calls", calls_);
@@ -79,7 +80,15 @@ auto SemanticsIR::Print(llvm::raw_ostream& out) const -> void {
PrintList(out, "integer_literals", integer_literals_);
PrintList(out, "real_literals", real_literals_);
PrintList(out, "strings", strings_);
PrintList(out, "nodes", nodes_);
out << "nodes: [\n";
for (int i = include_builtins ? 0 : SemanticsBuiltinKind::ValidCount;
i < static_cast<int>(nodes_.size()); ++i) {
const auto& element = nodes_[i];
out.indent(Indent);
out << element << ",\n";
}
out << "]\n";
out << "node_blocks: [\n";
for (const auto& node_block : node_blocks_) {