From: Jacob Lifshay Date: Fri, 28 Aug 2020 00:17:47 +0000 (-0700) Subject: add subf[o][.] instructions X-Git-Tag: v0.2.0~34 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e3f99e4360aabc84ab9d341dce7184b96ec4cd62;p=power-instruction-analyzer.git add subf[o][.] instructions --- diff --git a/src/instr_models.rs b/src/instr_models.rs index 8711e22..59ff2bb 100644 --- a/src/instr_models.rs +++ b/src/instr_models.rs @@ -53,6 +53,21 @@ pub fn addo(inputs: InstructionInput) -> InstructionResult { } } +create_instr_variants_ov_cr!(subf, subfo, subf_, subfo_, i64); + +pub fn subfo(inputs: InstructionInput) -> InstructionResult { + let ra = inputs.ra as i64; + let rb = inputs.rb as i64; + let (result, ov) = rb.overflowing_sub(ra); + let result = result as u64; + let ov32 = (rb as i32).overflowing_sub(ra as i32).1; + InstructionResult { + rt: Some(result), + overflow: Some(OverflowFlags { so: ov, ov, ov32 }), + ..InstructionResult::default() + } +} + create_instr_variants_ov_cr!(divde, divdeo, divde_, divdeo_, i64); pub fn divdeo(inputs: InstructionInput) -> InstructionResult { diff --git a/src/lib.rs b/src/lib.rs index 98880c2..6faa451 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -423,6 +423,24 @@ instrs! { "addo." } + // subf + #[enumerant = SubF] + fn subf(ra, rb) -> (rt) { + "subf" + } + #[enumerant = SubFO] + fn subfo(ra, rb) -> (rt, ov) { + "subfo" + } + #[enumerant = SubF_] + fn subf_(ra, rb) -> (rt, cr0) { + "subf." + } + #[enumerant = SubFO_] + fn subfo_(ra, rb) -> (rt, ov, cr0) { + "subfo." + } + // divde #[enumerant = DivDE] fn divde(ra, rb) -> (rt) {