Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top