From: Jacob Lifshay Date: Fri, 16 Oct 2020 22:32:24 +0000 (-0700) Subject: add cmpli X-Git-Tag: v0.2.0~6 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=50cab0eace9512917b46538ec2ee3fec350dc3a0;p=power-instruction-analyzer.git add cmpli --- diff --git a/src/instr_models.rs b/src/instr_models.rs index ae3c23c..5d005de 100644 --- a/src/instr_models.rs +++ b/src/instr_models.rs @@ -784,3 +784,25 @@ pub fn cmpwi(inputs: InstructionInput) -> InstructionResult { ..InstructionOutput::default() }) } + +pub fn cmpldi(inputs: InstructionInput) -> InstructionResult { + let ra = inputs.try_get_ra()? as u64; + let immediate = inputs.try_get_immediate_u16()? as u64; + let so = inputs.try_get_overflow()?.so; + let cr0 = ConditionRegister::from_ordering(ra.cmp(&immediate), so); + Ok(InstructionOutput { + cr0: Some(cr0), + ..InstructionOutput::default() + }) +} + +pub fn cmplwi(inputs: InstructionInput) -> InstructionResult { + let ra = inputs.try_get_ra()? as u32; + let immediate = inputs.try_get_immediate_u16()? as u32; + let so = inputs.try_get_overflow()?.so; + let cr0 = ConditionRegister::from_ordering(ra.cmp(&immediate), so); + Ok(InstructionOutput { + cr0: Some(cr0), + ..InstructionOutput::default() + }) +} diff --git a/src/lib.rs b/src/lib.rs index 0e85562..8fa9eec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -807,6 +807,16 @@ instructions! { fn cmpwi(Ra, ImmediateS16, Overflow) -> (CR0) { "cmpwi" } + + // cmpli + #[enumerant = CmpLDI] + fn cmpldi(Ra, ImmediateU16, Overflow) -> (CR0) { + "cmpldi" + } + #[enumerant = CmpLWI] + fn cmplwi(Ra, ImmediateU16, Overflow) -> (CR0) { + "cmplwi" + } } // must be after instrs macro call since it uses a macro definition