From b0609b1b20851cf33eb03a8f9491502121c4f127 Mon Sep 17 00:00:00 2001 From: iximeow Date: Mon, 7 Apr 2025 03:32:29 -0700 Subject: it is done (not all system, duplex, extender tho) --- src/display.rs | 11 +++++++++++ src/lib.rs | 42 ++++++++++++++++++++++++++---------------- 2 files changed, 37 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/display.rs b/src/display.rs index 5ce3d80..6349d4c 100644 --- a/src/display.rs +++ b/src/display.rs @@ -146,6 +146,16 @@ impl fmt::Display for Instruction { return write!(f, "{} = add(clb({}), {})", self.dest.as_ref().unwrap(), self.sources[0], self.sources[1]); } + Opcode::Vacsh => { + return write!(f, "{}, {} = {}({}, {})", + self.dest.as_ref().unwrap(), self.alt_dest.as_ref().unwrap(), + self.opcode, self.sources[0], self.sources[1]); + } + Opcode::Vminub => { + return write!(f, "{}, {} = {}({}, {})", + self.dest.as_ref().unwrap(), self.alt_dest.as_ref().unwrap(), + self.opcode, self.sources[0], self.sources[1]); + } Opcode::SfRecipa => { return write!(f, "{}, {} = {}({}, {})", self.dest.as_ref().unwrap(), self.alt_dest.as_ref().unwrap(), @@ -871,6 +881,7 @@ impl fmt::Display for Opcode { Opcode::Vmpyeh => { f.write_str("vmpyeh") }, Opcode::Vmpyweh => { f.write_str("vmpyweh") }, Opcode::Vmpywoh => { f.write_str("vmpywoh") }, + Opcode::Vrmpyweh => { f.write_str("vrmpyweh") }, Opcode::Vrmpywoh => { f.write_str("vrmpywoh") }, Opcode::Vrmpyu => { f.write_str("vrmpyu") }, Opcode::Vrmpysu => { f.write_str("vrmpysu") }, diff --git a/src/lib.rs b/src/lib.rs index 2e1aa74..0b94231 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -281,8 +281,6 @@ enum RoundingMode { Round, Cround, Raw, - Hi, - Lo, Pos, Neg, } @@ -293,8 +291,6 @@ impl RoundingMode { RoundingMode::Round => ":rnd", RoundingMode::Cround => ":crnd", RoundingMode::Raw => ":raw", - RoundingMode::Lo => ":lo", - RoundingMode::Hi => ":hi", RoundingMode::Pos => ":pos", RoundingMode::Neg => ":neg", } @@ -600,7 +596,6 @@ pub enum Opcode { Cmpyrwh, Cmpyi, Cmpyr, - Vacsh, Vcmpyi, Vcmpyr, Vmpybu, @@ -706,7 +701,6 @@ pub enum Opcode { Vmaxb, Vmaxub, Vminb, - Vminub, Vminuw, Vminh, Vminuh, @@ -820,6 +814,7 @@ pub enum Opcode { Vmpywoh, Vmpyweuh, Vmpywouh, + Vrmpyweh, Vrmpywoh, Vrmpyu, Vrmpysu, @@ -850,6 +845,8 @@ pub enum Opcode { AddClb, AddAdd, AddSub, + Vacsh, + Vminub, SfRecipa, SfInvsqrta, Any8VcmpbEq, @@ -6102,15 +6099,13 @@ fn decode_instruction< handler.on_source_decoded(Operand::gprpair(sssss)?)?; match opc { - o if o & 0b100011 == 0b100001 => { + o if o & 0b100011 == 0b000001 => { handler.on_opcode_decoded(Opcode::Vradduh)?; - rtt_star = true; saturate = false; shift_amt = 0; } o if o & 0b101111 == 0b001111 => { handler.on_opcode_decoded(Opcode::Vraddh)?; - rtt_star = true; saturate = false; shift_amt = 0; } @@ -6162,7 +6157,6 @@ fn decode_instruction< if o & 0b100000 == 0 { shift_amt = 0; } - rtt_star = true; } _other => { return Err(DecodeError::InvalidOpcode); @@ -6176,7 +6170,7 @@ fn decode_instruction< handler.shift_left(shift_amt)?; } if rtt_star { - handler.on_source_decoded(Operand::gpr_conjugate(ttttt))?; + handler.on_source_decoded(Operand::gprpair_conjugate(ttttt)?)?; } else { handler.on_source_decoded(Operand::gprpair(ttttt)?)?; } @@ -6190,6 +6184,7 @@ fn decode_instruction< handler.on_dest_decoded(Operand::gprpair(ddddd)?)?; handler.on_source_decoded(Operand::gprpair(sssss)?)?; let mut rtt_star = false; + let mut add_assign = true; match opc { 0b000010 => { @@ -6207,6 +6202,7 @@ fn decode_instruction< } 0b001100 => { handler.on_opcode_decoded(Opcode::Vcmpyr)?; + handler.saturate()?; } 0b010001 => { handler.on_opcode_decoded(Opcode::Vraddub)?; @@ -6242,7 +6238,7 @@ fn decode_instruction< handler.on_opcode_decoded(Opcode::Vrcmpys)?; handler.shift_left(1)?; handler.saturate()?; - handler.rounded(RoundingMode::Hi)?; + handler.raw_mode(RawMode::Hi)?; } 0b110001 => { handler.on_opcode_decoded(Opcode::Vrmpybsu)?; @@ -6254,12 +6250,13 @@ fn decode_instruction< o if o & 0b111100 == 0b111000 => { handler.on_opcode_decoded(Opcode::Vminub)?; handler.on_dest_decoded(Operand::pred(o & 0b11))?; + add_assign = false; } 0b111100 => { handler.on_opcode_decoded(Opcode::Vrcmpys)?; handler.shift_left(1)?; handler.saturate()?; - handler.rounded(RoundingMode::Lo)?; + handler.raw_mode(RawMode::Lo)?; } 0b000_100 | 0b100_100 => { handler.on_opcode_decoded(Opcode::Vdmpy)?; @@ -6288,7 +6285,7 @@ fn decode_instruction< handler.shift_left((opc >> 5) as u8)?; } 0b001_110 | 0b101_110 => { - handler.on_opcode_decoded(Opcode::Vrmpywoh)?; + handler.on_opcode_decoded(Opcode::Vrmpyweh)?; handler.shift_left((opc >> 5) as u8)?; } 0b001_111 | 0b101_111 => { @@ -6297,6 +6294,16 @@ fn decode_instruction< handler.rounded(RoundingMode::Round)?; handler.shift_left((opc >> 5) as u8)?; } + 0b010_101 | 0b110_101 => { + handler.on_opcode_decoded(Opcode::Vmpyweuh)?; + handler.saturate()?; + handler.shift_left((opc >> 5) as u8)?; + } + 0b010_111 | 0b110_111 => { + handler.on_opcode_decoded(Opcode::Vmpywouh)?; + handler.saturate()?; + handler.shift_left((opc >> 5) as u8)?; + } 0b011_101 | 0b111_101 => { handler.on_opcode_decoded(Opcode::Vmpyweuh)?; handler.saturate()?; @@ -6308,7 +6315,7 @@ fn decode_instruction< handler.shift_left((opc >> 5) as u8)?; } 0b011_111 | 0b111_111 => { - handler.on_opcode_decoded(Opcode::Vmpywoh)?; + handler.on_opcode_decoded(Opcode::Vmpywouh)?; handler.saturate()?; handler.rounded(RoundingMode::Round)?; handler.shift_left((opc >> 5) as u8)?; @@ -6319,10 +6326,13 @@ fn decode_instruction< } if rtt_star { - handler.on_source_decoded(Operand::gpr_conjugate(ttttt))?; + handler.on_source_decoded(Operand::gprpair_conjugate(ttttt)?)?; } else { handler.on_source_decoded(Operand::gprpair(ttttt)?)?; } + if add_assign { + handler.assign_mode(AssignMode::AddAssign)?; + } } 0b1011 => { // 1110|1011 -- cgit v1.1