Does a pipeline stall occur on an ARM to Thumb switch?

谁都会走 提交于 2020-01-05 08:29:49

问题


In ARM architecture, if an ARM to Thumb mode switch occurs, will a pipeline stall occur? If so, how many cycles are affected? Is this same for Thumb to ARM mode switching ? Does this behavior vary with different ARM processors ?


回答1:


Assuming you switch in the sensible way (with BLX/BX LR), any modern core will predict that (assuming the branch predictor isn't turned off, of course). Writing to the PC directly is a little more variable - generally, big cores might predict it but little cores won't - but is generally best avoided anyway.

Otherwise an interworking branch is AFAIK no different to a regular branch, so if it isn't predicted the penalty is just a pipeline flush. The only other way to switch instruction sets is via an exception return, which is a synchronising operation for the whole core (i.e. not the place to be worrying about performance).




回答2:


No, not at all.

The cost is just like any other branch instruction. If the predictor hits, it's free, if not, it costs the usual 13 cycles.

There's no additional hidden hiccups due to the switching.

Therefore, you can use the interworking mode without worrying about potential penalties related to the mode switching.



来源:https://stackoverflow.com/questions/24780301/does-a-pipeline-stall-occur-on-an-arm-to-thumb-switch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!