Add formatted textual IR output (#3056)

Add a textual IR format to the toolchain.

The exact details of the format are somewhat arbitrary right now, and I
expect them to change as we refine the semantics IR model, but at the
moment they're somewhat directly following the current structure of the
IR.

Semantics tests currently test both the "raw" format, which shows the
details of the representation, and the textual format, which is somewhat
higher level. We may want to revisit that decision once the textual
format is a bit more stable, and test only the textual format in most of
these tests, but for now it seems prudent to keep both sets of tests.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
Richard SmithandChandler Carruth authored and GitHub committed 2023-08-10 19:41:39 +00:00
1 parent fc5a9541ce
commit 6cbf280a68
140 files changed
+3127 -64

No files matched your search

@@ -27,7 +27,11 @@ static auto BuildFunctionDeclaration(SemanticsContext& context)
// Add the callable.
auto function_id = context.semantics_ir().AddFunction(
{.name_id = name_context.unresolved_name_id,
{.name_id =
name_context.state ==
SemanticsDeclarationNameStack::Context::State::Unresolved
? name_context.unresolved_name_id
: SemanticsStringId(SemanticsStringId::InvalidIndex),
.param_refs_id = param_refs_id,
.return_type_id = return_type_id,
.body_block_ids = {}});