IAR #pragma optimize 指令

来源:互联网 发布:javascript 刷新div 编辑:程序博客网 时间:2024/05/16 09:34
IAR #pragma optimize 指令发布时间:2012-07-13 09:53:50技术类别:嵌入式 
 
IAR #pragma optimize 指令  
#pragma optimize= none  //one of none, low, medium, high, size, or speed放在被优化函数前 
#pragma optimize 指令
格式:
#pragma optimize=token token token
where token is one or more of the following:
s Optimizes for speed
z Optimizes for size
2|3|6|9 Specifies level of optimization
no_cse Turns off common sub-expression elimination
no_inline Turns off function inlining
no_unroll Turns off loop unrolling
no_code_motion Turns off code motion.

The #pragma optimize directive is used for decreasing the optimization level or for
turning off some specific optimizations. This #pragma directive only affects the
function that follows immediately after the directive.
Notice that it is not possible to optimize for speed and size at the same time. Only one
of the s and z tokens can be used.
Note: If you use the #pragma optimize directive to specify an optimization level that
is higher than the optimization level you specify using a compiler option, the #pragma
directive is ignored.
Example
#pragma optimize=s 9
int small_and_used_often()
{
...
}
#pragma optimize=z 9
int big_and_seldom_used()
{
...
}
/*======================================================================================
速度优化选项:
-s[2|3|6|9]
Use this option to make the compiler optimize the code for maximum execution speed.
If no optimization option is specified, the compiler will use the size optimization -z2
by default. If the -s option is used without specifying the optimization level, speed
optimization at level 2 is used by default.

*The most important difference between -s2 and -s3 is that at level 2, all non-static
variables will live during their entire scope.

大小优化选项
-z[2|3|6|9]
Use this option to make the compiler optimize the code for minimum size. If no
optimization option is specified, -z2 is used by default

*The most important difference between -z2 and -z3 is that at level 2, all non-static
variables will live during their entire scope.

2 None*
3 Low
6 Medium
9 High
========================================================================================*/
0 0