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

IAR STM8 #pragma optimize 指令

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

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

金蝶K3 引出序时簿提示:cannot update database of object is read only

金蝶K3 引出序时簿提示:cannot update database of object is read only

金蝶K3引出序时簿提示:cannot update database of object is read only 解决办法: 更换引出路径...

ios7与ios8 注册本地通知

// IOS8 新系统需要使用新的代码    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)     {     &...

在水晶报表中使用Code128条形码

在水晶报表中使用Code128条形码

核心重点:字符串如果直接用code128字体显示,是无法扫描出来的。 1.将code128条码字体拷贝到C:\Windows\fonts下 2 .在水晶报表里的【字段资源管理器】的【公式字段】中新建一个公式字段例如我命名为Code128 3.在新建的字段单击鼠标右键 选择编辑 在报表自定义函数中新建...

51单片机内部扩展RAM

51单片机内部扩展RAM

一直想写一篇关于51RAM的文章,网上看到这篇文章,觉得讲的比较详细,我就不献丑了,转载过来了。初学者可以看看。 原文网址:http://www.jhmcu.com/index.php/mcu-internal-expansion-ram-application/ 单片机内部RAM:共256个单元...

Keil得到C编译之后的汇编代码

Keil得到C编译之后的汇编代码

在Options for Target --> Listing标签页下 在C Compiler Listing: \*.lst部分中勾选Assembly Code,这样生成的LST文件中就会包含汇编源码了。 找到相应的lst文件,如图所示: 用记事本打开,里面就有汇编代码了...

HP Laserjet 1020 在Mac OSX下的安装

HP Laserjet 1020 在Mac OSX下的安装

这个教程是在Mac OSX 10.8操作系统下实现的,但是升级到10.9后,依旧能正常使用。 公司的打印机是HP Laserjet 1020,打印服务器和其他同事的电脑都是Windows系统,这个驱动还是很容易搞定的。 现在有一台Mac Mini,需要连打印机,但是官方不支持Mac OSX。在惠普网...

发表评论

访客

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