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

IAR STM8 #pragma optimize 指令

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

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

VS2010 水晶报表部署依赖问题

VS2010 水晶报表部署依赖问题

水晶报表有两种部署方式: 1、直接安装运行环境 如果手动安装运行环境,那么没什么问题。如果通过打包后的Setup.exe来安装,则很有可能出现问题。 原因: (1) 打包后的Setup.exe有可能先安装水晶报表运行环境 (2) 该运行环境依赖于.NET环境,如果没有先安装.NET,那么运行环境直接...

SVN修改Log信息

SVN修改Log信息

SVN默认是不能修改Log的,强行修改会报错:Repository has not been enabled to accept revision propchanges,ask the administrator to create a pre-revprop-change hook 如果需要修改...

Word通配符全攻略

Normal 0 7.8 磅 0 2 什么是WORD通配符?通配符是配合WORD查找、替换文档内容的有利武器。打开WORD,按Ctrl+F,点击&ldq...

焊接的一些心得

这几天,不断的在焊接一些贴片元件,都是焊盘在IC底下,侧面看不到任何焊盘的IC,例如KXTE9,MMC2121。总结起来有以下几点要注意的地方 1、IC焊盘要与PCB上的焊盘对齐 这点实际上是说起来容易,做起来难。而实际上,只要焊盘对齐了,焊接就完成了80%。在实际操作中可以这样做 (1)画...

C# 用NPOI操作读写2007版的excel错误

现象: 导出Excel2003正常,导出Excel2007莫名其妙的错误。 C#用NPOI操作读写类网上很多了,在此不重复。 我引用的dll:NPOI.dll,NPOI.OOXML.dll,NPOI.OpenXml4Net.dll, 解决方法:还需要引用ICSharpCode.SharpZipLib...

PhonestateListener如何取消监听

PhonestateListener怎么取消监听? TelephonyManager tm; tm.listen(MyPhoneListener myPlistener,PhoneStateListener.LISTEN_CALL_STATE); class MyPhoneStateL...

发表评论

访客

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