use crate::{
Error, Register, Result,
proc::{DispatchIsaOp, fhe_processor::FheProcessor},
tomasulo::{registers::RobEntryRef, tomasulo_processor::RetirementInfo},
unwrap_registers,
};
impl FheProcessor {
pub fn loadi(
&mut self,
retirement_info: RetirementInfo<DispatchIsaOp>,
dst: RobEntryRef<Register>,
imm: u32,
width: u32,
instruction_id: usize,
pc: u32,
) {
let loadi_impl = || -> Result<()> {
unwrap_registers!((mut dst));
let in_range_unsigned = (imm as u64) < (1 << width);
let in_range_signed_neg = imm >= 0xFFFFFFFF << (width - 1);
if !in_range_unsigned && !in_range_signed_neg {
return Err(Error::out_of_range(instruction_id, pc));
}
*dst = Register::Plaintext {
val: imm as u128 & ((1 << width) - 1),
width,
};
FheProcessor::retire(&retirement_info, Ok(()));
Ok(())
};
if let Err(e) = loadi_impl() {
FheProcessor::retire(&retirement_info, Err(e));
}
}
}