What is a clobber?

坚强是说给别人听的谎言 提交于 2020-12-29 09:55:56

问题


Clang TargetInfo has a method called getClobbers:

Returns a string of target-specific clobbers, in LLVM format.

So, what is a clobber?


回答1:


A clobbered register is a register which is trashed i.e. modified in unpredictable way by inline assembler. This usually happens when you need a temp. register or use particular instruction which happens to modify some register as a by-product.

Usually programmer explicitly declares registers which are clobbered by his inline asm code but some may be considered to be trashed by default and that's where getClobbers come into play.

getClobbers returns empty result for most targets. On MIPS GCC has historically not used $1 in generated code so most programmers didn't bother to declare it as clobbered. To reduce portability costs, LLVM considers $1 to be always clobbered in inline asm. Another example is arithmetic flags register (cc) which is considered to be always clobbered by inline asm by GCC on i386 and x86_64 targets.



来源:https://stackoverflow.com/questions/41899881/what-is-a-clobber

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