mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 07:14:42 +01:00
Lowering of Branch / BranchIf / BranchWithArg / BlockArg. (#2904)
This gives us complete lowering of `if` expressions plus `and` and `or`. Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
c27f41c94b
commit
0d4d392d12
@@ -103,16 +103,24 @@ auto LoweringContext::BuildFunctionDefinition(SemanticsFunctionId function_id)
|
||||
function_lowering.SetLocal(param_storage, llvm_function->getArg(i));
|
||||
}
|
||||
|
||||
CARBON_VLOG() << "Lowering " << function.body_id << "\n";
|
||||
for (const auto& node_id : semantics_ir().GetNodeBlock(function.body_id)) {
|
||||
auto node = semantics_ir().GetNode(node_id);
|
||||
CARBON_VLOG() << "Lowering " << node_id << ": " << node << "\n";
|
||||
switch (node.kind()) {
|
||||
// Add the entry block to the worklist.
|
||||
function_lowering.GetBlock(function.body_id);
|
||||
|
||||
while (!function_lowering.block_worklist().empty()) {
|
||||
SemanticsNodeBlockId block = function_lowering.block_worklist().Pop();
|
||||
CARBON_VLOG() << "Lowering " << block << "\n";
|
||||
function_lowering.builder().SetInsertPoint(
|
||||
function_lowering.GetBlock(block));
|
||||
for (const auto& node_id : semantics_ir().GetNodeBlock(block)) {
|
||||
auto node = semantics_ir().GetNode(node_id);
|
||||
CARBON_VLOG() << "Lowering " << node_id << ": " << node << "\n";
|
||||
switch (node.kind()) {
|
||||
#define CARBON_SEMANTICS_NODE_KIND(Name) \
|
||||
case SemanticsNodeKind::Name: \
|
||||
LoweringHandle##Name(function_lowering, node_id, node); \
|
||||
break;
|
||||
#include "toolchain/semantics/semantics_node_kind.def"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user