cordillera 0.1.2

IR generation library for Sierra
Documentation
//! # Instructions Module
//! - Made to store instruction construction methods

use super::ir::IRNode;

/// Creates a new Int IR value
/// 
/// # Arguments
/// * `value` - The integer to build
/// 
/// # Examples
/// ```rust
/// let integer = builder.build_int(5)
/// ```
#[allow(dead_code)]
pub fn iconst(value: i64) -> IRNode {
    IRNode::ConstInt(value)
}
/// Creates a new Float IR value
/// 
/// # Arguments
/// * `value` - The Float to build
/// 
/// # Examples
/// ```rust
/// let float = builder.build_float(5)
/// ```
#[allow(dead_code)]
pub fn fconst(value: f64) -> IRNode {
    IRNode::ConstFloat(value)
}
/// Creates a new `iadd` instruction
/// 
/// # Arguments
/// * `left` - The left-hand-side Integer value
/// * `right` - The right-hand-side Integer value
/// 
/// # Examples
/// ```rust
/// let iadd_instruction = builder.iadd(IRNode::ConstInt(5), IRNode::ConstInt(6));
/// ```
#[allow(dead_code)]
pub fn iadd(left: IRNode, right: IRNode) -> IRNode {
    IRNode::IAdd {
        left: Box::new(left),
        right: Box::new(right)
    }
}
/// Creates a new `isub` instruction
/// 
/// # Arguments
/// * `left` - The left-hand-side Integer value
/// * `right` - The right-hand-side Integer value
/// 
/// # Examples
/// ```rust
/// builder.isub(IRNode::ConstInt(7), IRNode::ConstInt(2));
/// ```
#[allow(dead_code)]
pub fn isub(left: IRNode, right: IRNode) -> IRNode {
    IRNode::ISub {
        left: Box::new(left),
        right: Box::new(right)
    }
}
/// Creates a new `imul` instruction
/// 
/// # Arguments
/// * `left` - The left-hand-side Integer value
/// * `right` - The right-hand-side Integer value
/// 
/// # Examples
/// ```rust
/// builder.imul(IRNode::ConstInt(3), IRNode::ConstInt(6));
/// ```
#[allow(dead_code)]
pub fn imul(left: IRNode, right: IRNode) -> IRNode {
    IRNode::IMul {
        left: Box::new(left),
        right: Box::new(right)
    }
}
/// Creates a new `idiv` instruction
/// 
/// # Arguments
/// * `left` - The left-hand-side Integer value
/// * `right` - The right-hand-side Integer value
/// 
/// # Examples
/// ```rust
/// builder.idiv(IRNode::ConstInt(35), IRNode::ConstInt(5));
/// ```
#[allow(dead_code)]
pub fn idiv(left: IRNode, right: IRNode) -> IRNode {
    IRNode::IDiv {
        left: Box::new(left),
        right: Box::new(right)
    }
}
/// Creates a new `ineg` instruction
/// 
/// # Arguments
/// * `left` - The left-hand-side Integer value
/// * `right` - The right-hand-side Integer value
/// 
/// # Examples
/// ```rust
/// builder.ineg(IRNode::ConstInt(4));
/// ```
#[allow(dead_code)]
pub fn ineg(operand: IRNode) -> IRNode {
    IRNode::INeg {
        operand: Box::new(operand)
    }
}
/// Makes a new Variable Wrapper
/// 
/// # Arguments
/// * `name` - The name of the variable to wrap
/// 
/// # Examples
/// ```rust
/// let variable = builder.var_wrap("v0");
/// ```
#[allow(dead_code)]
pub fn v(name: &str) -> IRNode {
    IRNode::Variable(name.to_string())
}