Inline Assembly and Preprocessor
Ravishankar S
ravishankar.s@hathway.com
Wed Sep 13 13:42:00 GMT 2006
Greetings,
Im trying to write an optimized inline assembly for TriCore. I was under
the assumtion that __builtin's were evaluated at compile time so that
for further parsing ,the correct code is selected. This does not seem to
be the case.
Example I want to optimize a PutBit macro as follows:
// If val == 0 then clear the bit in var at pos. Else set the bit.
#define PutBit(var,pos,val) {\
if(__builtin_constant(pos)) {\
// Optimized version if pos is constant.\
uint32_t temp == (val == 0);\
__asm__ __volatile__("ins.t %0,%1,%2,%3,0": "=d"(val) : "d"(val)
, "K"(pos) , "d"(temp));\
} else {\
// Normal version
}\
The problem is when pos is not a constant but a variable.
PutBit(var1,bitpos,bitval);
Now pos is replaced by a variable where a constant was expected.
So compiler gives an error "improper constraint" for "K" must be a
constant.
Is there any way (compiler, preprocessor or other) way to solve this
problem.
Regards,
Ravishankar
More information about the Gcc-help
mailing list