如何告诉GCC编译器应该生成串行(即没有跳转)的代码。如何告诉GCC编译器应该生成的代码是串行的,即没有跳转
我正在研究将内联汇编嵌入C源代码(或LLVM IR)的项目。
我的实现取决于将内联汇编写入可执行文件的代码。
更正式地说,假设我有索里的代码(C或LLVM IR):
.label_start: (inserted as inline assembly)
inline_assembly0
source_code0
source_code1
inline_assembly1
...
.label_end: (inserted as inline assembly)
...
现在,这不应该被编译为:
.jmp_target:
source_code1
inline_assembly1
...
.label_end: (inserted as inline assembly)
...
.label_start: (inserted as inline assembly)
inline_assembly0
source_code0
jmp jmp_target
即代码应留在标签之间,不要跳转.label_start
和.label_end
。
有什么办法告诉GCC两个内联汇编标签之间的所有内容都应该保持“完好无损”而不必重新排序?我的实现取决于此。
这段代码是否恰好在循环中? –
你为什么需要这个?在任何情况下,你是否有一个不符合乱序执行的CPU。 –
通常,代码可以位于循环@BenVoigt中。 – Shuzheng