c++: asm 破坏列表
在g++中,可以指定asm的破坏列表,例如:
asm ("somecode" : : "r1", "r2", "r3");
这意味着asm代码更改寄存器r1,r2,r3。
现在,我更改的寄存器依赖于模板参数n
(asm
块位于模板函数内部),并且寄存器r1,...,rn将被更改。我该如何表达呢?
In g++, clobber lists for asm can be specified, for example:
asm ("somecode" : : "r1", "r2", "r3");
which means that the asm code changes registers r1, r2, r3.
Now, my changed registers depend on a template parameter n
(the asm
block is inside of a template function), and registers r1, ..., rn will be changed. How can I express that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您面临着多少种不同的语域星座?如果不是太多,您可以为每个提供具体的实现。 (模板专业化)
因为,我担心不可能创建“模板化语句”。
How many different register constellations are you confronted with? If not too many, you could provide a specific implementation for each. (Template Specialization)
Because, I apprehend that there's no possibility to create "templated statements".
您可以在 clobber 列表中设置所有可以使用的寄存器,这样编译器就不会使用它们来存储变量的值;我知道这有点慢,但如果你不需要非常非常高的优化,它会起作用。
You can set all the register that you could use in the clobber list, so the compiler doesn't use them to store the value of a variable; I know this is a little bit slower, but if you don't need a very very high optimization, it will work.