指令集如何标准化?
我的理解是AMD64是AMD发明的,作为x86的64位版本。
AMD 和 Intel 都添加了新指令(因为它们是仅有的两家实现 AMD64 的公司)。实际上,不存在像 C++ 那样的中央标准。
当添加新指令时,它们通常是“集合”的一部分,例如 sse 或 avx。
在我的研究中,有些指令的指定是不一致的,即并不总是清楚一条指令属于哪一个集合。
什么定义了指令集?对于哪些指令属于哪些指令集是否存在普遍协议,或者是由惯例决定的?
My understanding is the AMD64 was invented by AMD as a 64 bit version of x86.
New instructions are added by both AMD and Intel (because those are the only two companies that implement AMD64). In effect, there is no central standard like there is in C++.
When new instructions are added, they are usually a part of a "set" like sse or avx.
In my research, the designation for some instructions is inconsistent, ie, it's not always clear which set an instruction belongs to.
What defines the instruction sets? Is there a universal agreement on what instructions are in which instruction sets or is it decided by convention?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
80x86 本质上是 8086 指令集(从 20 世纪 70 年代末开始)加上不同供应商添加的“可选”扩展;许多扩展变得无处不在(一段时间后所有供应商都支持有效的“伪标准”);具有交叉许可协议,用于允许一个供应商提供另一供应商的扩展的兼容实现。
随着时间的推移,这(所有“可选但普遍存在”的扩展)变得变得尴尬。帮助解决这个问题; AMD 创建了“AMD64”,这是给一大组不同扩展(来自不同供应商)的名称,以形成新的基线。它由长模式(AMD 的 64 位扩展,它扩展了 Intel 的一些不同的扩展 - 主要是 32 位保护模式扩展和“PAE 分页”扩展),加上 SSE(来自 Intel),加上 SYCALL(来自 AMD),加上许多较小/较旧的东西(TSC、CPUID、INVLPG、MSR,... - 主要来自英特尔)。当然,交叉许可协议意味着其他供应商可以实现所有这些不同的扩展(并因此实现新的“AMD64”基线);因此,Intel 和 VIA 都在其 CPU 中添加了对 AMD64 的支持。
其他所有 ISA 的相似之处在于都有基本标准(例如 Aarch64)和供应商特定扩展(例如 Apple 添加到其 M1 芯片中的矩阵和机器学习加速器)。根本区别在于,没有任何其他 ISA 的交叉许可协议(例如,如果高通想要实施苹果的扩展,他们可能最终会打上几年的法律战)。
另一个区别是 80x86 有一个明确的方法让软件识别可选扩展(通过 cpuid 指令),该扩展被分为供应商特定范围(例如,从 0x0000000 开始的 Intel 扩展/功能、虚拟机管理程序扩展) /features 从 0x4000000 开始,AMD 的扩展/功能从 0x8000000 开始,Transmeta 的开始于0x8086000,Centaur/VIA 从 0xC000000 开始)。这使得供应商可以随时添加自己的扩展,而不会引起冲突;并允许软件在所有供应商的 CPU(以及来自同一供应商的旧 CPU 和新 CPU)上正常工作,方法是询问 CPU 它支持哪些功能,然后启用对 CPU 提供的扩展的支持(例如粗略地像“
if( CPU_supports(thing) ) { use_thing(); } else { use_alternative() }
);每个供应商都定义了自己的扩展(无需浪费 3 年时间与竞争对手争论,最终达成“由委员会设计”的妥协方案)。
请注意,有时这意味着您会获得竞争性的替代扩展(例如 3DNow 与 SSE,或 SYSCALL 与 SYSENTER,或 AMD 的虚拟化扩展与 Intel 的虚拟化扩展,或...)。他们中很少有人正式死亡(例如 3DNow)。
另一件值得一提的事情是,对于 ISA 本身来说,非常强调向后兼容性。你几乎可以保证明年的CPU仍然能够运行40年前的16位软件。无论好坏,破坏向后兼容性的是其他一切(操作系统、设备、固件……),而不是 ISA 或扩展。
80x86 is/was essentially the 8086 instruction set (from late 1970s) plus "optional" extensions added by different vendors; where a lot of extensions became ubiquitous (effectively "pseudo standards" supported by all vendors after a while); with a cross-licensing agreement used to allow one vendor to provide a compatible implementation of another vendor's extension.
Over time this (all the "optional but ubiquitous" extensions) grew to become awkward. To help fix that; AMD created "AMD64", which is the name given to a large set of different extensions (from different vendors) to form a new base-line. It consists of long mode (a 64-bit extension from AMD, that extends a few different extension from Intel - mainly a 32-bit protected mode extension and a "PAE paging" extension), plus SSE (from Intel), plus SYCALL (from AMD), plus lots of smaller/older things (TSC, CPUID, INVLPG, MSRs, ... - mostly from Intel). Of course the cross-licensing agreement meant that other vendors could implement all of these different extensions (and therefore implement the new "AMD64" base-line); and so both Intel and VIA added support for AMD64 in their CPUs.
Every other ISA is similar in that there's a base standard (e.g. Aarch64) and vendor specific extensions (e.g. the matrix and machine learning accelerators Apple added to their M1 chips). The fundamental difference is that there is no cross-licensing agreement in place for any other ISA (e.g. if Qualcomm wanted to implement Apple's extensions they'll probably end up fighting a legal battle for several years).
The other difference is that 80x86 has a clear way for software to identify optional extensions (via. the
cpuid
instruction), which is split into vendor specific ranges (e.g. Intel's extensions/features starting at 0x0000000, hypervisor extensions/features starting at 0x4000000, AMD's extensions/features starting at 0x8000000, Transmeta's starting at 0x8086000, Centaur/VIA's starting at 0xC000000). This allows vendors to add their own extensions whenever they want without causing conflicts; and allows software to work fine on all vendors CPUs (and old CPUs and new CPUs from the same vendor) by asking the CPU which features it supports and then enabling support for the extensions the CPU provides (e.g. crudely like "if( CPU_supports(thing) ) { use_thing(); } else { use_alternative(); }
).Each vendor defines their own extensions (without wasting 3 years arguing with competitors to end up with a "designed by committee" compromise).
Note that sometimes this means you get competing alternative extensions (e.g. 3DNow vs. SSE, or SYSCALL vs. SYSENTER, or AMD's virtualization extensions vs. Intel's, or...). Rarely one of them becomes officially dead (e.g. 3DNow).
The other thing that's worth mentioning is that, for the ISA itself, there's a strong emphasis on backward compatibility. You can almost guarantee that next year's CPU will still be capable of running 16-bit software from 40 years ago. For better or worse, it's everything else (the OS, the devices, the firmware, ..) and not the ISA or extensions that breaks backward compatibility.
不存在这样的事情,我也无法想象怎么会有。
英特尔的一名或多名人员为其产品定义了指令集。如果 AMD 碰巧能够制作合法的克隆(他们已经做到了),并且作为该协议的一部分,或者甚至可能没有,但会受到一些惩罚,他们会添加额外的指令/功能。首先,如果他们想要兼容的话,他们就应该这样做并保持一定的兼容感。其次,如果他们想要添加扩展并且能够逃脱惩罚,那完全是 AMD 一名或多名工程师的责任。然后,如果英特尔去制定一些新指令,那就是一名或多名英特尔工程师。随着历史的发展,你会看到其他完全无关的团体,比如 gnu 工具人员、微软工具人员和一系列其他人员,以及使用工具和制造产品的操作系统人员,直接或间接选择使用哪些指令。随着历史的发展,其中一些仅英特尔或仅指令可能会受到一方或另一方的青睐。如果该方碰巧有影响力(微软 Windows、Linux 等),以至于对英特尔或 AMD 施加压力,要求其以某种方式倾斜,那么他们就是在公司内部的管理和工程部门这样做的。他们可以选择不遵循用户想要的,并尝试将用户推向他们的方向。一种或另一种产品线的简单销售可能决定各方决策的成功或失败。
我想不出人们实际上同意的一个或多个标准,即使他们可能有穿着带有相同徽标的衬衫参加标准机构的代表。从 pcie 到 java 再到 C++ 等(C 和 C++ 非常糟糕,因为它们是编写出来的,然后试图标准化,这只是补丁,留给各个编译器作者的解释选择太多了)。您希望在商业上获胜,从而使自己与其他人区分开来。我有一个 x86 克隆,它便宜得多,但性能与 intel 一样好 95%。另外,我添加了我自己的英特尔没有的东西,我付钱给员工添加开源东西,使这些开源东西成为可选的以获得功能/性能提升。这使我在竞争中脱颖而出,对于某些用户来说,我成为他们唯一的选择。
架构的指令集(随着时间的推移,x86 拥有很长的架构系列,arm 也有,而且在我看来,它们的组织性更强,等等)是由该公司内的个人或团队定义的。故事结束。最好的情况是他们可能必须避免专利(是的,有些专利是你必须避免的,这使得制定新的指令集变得困难)。如果英特尔和 AMD(或英特尔团队 A 与英特尔团队 B、AMD 团队 A 与...)等两个竞争且兼容的架构碰巧采用彼此的功能/指令,那么它更多的是市场驱动的,而不是某些标准机构。
基本上看看 itanium 与 amd64 的对比以及结果如何。
x86 的历史有点像一场噩梦,我仍然无法理解为什么它仍然存在(与指令集的质量无关,而是与业务的运作方式无关),因此试图给事物贴上标签并组织起来将它们放入单独的盒子中,实际上不会增加任何价值并会造成一些混乱。 intel的r代有这个,amd的m代有那个,我的工具支持这个的gen r和那个的gen m。明年我将亲自选择是否要支持下一代。永远重复,直到产品死亡。您还必须选择是否要支持老一代,因为尽管理论上是兼容的,但它们可能具有相同的指令,但具有不同的功能/副作用。
There is no such thing, and I cannot imagine how there would be.
One or more people at intel define their instruction sets for their products, period. If AMD happens to have been able to make legal clones (which they have) and as part of that agreement or perhaps even not but with some penalty, they add additional instructions/features. First off it is on them to do it and keep some sense of compatibility, if they even want to be compatible. Second if they want to add extensions and can get away with it it is purely within AMD one or more engineers. Then if intel goes and makes some new instructions, it is one or more intel engineers. As history played out you then have other completely disconnected parties like gnu tools folks, microsoft tools folks and a list of others, as well as operating system folks that use tools and make their products, choosing directly or indirectly what instructions get used. And as history plays out some of these intel only or amd only instructions may be favored by one party or another. And if that party happens to have influence (microsoft windows, linux, etc), to the point that it puts pressure on intel or amd to lean one way or another, they it is their management and engineering that does that, within their company. They can choose to not go with what the users want and try to push users in their direction. Simple sales of one product line or another may dictate the success or failure of each parties decisions.
I cannot think of a or many standards that folks actually agree on even though they might have representatives that wear shirts with the same logo on them that participate in the standards bodies. From pcie to java to C++, etc (C and C++ being really bad since they were written then attempts to standardize later, which are just patches and too much left to individual compiler authors choices of interpretation). You want to win at business you differentiate yourself from the others. I have an x86 clone that is much cheaper but performs 95% as well as intel. Plus I added my own stuff that intel does not have that I pay employees to add to open source stuff, making those open source things optional to gain that feature/performance boost. That differentiates me from the competition, and for some users locks me in as their only choice.
Instruction sets for an architecture (x86 has a long line of architectures over time, arm does too and they are more organized about it imo, etc) are defined by that individual or teams within that company. End of story. At best they may have to avoid patents (yep there have been patents you have to avoid, making it hard to make a new instruction set). If two competing and compatible architectures like intel and amd (or intel team a vs intel team b, amd team a vs ...) happen to adopt each others features/instructions it is more market driven not some standards body.
Basically go look at itanium vs amd64 and how that played out.
The x86 history is a bit of a nightmare and I still cannot fathom why it still even exists (has nothing to do with the quality of the instruction set but instead how the business works), and as such attempting to put labels on things and organize them into individual boxes, really does not add any value and creates some chaos. Generation r of intel has this, generation m of amd has that, my tool supports gen r of this and gen m of that. Next year I will personally choose if I want to support the next gen of each or not. Repeat forever until the products die. You also have to choose if you want to support an older generation as those may have the same instructions but with different features/side effects despite in theory being compatible.