Inline Assembly and Preprocessor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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







      
         
         
        
        




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux