You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Found that when writing code like ; mov QWORD [buffer + offset as i32], temp where offset is a immediate value this crate will unconditionally emit relative instructions. When explicitly checking for when offset is zero and emitting ; mov QWORD [buffer], temp reduces my emitted code significantly (~10%).
Maybe this crate could check if immediate values are zero and choose to emit smaller instructions.
The text was updated successfully, but these errors were encountered:
To aid with size reduction it would also be nice to have a "smallest" size annotation. The assembler could then choose to use add/sub/jmp instructions with the smallest possible size for the immediate value. i.e. ; add r14, AUTO s.len() as _
with s.len() < 255 -> 49 83 c6 XX
else -> 49 81 c6 XX XX XX XX
The crate is built with the idea in mind that instruction sizes (and the generated instruction) should be predictable from the code, to allow things like instruction patching / hotswapping. The behaviour you mentioned first would need some kind of annotation as well to allow it.
I'm having trouble thinking of how to implement this properly though. The x64 instruction set is not regular at all, and just selecting the right instruction is already extremely hairy. Would probably have to just generate the three size possibilities, pass them each through it and see which compiles. And then figure out how to generate branching code from the backend (which also expects somewhat stable sizes).
Summarizing: I might consider it at some point but this is fairly low priority, especially considering the same behaviour can be implemented by the user easily.
Found that when writing code like
; mov QWORD [buffer + offset as i32], temp
where offset is a immediate value this crate will unconditionally emit relative instructions. When explicitly checking for when offset is zero and emitting; mov QWORD [buffer], temp
reduces my emitted code significantly (~10%).Maybe this crate could check if immediate values are zero and choose to emit smaller instructions.
The text was updated successfully, but these errors were encountered: