简体   繁体   English

x86如何处理条件指令?

[英]How does x86 handle store conditional instructions?

I am trying to find out what an x86 processor does when it encounters a store conditional instruction. 我试图找出x86处理器在遇到存储条件指令时的功能。 For instance does it stall the front end of the pipeline and wait for the ROB buffer to become empty before it stops stalling the front end and execute the SC? 例如,它是否停止流水线的前端并在停止停止前端并执行SC之前等待ROB缓冲区变空? Basically does it force the processor to become non speculative... 基本上会迫使处理器成为非投机性的...

Thanks 谢谢

I'm guessing that you're referring to the CMOV cc instructions. 我猜您是在指CMOV cc指令。

I don't know about older x86 processors, but modern ones (ever since they became speculative and out of order) implement conditional stores as: 我不了解较旧的x86处理器,但是现代的(自从它们变得投机和无序以来)就将条件存储实现为:

old value = mem[dest address]
if (condition) 
    mem[dest address] = new value
else
    mem[dest address] = old value

The condition part can be implemented in hardware like this: 条件部分可以在这样的硬件中实现:

      cond
    |\ |
----| \|
new |  \
    |   |    dest
    |   |---------
    |   |     |
  __|  /      |
 |  | /       |
 |  |/        |
 |____________|

So there's no need to break speculation. 因此,无需打破猜测。 A store will in fact take place. 事实上, 将会有一家商店。 The condition determines if the data to be written will be the old value or a new one. 该条件确定要写入的数据是旧值还是新值。

A (generic) x86 processor does none of the things you mentioned. (通用)x86处理器不执行您提到的任何操作。 It just fetches one instruction after another and executes them. 它只是依次提取一条指令并执行它们。

Everything else is handled transparently and heavily depends on which processor you are looking at, so there is no generic answer to your question. 其他所有事情都是透明地处理的,并且在很大程度上取决于您要看的处理器,因此,您的问题没有通用的答案。

If you are interested in methods around stalling problems you should start at the wikipedia page on x86 (register renaming to mention one. Just throw away results from the non-taken branch). 如果您对解决停顿问题的方法感兴趣,则应从x86上的Wikipedia页面开始(注册重命名以提及一个。只需丢弃未采用的分支中的结果)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM