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

IAR STM8 #pragma optimize 指令

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

参考资料: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 指令” 的相关文章

提交到app store时,提示ERROR ITMS-90478 ,ERROR ITMS-90062错误

提交到app store时,提示ERROR ITMS-90478 ,ERROR ITMS-90062错误

ios app提交到AppStore时,提示ERROR ITMS-90478 ,ERROR ITMS-90062,如下图所示: 看字面意思,应该是我提交的版本比之前上架的版本要低。 但是,之前的版本是V1.03,现在是V1.1.0。好像版本要高,并没有低。 然而,到AppStore构建版本那里查看...

Multisim仿真过慢

Multisim仿真过慢

在用Multisim仿真的时候,有时候会仿真过慢,实际等了半天,而传递函数才走了几秒而已,有时候要看最后稳定的结果,得等N长时间,这个是无法忍受的。这个问题实际上是所有Spice类软件的通病,如果你按照软件的默认设置的话,有些仿真进程就是很慢。 解决办法: 修改仿真的步进值。如图(以中文版为例)...

MSP430复位电路

MSP430复位电路

复位电路有啥好讲的?很多人可能都这样认为。简单的阻容复位,相信大伙都知道如何使用。一直以来,我也是这么认为的。后来在利尔达的一款MSP430F449开发板上看到其复位电路,看到电路上多了个1N4148二极管,这个二极管的作用我一度认为是起保护作用的,直到最近在网上看到一个网友的精彩说明,才知道二极管...

Android Studio Build Output中文乱码

Android Studio Build Output中文乱码

1.双击shift  弹出如下窗口  选择Actions  找到Edit Custom VM Options 打开 2.打开后输入  -Dfile.encoding=UTF-8  保存重启  ok...

用Allegro导出DXF/DWG格式文件

用Allegro导出DXF/DWG格式文件

在硬件系统设计过程中,有时需要导出PCB文件的二维模型用以设计对应的结构件。 以下内容介绍的是采用Cadence套件中的Allegro软件将brd文件导出为DXF文件。1.在Allegro中打开brd文件,设置好要导出的layer,选择File->Export->DXF 2....

iPhone下xib转成iPad的xib

iPhone下xib转成iPad的xib

参考文献:http://blog.csdn.net/kmyhy/article/details/7715397 在Xcode 3中,将xib从iPhone版转变为iPad版,通过Create iPad Version菜单。 但在Xcode 4及Xcode5中,这个菜单找不到了。但是可以通过其...

发表评论

访客

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