什么是“欧盟”? 在 x86 架构中? (计算有效地址?)
我在某处读到 x86 指令中的有效地址(如 LEA 指令)是由“EU”计算的。 欧盟是什么? 计算有效地址到底涉及什么?
我只了解了MC68k指令集(UC Boulder先教这个),通过搜索网络找不到好的x86网页。
I read somewhere that effective addresses (as in the LEA instruction) in x86 instructions are calculated by the "EU." What is the EU? What is involved exactly in calculating an effective address?
I've only learned about the MC68k instruction set (UC Boulder teaches this first) and I can't find a good x86 webpage by searching the web.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Intel 自己的软件开发人员手册是有关 x86 的良好信息来源,尽管它们可能有点矫枉过正(并且更像参考而不是教程)。
EU(执行单元)参考最有可能与 ALU(算术逻辑单元)形成对比,后者通常是处理器中负责算术和逻辑指令的部分。 然而,欧盟也有(或曾经有)一些算术能力,用于计算内存地址。 x86 LEA 指令将这些功能传递给汇编程序员。
通常,您可以向 x86 指令提供一些相当复杂的内存地址:
当 ALU 处理算术减法时,EU 负责生成地址。
使用 LEA,您可以将有限的地址生成功能用于其他目的:
比较:
我链接的页面上的“卷 1”有一个部分“3.7.5”讨论寻址模式 - 您可以提供哪种内存地址到需要内存操作数(LEA 就是其中之一)的指令,反映 EU(或任何称为内存接口部分)能够执行的算术类型。
“第 2 卷”是指令集参考,包含所有指令(包括 LEA)的明确信息。
Intel's own Software Developer's Manuals are a good source of information on the x86, though they may be bit of an overkill (and are more reference-like rather than tutorial-like).
The EU (Execution Unit) reference was most likely in contrast to ALU (Arithmetic Logic Unit) which is usually the part of the processor responsible for arithmetic and logic instructions. However, the EU has (or had) some arithmetic capabilities as well, for calculating memory addresses. The x86 LEA instruction conveys these capabilities to the assembly programmer.
Normally you can supply some pretty complex memory addresses to an x86 instruction:
and while the ALU handles the arithmetic subtraction, the EU is responsible for generating the address.
With LEA, you can use the limited address-generating capabilities for other purposes:
Compare with:
"Volume 1" on the page I've linked has a section "3.7.5" dicussing addressing modes - what kind of memory addresses you can supply to an instruction expecting a memory operand (of which LEA is one), reflecting what kind of arithmetic the EU (or whatever the memory interface part is called) is capable of.
"Volume 2" is the instruction set reference and has definitive information on all instructions, including LEA.
“EU”是执行单元的通用术语。 ALU 是执行单元的一个示例。 FADD 和 FMUL,即浮点加法器或乘法器,是其他示例 - 因为,就此而言,它们是用于加载和存储的存储器单元。
与LEA指令相关的EU是ALU(加、减、AND/OR等)和AGU(地址生成单元)。 AGU 与内存管道、TLB、数据缓存等耦合。
当我编写第一个代码生成指南时,典型的 Intel x86 CPU 有 2 个 ALU、1 个与 AGU 绑定的加载管道、与第二个 AGU 绑定的存储地址管道,以及存储数据管道。 截至 2016 年,大多数具有 3 或 4 个 ALU 和多个负载管道。
LEA 是一条 3 输入指令 - BaseReg+IndexReg*Scale+Offset。 就像 x86 的内存寻址模式一样,它实际上有第四个输入,即段基址,它不属于 LEA 计算的一部分。 3 个投入的成本必然高于 ADD 所需的 2 个投入。
在某些机器上,ALU 只能执行 2 个输入操作。 因此,LEA 只能在 AGU 上执行,特别是用于加载的 AGU(因为存储 ALU 不写入寄存器)。 这可能意味着您不能在加载的同时执行 LEA,或者同时执行两个 LEA,而您可以在同一个周期中执行两个添加和一个加载。
在其他机器上,LEA 可以由一个、两个或三个 ALU 完成。 可能代替 AGU,也可能代替 ALU。 这证明了更大的灵活性。
或者,简单的 LEA,例如 regscale+offset,可以在 ALU 上完成,而最大的 LEA,例如 breg+iregscale+offset,可能会受到限制,甚至可能分成两个微指令。
因此,问题归结为:哪个 EU(执行单元)处理哪些 LEA? ALU 还是 AGU? 答案取决于机器。
优化指南中的通用文本可能只是简单地说“EU”,而不是“AGU 或 ALU,具体取决于模型”或“无论哪个 EU 有能力处理该特定 LEA”。
"EU" is the generic term for Execution Unit. The ALU is one example of an execution unit. FADD and FMUL, i.e. the floating point adder or multiplier, are other examples - as, for that matter are (is) the memory unit, for loads and stores.
The EUs relevant to LEA instructions are the ALU (add, subtract, AND/OR, etc.) and the AGU (Address Generation Unit). The AGU is coupled to the memory pipelines, TLB, data cache, etc.
A typical Intel x86 CPU back when I wrote the first codegen guide had 2 ALUs, 1 load pipeline tied to an AGU, a store address pipeline tied to a second AGU, and a store data pipeline. As of 2016 most have 3 or 4 ALUs and more than one load pipe.
LEA is a 3 input instruction - BaseReg+IndexReg*Scale+Offset. Just like the memory addressing mode of x86, which actually has a 4th input, the segment base, that is not part of the LEA calculation. 3 inputs necessarily costs more than the 2 inputs needed for ADD.
On some machines, the ALU can only do 2 input operations. LEA therefore can only execute on an AGU, specifically the AGU used for load (because the store ALU doesn't write a register). This may mean that you cannot do LEA at the same time as Load, or two LEAs at the same time, whereas you can two Adds and a load in the same cycle.
On other machines, LEA can be done by one, or two or three, of the ALUs. Possibly instead of the AGU - possibly as well as the ALU. This proves more flexibility.
Or, the simple LEAs, eg regscale+offset, can be done on the ALUs, whereas the biggest LEAs, eg breg+iregscale+offset, may be restricted, or possibly even broken into two uops.
So, the question comes down to: which EU (Execution Unit) handles which LEAs? The ALU or the AGU? The answer depends on the machine.
Generic text in an optimization guide may simply say "EU" rather than "AGU or ALU, depending on the model" or "whichever EU is capable of handling that particular LEA".
EU = 执行单位?
有效地址是如果
LEA
指令是实际执行某种算术或其他数据访问的指令时将被访问的地址。 它的“预期”用途是计算指针算术或数组索引操作的结果指针。 但是,由于它可以执行乘法和加法的某些组合,因此它也可用于优化一些常规计算。EU = Execution Unit?
Effective Address is the address that would have been accessed if the
LEA
instruction had been an instruction that actually performed some sort of arithmetic or other data access. Its 'intended' use is to calculate the resulting pointer from a pointer arithmetic or array indexing operation. However, because it can perform some combination of multiply and add, it's also used to optimize some regular calculations.多年来,单个系列中的处理器内部结构发生了很大变化,因此需要通过确切的 CPU 型号来澄清“EU”参考。 与您的 m68k 体验进行类比,68000、010、020、030、040 和 060 的指令集大部分相同,但它们的内部结构确实不同,因此任何对内部名称的引用都需要附带其部件号。
The internals of processors inside a single family have changed a lot over the years, so that "EU" reference would need to be clarified with the exact cpu model. As an analogy to your m68k experience, the instruction set for 68000, 010, 020, 030, 040 and 060 are mostly the same but their internals are really different, so any reference to an internal name needs to come with their part number.