Skip to main content

xir_scf/
lib.rs

1//! Simple control flow operations.
2
3use xir::{Block, Context, Operation, Span, Type};
4
5/// An `if` operation.
6pub fn r#if<'a>(context: &'a Context<'a>, types: &[Type<'a>], span: Span<'a>) -> Operation<'a> {
7    Operation::new(context, "scf.if", &[], types, [], span)
8}
9
10/// A `while` operation.
11pub fn r#while<'a>(
12    context: &'a Context<'a>,
13    types: &[Type<'a>],
14    before: Block<'a>,
15    after: Block<'a>,
16    span: Span<'a>,
17) -> Operation<'a> {
18    Operation::new(context, "scf.while", &[], types, [before, after], span)
19}
20
21/// A `yield` operation.
22pub fn r#yield<'a>(context: &'a Context<'a>, types: &[Type<'a>], span: Span<'a>) -> Operation<'a> {
23    Operation::new(context, "scf.while", &[], types, [], span)
24}