pub struct ShortInsts {
pub prefix: &'static str,
pub zeroing: &'static [Zeroed],
pub narrowing: &'static [Narrowed],
pub testing: &'static [Tested],
pub stepping: &'static [Stepped],
pub copying: &'static [Copied],
}Expand description
The shorter spellings this target has.
Fields§
§prefix: &'static strWhat a rule file and the machine IR put in front of this target’s opcodes, such as x64..
zeroing: &'static [Zeroed]Every instruction that puts a constant in a register and has a shorter way of putting zero there.
narrowing: &'static [Narrowed]Every instruction that puts a constant in a register and has a narrower one that writes the same register and clears the rest of it.
testing: &'static [Tested]Every instruction that compares a register against a constant and has a shorter one that asks the same thing of the register against itself when the constant is zero.
stepping: &'static [Stepped]Every instruction that adds a constant to a register and has a shorter one that carries the number in its opcode, for the one or two numbers that shorter one is about.
copying: &'static [Copied]Every instruction that works out an address and keeps it, and the move that says the same thing when the address is one register and nothing else.
Implementations§
Source§impl ShortInsts
impl ShortInsts
Sourcepub fn zeroed(&self, name: &str) -> Option<&'static str>
pub fn zeroed(&self, name: &str) -> Option<&'static str>
The shorter way of writing zero into a register, for the instruction of that name.
Sourcepub fn narrowed(&self, name: &str) -> Option<Narrowed>
pub fn narrowed(&self, name: &str) -> Option<Narrowed>
The narrower instruction that writes the same register, for the instruction of that name.
Sourcepub fn tested(&self, name: &str) -> Option<&'static str>
pub fn tested(&self, name: &str) -> Option<&'static str>
The shorter way of comparing a register against zero, for the instruction of that name.
Sourcepub fn stepped(&self, name: &str, by: i64) -> Option<&'static str>
pub fn stepped(&self, name: &str, by: i64) -> Option<&'static str>
The shorter way of adding that number to a register, for the instruction of that name.
Both halves are the key. One instruction has a shorter spelling for more than one number, since an addition of one and a subtraction of one are each other going the other way, and which of the two shorter instructions is meant depends on which number was written.
Sourcepub fn copied(&self, name: &str) -> Option<&'static str>
pub fn copied(&self, name: &str) -> Option<&'static str>
The move that says the same thing as the address computation of that name.
Only the name is the key, because what makes the two the same is the addressing mode rather than anything about the opcode, and the addressing mode is not a thing a table of names could hold. The pass is what looks at it.
Sourcepub fn steps(&self, name: &str) -> bool
pub fn steps(&self, name: &str) -> bool
Whether the instruction of that name is one of the shorter ones that leaves the carry alone.
Asked of an instruction the walk is looking past rather than of one it is thinking about rewriting, so what it is really asking is whether this instruction ends the life of a carry something in front of it set. One of these does not, which is the whole of what makes it shorter and the whole of what makes the rewrite conditional.