News for hackers. Stuff that matters.
Re:X86 Register Encoding by pklausler on Tuesday November 01, 2016 @02:27PM (#12848790)
The OP perpetuates the mistaken assumption that x86-64 looks as it does because it extends good ol' 32-bit x86 encodings, which one might assume still work so well that one could run 32-bit code in 64-bit mode and have it still work.

Which is not the case at all. Those REX prefix bytes used to be perfectly good 32-bit x86 instructions that now simply don't work in 64-bit mode with their original encodings. So the "compatibility" between 32-bit and 64-bit modes is mythical -- the Opteron could have had a nice shiny new 64-bit programming model that was far less confusing than the dog's breakfast that is x86-64, but just didn't.

Re:X86 Register Encoding by ant6n on Tuesday November 01, 2016 @02:37PM (#12848884)
They probably wanted to re-use most of the x86-32 decoder that they had on the chip anyway.

Kind of strange, nowadays, an embedded armv8 cpu will come with multiple decoders (ARM32, thumb2, AARCH64).

Re:X86 Register Encoding by lisper on Tuesday November 01, 2016 @05:27PM (#12850183)
This. In today's world it is easy to support multiple instruction sets in the same silicon using the same registers and ALU. So why in the name of all that is holy does the x86 not have a nice clean 64-bit instruction set that you can swap in? It's all RISC under the hood anyway, why not give us access to it? The only explanation I can think of is that Intel wants to keep things complicated as a barrier to entry for competition.
Re:X86 Register Encoding by pcwalton on Tuesday November 01, 2016 @06:32PM (#12850711)
> It's all RISC under the hood anyway, why not give us access to it?

Presumably because it doesn't matter that much, so it isn't worth the investment for Intel.

It feels to me like people have trouble accepting that both of these are true: (1) RISC vs. x86 doesn't matter that much in practice; (2) technically speaking, RISC is a superior design to x86.

Re:X86 Register Encoding by nullc on Tuesday November 01, 2016 @07:44PM (#12851159)
> Presumably because it doesn't matter that much, so it isn't worth the investment for Intel.

Intel invested in a new instruction set (IA64). AMD did not.

The market chose AMD's offering.

Re:X86 Register Encoding by pcwalton on Tuesday November 01, 2016 @08:54PM (#12851477)
And the market also chose ARM's AArch64 instruction set, despite the ARM installed base being wider than x86 and a backwards incompatible break from the past. The secret? Supporting both ISAs and switching instruction sets on exceptions.

The lesson I take from history is that there is no need to maintain ISA compatibility as long as the old mode is accessible on a process level.

Re:X86 Register Encoding by imtringued on Wednesday November 02, 2016 @03:34AM (#12852892)
>The secret? Supporting both ISAs and switching instruction sets on exceptions.

The secret is that Apple controls their hardware/appstore and android apps are ISA independent.

Re:X86 Register Encoding by adrianratnapala on Wednesday November 02, 2016 @06:16AM (#12853392)
Whot?

Didn't the AMD64 architecture spank Itanium in the marketplace long before the iPhone became a big deal?

Re:X86 Register Encoding by qb45 on Wednesday November 02, 2016 @08:44AM (#12854089)
> It's all RISC under the hood anyway, why not give us access to it? The only explanation I can think of is that Intel wants to keep things complicated as a barrier to entry for competition.

It wasn't Intel but AMD that came up with x86-64. Intel (and HP) indeed wanted to give you a clean 64-bit design - Itanium. And yes, it was meant as a barrier to entry among other things. But AMD won because Itanic didn't run existing x86 software and generally turned out to be slower than Intel hyped.

As for the internal RISC, you won't get it because it changes from generation to generation (also between vendors) and these changes are part of why x86 keeps getting faster. Furthermore, AFAIK these internal ops aren't as dense as x86 to make them simpler to decode and fetching them from memory would make bandwidth more of a bottleneck.

Re:X86 Register Encoding by gsnedders on Tuesday November 01, 2016 @06:23PM (#12850636)
Related to this is the PPC615, an IBM project in the mid-90s, socket compatible with the original Pentium, and ran x86-32, PPC32, and PPC64 natively. (It got scrapped because all the signs looked like Intel was going to push IA-64 heavily, and rely on it's backwards compatibility for x86-32, hence an expectation x86-32 was soon to be legacy.)
Re:X86 Register Encoding by setpatchaddress on Tuesday November 01, 2016 @11:27PM (#12852043)
Do you have a reference for that? I've heard various things about the 615, one of which was that it wasn't ever a real project.
Re:X86 Register Encoding by gens on Tuesday November 01, 2016 @02:41PM (#12848922)
AFAIK the reason for amd64 being what it is are intels lawyers.
Re:X86 Register Encoding by eloff on Tuesday November 01, 2016 @03:51PM (#12849485)
That makes little sense, could you elaborate? AMD could have done anything they wanted with amd64 instruction encodings.
Re:X86 Register Encoding by gens on Tuesday November 01, 2016 @08:00PM (#12851240)
Well, not lawyers directly. More through lack of cooperation (due to competitive mentality).

http://www.agner.org/optimize/blog/read.php?i=25

Re:X86 Register Encoding by eloff on Wednesday November 02, 2016 @02:17AM (#12852674)
I don't see how that matters in this case, AMD took the lead on AMD64 and Intel had to copy them afterward. They really could have done anything they wanted. As someone else here mentioned it was probably more to re-use the existing investment in x86 decoders.
Re:X86 Register Encoding by gens on Wednesday November 02, 2016 @07:33AM (#12853702)
Amd64 encoding, as is the case with most x86 encodings, is longer then it should be. Due to the two companies not communicating/cooperating.

That is the one advantage that i think ARM has over x86/amd64. That ARM encoding is much shorter.

Re:X86 Register Encoding by eloff on Wednesday November 02, 2016 @10:24AM (#12855020)
You just repeated your point without adding anything new, that doesn't help your argument.
Re:X86 Register Encoding by gens on Thursday November 03, 2016 @12:02AM (#12861501)
They couldn't use the shorter code space. So no, they could not do whatever they wanted. (note that making a completely new instruction encoding scheme would fail for obvious reasons)
Re:X86 Register Encoding by eloff on Thursday November 03, 2016 @01:03PM (#12865785)
I disagree, 64bit mode did not have to have any kind of instruction compatibility. It could have been a completely new instruction encoding scheme. A 64bit process must run all 64bit code, there is no invoking 32bit code from a 64bit process on any modern OS for AMD64.
Re:X86 Register Encoding by ant6n on Thursday November 03, 2016 @08:28PM (#12869410)
And adding to that, they could've probably come up with some sort of 32bit per instruction risc structure where the the makeup overlaps with the cisc x86 encoding. For example, pack the 16 bits of a normal x86 instruction into the first bits of the risc, then add second source register and a bit or to each operand to increase the number of registers.
Re:X86 Register Encoding by bonzini on Tuesday November 01, 2016 @04:02PM (#12849593)
Those instructions were hard to optimize because of partial flags stalls. In the end because of this and because of strength reduction compilers were not generating that many INC and DEC instructions.