diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/display.rs | 11 | ||||
-rw-r--r-- | src/lib.rs | 34 |
2 files changed, 39 insertions, 6 deletions
diff --git a/src/display.rs b/src/display.rs index f2b0e51..fc4fd3a 100644 --- a/src/display.rs +++ b/src/display.rs @@ -119,6 +119,14 @@ impl fmt::Display for Instruction { return write!(f, "{} = add({}, mpyi({}, {}))", self.dest.as_ref().unwrap(), self.sources[0], self.sources[1], self.sources[2]); }, + Opcode::MpyiPos => { + return write!(f, "{} = +mpyi({}, {})", self.dest.as_ref().unwrap(), + self.sources[0], self.sources[1]); + }, + Opcode::MpyiNeg => { + return write!(f, "{} = -mpyi({}, {})", self.dest.as_ref().unwrap(), + self.sources[0], self.sources[1]); + }, Opcode::AddClb => { return write!(f, "{} = add(clb({}), {})", self.dest.as_ref().unwrap(), self.sources[0], self.sources[1]); @@ -636,7 +644,8 @@ impl fmt::Display for Opcode { Opcode::Vnegh => { f.write_str("vnegh") }, Opcode::Vcnegh => { f.write_str("vcnegh") }, - Opcode:: Pmpyw => { f.write_str("pmpyw") }, + Opcode::Pmpyw => { f.write_str("pmpyw") }, + Opcode::Vpmpyh => { f.write_str("vpmpyh") }, Opcode::Lfs => { f.write_str("lfs") }, Opcode:: Vxaddsubh => { f.write_str("vxaddsubh") }, @@ -611,6 +611,7 @@ pub enum Opcode { Vrmpyh, Pmpyw, + Vpmpyh, Lfs, Vxaddsubh, @@ -1464,6 +1465,11 @@ impl<T: yaxpeax_arch::Reader<<Hexagon as Arch>::Address, <Hexagon as Arch>::Word let flags = &mut self.instructions[self.instruction_count as usize].flags; assert!(flags.shift_left.is_none()); assert!(flags.shift_right.is_none()); + // if the result would be shifted by zero, ignore it so as to not print + // <<0 when rendering the instruction. + if shiftamt == 0 { + return Ok(()); + } flags.shift_left = Some(shiftamt); Ok(()) } @@ -1471,6 +1477,11 @@ impl<T: yaxpeax_arch::Reader<<Hexagon as Arch>::Address, <Hexagon as Arch>::Word let flags = &mut self.instructions[self.instruction_count as usize].flags; assert!(flags.shift_left.is_none()); assert!(flags.shift_right.is_none()); + // if the result would be shifted by zero, ignore it so as to not print + // >>0 when rendering the instruction. + if shiftamt == 0 { + return Ok(()); + } flags.shift_right = Some(shiftamt); Ok(()) } @@ -5682,6 +5693,11 @@ fn decode_instruction< handler.on_dest_decoded(Operand::gpr(reg_b0(inst)))?; handler.on_source_decoded(Operand::gpr(sssss))?; handler.on_source_decoded(Operand::imm_i8(i as i8))?; + if op_hi < 0b100 { + handler.assign_mode(AssignMode::AddAssign)?; + } else { + handler.assign_mode(AssignMode::SubAssign)?; + } } 0b0011 => { let uuuuu = reg_b0(inst); @@ -5722,7 +5738,10 @@ fn decode_instruction< handler.on_source_decoded(Operand::gpr_high(ttttt))?; } - handler.shift_left((op_hi >> 2) & 1)?; + let shift = (op_hi >> 2) & 1; + if shift != 0 { + handler.shift_left(shift)?; + } } 0b0101 => { // some more mpy @@ -5736,7 +5755,10 @@ fn decode_instruction< handler.on_opcode_decoded(Opcode::Vmpyh)?; handler.on_source_decoded(Operand::gprpair(sssss)?)?; handler.on_source_decoded(Operand::gprpair(ttttt)?)?; - handler.shift_left((opc >> 5) as u8)?; + let shift = opc >> 5; + if shift != 0 { + handler.shift_left((opc >> 5) as u8)?; + } handler.saturate()?; return Ok(()); } @@ -5765,14 +5787,16 @@ fn decode_instruction< handler.on_source_decoded(Operand::gpr(ttttt))?; + eprintln!("opc: {:05b}", opc); + static OPCODES: [Option<Opcode>; 64] = [ Some(Mpy), Some(Cmpyi), Some(Cmpyr), None, None, None, None, None, - Some(Mpyu), Some(Vmpybsu), None, Some(Pmpyw), None, None, None, None, None, None, None, None, None, None, None, None, - None, Some(Vmpybu), None, None, None, None, None, None, + Some(Mpyu), Some(Vmpybsu), None, None, None, None, None, Some(Pmpyw), None, None, None, None, None, None, None, None, - None, None, None, None, None, None, None, Some(Vmpyh), + None, Some(Vmpybu), None, None, None, None, None, None, None, None, None, None, None, None, None, None, + None, None, None, None, None, None, None, Some(Vpmpyh), None, None, None, None, None, None, None, None, ]; |