diff --git a/crates/victory-shader/src/gfx10/mod.rs b/crates/victory-shader/src/gfx10/mod.rs index 57e6ea2..f89a382 100644 --- a/crates/victory-shader/src/gfx10/mod.rs +++ b/crates/victory-shader/src/gfx10/mod.rs @@ -56,12 +56,16 @@ pub struct Instruction { pub opcode: u16, /// Every dword of the instruction, including literals and extra dwords. pub words: Vec, + /// [`name`] of `encoding` and `opcode`, resolved once at decode time. + /// The translator asks about every instruction eight times; the table is + /// a binary search. + name: Option<&'static str>, } impl Instruction { /// AMD's name for the opcode, if it is in our table. pub fn name(&self) -> Option<&'static str> { - name(self.encoding, self.opcode) + self.name } } @@ -282,11 +286,13 @@ fn instruction(code: &[u8], offset: usize) -> Result { _ => return Err(isa(offset, "unknown encoding")), } }; + let opcode = opcode as u16; Ok(Instruction { offset, encoding, - opcode: opcode as u16, + opcode, words: (0..len).map(word).collect::>()?, + name: name(encoding, opcode), }) }