This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Conditional compilation w.r.t. optimization level in CCS v4.x

In order to speed up a function, I have written a few in-line assembly instructions which works on the input parameters to the function. Depending on the optimization level, these input parameters are located either in the registers or on the stack. This means that the assembly instructions may be different for each optimization level.

 

Is there a conditional statement like:

#if opt_level == 2

{

compile this

}

#else

{

compile that

}

#endif

 

Or is there a better way of handling this issue?

 

Regards,

Magne

  • Function arguments show up in the same place (usually a register, but not always) regardless of whether you build with optimization.  I suspect that when you say "input parameters" you mean something other than function arguments.  

    Your approach will not work over the long term.  Other than for function arguments, the compiler does not guarantee where any variable is allocated.  The current allocation may change due to changing the compiler version, changing the source code (even somewhere later in the function), etc.  

    Consider intrinsics instead.  If that doesn't work out, your best bet is linear assembly (C6000 only) or hand-coded assembly.

    Thanks and regards,

    -George

     

  • Thank you for pointing me in the right direction!

    Using intrinsic functions did indeed solve my problem.

    Regards,

    Magne