On 4/22/2012 11:19 PM, Scott Wood wrote:
> On 2012-04-19, BGB<
cr8...@hotmail.com> wrote:
>> I will disagree with the OP though for asserting that ARM is less ugly
>> than x86.
>>
>> IMHO, at the level of the ISA, ARM is considerably more ugly, and far
>> less internally consistent, than is the x86 ISA.
>>
>> for example, at least x86 has fairly consistent instruction encoding
>> rules. for ARM, instruction layout varies from one instruction to the
>> next (many operands are irregularly-placed bit-fields), and based on
>> whether it is 32-bit ARM instructions, or Thumb / Thumb-2 instructions,
>> or Jazelle / ThumbEE, as well as for whether certain ISA features are
>> available or not (depends on both mode and ISA version), ...
>
> x86 doesn't have instruction set extensions that must be tested for?
>
there are differences:
most extensions don't dramatically change the way the basic ISA works;
usually, after a while certain features become "standard" and are
present on all later CPUs (for example, the present state of SSE and
SSE2, ...), and thus no longer need testing.
likewise, nearly all are either available or not available, so it is
more about checking CPUID bits.
>> on x86, it is also fairly trivial to get an immediate loaded into a
>> register, but on ARM it is far less trivial (the assembler may in-fact
>> emit a long instruction chain and/or load from memory).
>
> That's the price you pay for fixed-length (and reasonable-length)
> instructions. It's more or less the same on any RISC, though some (like
> ARM) may need longer instruction chains than others (when not loading from
> memory), due to the smaller immediate value size.
>
it *can* be done better, including with fixed-width.
also, Thumb is arguably variable-width, given that instructions may
require a variable number of 16-bit words.
>> likewise, call and jump instructions may require several instruction
>> words, ... (and be longer than their x86 equivalents).
>
> Do you have benchmarks to show that this is a serious problem?
>
it does waste memory and adds complexity to writing assemblers and
linkers. it is no longer possible to simply perform a relocation on a
word, now the linker has to take things like the instruction encoding
into account.
as for cleanliness / elegance aspects of the ISA, consistent instruction
coding is much more important than performance, which was what all this
was about.
>> not that x86 is by any means perfect though.
>
> Indeed.
>
>> ARM has an advantage related to small die size and power use, but I will
>> contend that being "clean" or "elegant" are not merits for the architecture.
>
> It's not the cleanest RISC I've seen (Alpha or MIPS would probably have to
> take the prize there), but it's cleaner than x86.
>
I will disagree that it is cleaner than x86.
IMO, it is much uglier, especially in the case of Thumb/Thumb2/ThumbEE
modes.
I am not complaining so much here about RISCs in general, but rather the
specifics of ARM.
if everything were the 32-bit ARM instructions, I would not be
complaining so much, except that many use cases of ARM, such as
targeting Android, generally use Thumb code.
a big issue with thumb is that nearly every opcode has its own layout,
rather than:
most other RISCs, which have only one of several instruction forms;
x86, which (effectively) has one of several basic instruction forms.
how much variability is in x86 normally?:
<op>|r op reg
<op>|r,i op reg, imm
<op>/r op reg, mem / op mem, reg
<op>/r,i op reg, mem, imm / op mem, reg, imm
<op>/0-7 op mem
<op>/0-7,i op mem, imm
for the most part, this is fairly consistently applied across the entire
ISA, with few exceptions.
in ARM, and especially in Thumb/Thumb2, most values are placed into
bit-fields, with little regularity as to where in the instruction word
the value is placed. this makes instruction encoding much more complex.
IMO, the only thing "particularly" ugly about x86 instruction encoding
is the abuse of prefixes common in composing many opcodes.
but, if the prefixes are simply treated as fixed byte patterns or escape
codes, it is no longer really a significant issue.
>> much of the large die-size and power-use of x86 is more due to getting
>> high performance (lots of cache, multiple ALUs and FPUs, execution
>> pipelines, ...), and not because the architecture is inherently messy or
>> complicated.
>
> Sure, but it wouldn't hurt (other than compatibility) if the architecture
> were cleaner.
>
the issue could be partly that of "strict" compatibility, vs "relative"
compatibility.
for example:
what if the CPU removed real-mode and legacy PMode (IOW: CPU only has
Long-Mode and 32-bit Compatibility Mode) ?...
...
the CPU would no longer be strictly compatible (and would some OS
support), but from the level of applications it wouldn't necessarily
look all that much different.