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

IAR STM8 #pragma optimize 指令

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

参考资料: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://xjtudll.cn/Exp/458/

标签: IARSTM8
分享给朋友:

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

浅析电波表——发射和接收原理

浅析电波表——发射和接收原理

一、发射的基本原理 授时信号的发射部分由原子钟、时间信号处理器、调制器、载波振荡器、激励级、强放级和发射天线组成。其工作原理是:原子钟作为时钟源,产生相对准确和稳定的时频标准,这个频率标准通过系统分频器得到实时的标准时间信息。如:年、月、日、时、分、秒、毫秒、微妙等时间信息,这些时间信息通过时间信息...

Protel99SE高级规则设定

Protel99SE高级规则设定

1、Protel99SE高级间距规则 Protel99SE间距规则是在Rules里面设置的,通常我们只是设置整个PCB的间距,实际上我们可以单独设置各类间距,比如覆铜间距,过孔与过孔间距,焊盘到焊盘间距,焊盘到过孔间距等等。 Design->Rules->Routing->Clea...

mircrosoft project2010怎么设置任务级别,降级

mircrosoft project2010怎么设置任务级别,降级

参考资料: http://zhidao.baidu.com/link?url=hW3eTVmKLi2WzQM_jTfsCb2btmRnrmixR8tfFfiRn1YTtM6ylBBXMsnQHpEAUefawNdg-bTiFeXh9Of-U47Mma 两个方法: 1、任务菜单---计划列表---那两...

Allegro测量距离如何同时显示mil和mm双单位

Allegro测量距离如何同时显示mil和mm双单位

点击Setup菜单→User Preferences...(用户参数设置) 打开下面的对话框,选择Display→Element(元素)→show measure_altunits(显示测量所有档位)选项卡选择millimeters。 然后测量后显示的距离效果如下图所示...

Altium Drag妙用——批量添加引脚(PIN)延长导线

Altium Drag妙用——批量添加引脚(PIN)延长导线

使用Altium画单片机相关的原理图的时候,因为要对单片机的引脚添加网表(Netlist),所以必然会用导线将PIN延长,然后加网表。要达到的效果如图所示: 最笨的办法就是:一根线一根线画。这样的话效率很低,典型的浪费时间。有没有更高效的办法呢?答案是肯定的,这就是我标题里提到的Drag的功效。...

ios7 xib适配statusBar—同时适配ios7和ios6

ios7 xib适配statusBar—同时适配ios7和ios6

参考资料:https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/SupportingEarlieriOS.html ios7中,由于status b...

发表评论

访客

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