当前位置:首页 > 技术心得 > 正文内容

IAR STM8 #pragma optimize 指令

xjtudll9年前 (2017-06-18)技术心得31680

参考资料:http://blog.csdn.net/niepangu/article/details/38066319

#pragma optimize= none  //one of none, low, medium, high, size, or speed放在被优化函数前 
#pragma optimize 指令
格式:
#pragma optimize=token token token

我在IAR STM8里尝试,发现只能使用none, low, medium, high, size,  speed,且区分大小写。

不能用 s 9之类的,会报警:

f158bb59-a95a-490a-afd9-25fadd7b8c88

Warning[Go013]: Deprecated optimization level "9" encountered in #pragma optimize, please use one of none, low, medium, high, size, or speed

sshot-1_2

后面是参考文献介绍的,我尝试貌似不对,也有可能理解错误。

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
========================================================================================*/

扫描二维码推送至手机访问。

版权声明:本文由鸟的天空发布,如需转载请注明出处。

本文链接:http://www.xjtudll.cn/Exp/458/

标签: IARSTM8
分享给朋友:

“IAR STM8 #pragma optimize 指令” 的相关文章

OKI单片机——ML610Q4XX Melody Driver

OKI单片机——ML610Q4XX Melody Driver

配置流程: (1) Select a buzzer mode by setting the BZMD bit of the melody 0 control register (MD0CON) to “1”. (MD0CON寄存器的BZMD位置一)。 (2) Select...

NSTableview从mutable array获取数据

参考资料: http://stackoverflow.com/questions/3397952/populating-nstableview-from-a-mutable-array 可以使用以下的方法 – numberOfRowsInTableView:...

Quartus II 中管脚上拉电阻(弱上拉)的设置方法

Quartus II 中管脚上拉电阻(弱上拉)的设置方法

参考资料: http://blog.sina.com.cn/s/blog_706f04d20100oelx.html 由于系统需求,需要在管脚的内部加上上拉电阻,目的是为了有个固定的初始状态。 以Quartus II 11.0为例,具体过程如下: 1、在菜单Assignments 中选择Assig...

Allegro导出坐标文件(嘉立创用)

Allegro导出坐标文件(嘉立创用)

File -> Export -> Placement 选Symbol Origin...

Windows 2008 Server R2增量备份

Windows 2008 Server R2增量备份

Windows 2008 server R2在默认情况下都是完整备份,如果这么搞的话,空间很快就不够用了。 其实windows 2008 r2是有增量备份功能的,只不过这个功能隐藏的太深了。 Windows Server Backup -> 配置性能设置 -> 优化备份性能 ->...

金蝶K3获取当前会计期间 以及会计期间的开始结束时间

SELECT @CurPeriod =CONVERT(smallint,FValue) FROM t_SystemProFile WHERE FCategory='IC' AND FKey='CurrentPeriod'   SELECT @CurYear =CONVERT(smallin...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。