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

IAR STM8 #pragma optimize 指令

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

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

STM32串口发送数据首字符丢失解决办法

STM32串口发送数据首字符丢失解决办法

现象: 串口发送数据时,第一个字符丢失 例如,发送“system init\r\n”,最后收到的是“ystem init\r\n”,在此之后发送的数据均正常。 错误代码: 原因分析: TC 和 TXE 标志位在复位的时候被置1 ,这样第一次whil...

Word转pdf

Word转pdf

为了通用:把一篇文章转成PDF后,读者无论在Unix还是Windows,无论是否有中文字体,都可以正常阅读。 为了美观:你精心排版的文件转成PDF后,对方在屏幕上看到的与你完全一样,不会有重新换行/字体/之困挠。 为了安全:在PDF文件中,你可以做到打开要密码,不允许修改、复制、打印…...

PHP:Call to undefined function bindtextdomain()

all to undefined function bindtextdomain() bindtextdomain() 是系统函数为什么会出现上面情况 我的是 PHP/5.2.9 (PHP 4, PHP 5) bindtextdomain ? Set...

C#让TextBox滚动条一直位于最下部

TextChanged事件 滚动条自动处于TextBox最下部需要在Form1类中加上下段代码:   private void txtReceiveMsgChanged(object sender, EventArgs e) {     //...

CrystalDecisions.Windows.Forms.CrystalReportViewer.DisplayGroupTree”已过时

问题:早期工程升级到VS2010 提示: CrystalDecisions.Windows.Forms.CrystalReportViewer.DisplayGroupTree”已过时 解决办法: this.crystalReportViewer1.DisplayGroupTree =...

File.Create创建文件后,需要释放

重点就是要close if (!File.Exists(SavePath))             {       ...

发表评论

访客

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