c++: asm 破坏列表

发布于 2024-09-30 18:06:49 字数 221 浏览 0 评论 0原文

在g++中,可以指定asm的破坏列表,例如:

asm ("somecode" : : "r1", "r2", "r3");

这意味着asm代码更改寄存器r1,r2,r3。

现在,我更改的寄存器依赖于模板参数nasm块位于模板函数内部),并且寄存器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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

橙味迷妹 2024-10-07 18:06:49

您面临着多少种不同的语域星座?如果不是太多,您可以为每个提供具体的实现。 (模板专业化

因为,我担心不可能创建“模板化语句”。

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".

不即不离 2024-10-07 18:06:49

您可以在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文