summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2025-04-06 19:58:42 -0700
committeriximeow <me@iximeow.net>2025-04-06 19:58:42 -0700
commitddeacaf13a9e18e9cfe9083cd39f72b2ff78e773 (patch)
treedb0c98a1e9c591e427545c7d5f3d43ad0fc5a238 /src/lib.rs
parentdc1fb4bde1ea601e8be3a7ce3f4244344d1f8e3c (diff)
more pmpy, ignore shift_{left,right} with amt=0
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index fc82124..7ca9d8d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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,
];