From f42c92f0fba0a922a2b4bcf454da127f5ff44666 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Mon, 15 Jan 2024 13:06:32 +0100 Subject: [PATCH] add docs on if --- crates/concrete_codegen_mlir/src/codegen.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/concrete_codegen_mlir/src/codegen.rs b/crates/concrete_codegen_mlir/src/codegen.rs index 648d7ff..bd62647 100644 --- a/crates/concrete_codegen_mlir/src/codegen.rs +++ b/crates/concrete_codegen_mlir/src/codegen.rs @@ -267,6 +267,19 @@ fn compile_function_def<'ctx, 'parent: 'ctx>( )) } +/// Compile a if expression / statement +/// +/// This returns a block if any branch doesn't have a function return terminator. +/// For example, if the if branch has a return and the else branch has a return, +/// it wouldn't make sense to add a merging block and MLIR would give a error saying there is a operation after a terminator. +/// +/// The returned block is the merger block, the one we jump after processing the if branches. +/// +/// ```text +/// - then block - +/// - if (prev block) - < > merge block -- +/// - else block - +/// ``` fn compile_if_expr<'c, 'this: 'c>( session: &Session, context: &'c MeliorContext,