3 ms·
> ARM introduced Thumb-2, with a mix of 2-byte and 4-byte instructions, in 2003. PowerPC and RISC-V also [...] x86 is still the weirdo. Both Thumb-2 and the RI
by cesarb 5y ago
> ARM introduced Thumb-2, with a mix of 2-byte and 4-byte instructions, in 2003. PowerPC and RISC-V also [...]
x86 is still the weirdo. Both Thumb-2 and the RISC-V C extension (I don't know about PowerPC) have only 2-byte and 4-byte instructions, aligned to 2 bytes; x86 instructions can vary from 1 to 15 bytes, with no alignment requirement.
- classichasclass 5y agoPower10 has prefixed instructions. These are essentially 64-bit instructions in two pieces. They are odd even (particularly?) to those of us who have worked with the architecture for a long time, and not much otherwise supports them yet. Their motivation is primarily to more efficiently represent constants and offsets.
- cryptonector 5y agoI suspect variable-length instructions are a big gain because you get to pack instructions more tightly and so have fewer cache misses. Though, obviously, it's going to depend on having an instruction set that yields shorter text for typical assembly than fixed-sized instructions would. (In a way, opcodes need a bit of Huffman encoding!) Any losses from having to do more decoding work are probably offset by having sufficiently deep pipelines and enough decoders.
- phdelightful 5y agoThe counterpoint is that variable-length decoding introduces sequential dependence in the decoding, i.e. you don’t know where instruction 2 starts until you’ve decoded instruction 1. This probably limits how many decoders you can have. If you know all your instructions are 4B you can basically decode as many as you want in parallel.
- gpderetta 5y agoI think what happen in practice is that the decoders still speculatively decode in parallel then drop all misdecoded instructions. Easy when instructions have only a couple of sizes. Hard and wasteful for something like x86.
- astrange 5y agoA larger problem is that they're bad for security; you can hide malicious instructions from static analysis by jumping into the middle of a cleaner one. Or use it to find more ROP gadgets, etc. I can imagine ways to deal with this, but x86 doesn't have them.
- chasil 5y agoARM Thumb actually licensed patents from Hitachi Super-H, who did this first. Supposedly, "MIPS processors [also] have a MIPS-16 mode." https://en.m.wikipedia.org/wiki/SuperH https://en.m.wikipedia.org/wiki/SuperH