TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

X86 Register Encoding

100 pointsby eklitzkeover 8 years ago

5 comments

pcwaltonover 8 years ago
LLVM doesn&#x27;t actually prefer the lower registers when doing register allocation. IIRC, sunfish told me that GCC doesn&#x27;t either. It would be interesting to add features that try to minimize code size to the register allocator, but no compiler I know of actually does this.<p>Partially as a consequence of this, the REX prefixes take up a lot of space in most x86-64 instruction streams. In fact, the average size of each instruction is almost exactly 4 bytes, exactly the same as in classic 32-bit RISC architectures. (This is why I dislike it when people link to that old Linus post about how x86 is better than RISC architectures because of code size; it may have been true then, but not now.)
评论 #12849398 未加载
评论 #12849411 未加载
评论 #12849443 未加载
评论 #12849038 未加载
评论 #12850131 未加载
stephencanonover 8 years ago
N.B. the &quot;Volatile?&quot; column is specific to the <i>Windows</i> calling conventions. Under the Sys V calling conventions (i.e. what the world outside of Redmond uses), RDI and RSI are volatile (and used for passing the first two integer arguments).
pklauslerover 8 years ago
The OP perpetuates the mistaken assumption that x86-64 looks as it does because it extends good ol&#x27; 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.<p>Which is not the case at all. Those REX prefix bytes used to be perfectly good 32-bit x86 instructions that now simply don&#x27;t work in 64-bit mode with their original encodings. So the &quot;compatibility&quot; 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&#x27;s breakfast that is x86-64, but just didn&#x27;t.
评论 #12848884 未加载
评论 #12849593 未加载
alexanderstockoover 8 years ago
The REX prefix: <a href="http:&#x2F;&#x2F;wiki.osdev.org&#x2F;X86-64_Instruction_Encoding#REX_prefix" rel="nofollow">http:&#x2F;&#x2F;wiki.osdev.org&#x2F;X86-64_Instruction_Encoding#REX_prefix</a>
bogomipzover 8 years ago
I had a question about this statement in the artcile:<p>&quot;The C calling convention on x86 systems specifies that callees need to save certain registers.&quot;<p>Practically speaking is this the prologue that that C run time - crt0.o provides automatically&#x2F;implicitly?
评论 #12852126 未加载
评论 #12852075 未加载