문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top