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

IAR STM8 #pragma optimize 指令

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

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

Xcode查找函数(方法)调用及被调用

Xcode查找函数(方法)调用及被调用

参考资料:http://stackoverflow.com/questions/7145045/find-method-references-in-xcode 这个功能有的说是 Find Caller,有的说是Find references,有的说是Find Usages 直白的讲,就是我需要知道这...

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

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

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

Multisim汉化

Multisim汉化

对于中国人来说,还是喜欢用汉化版的。Multisim也能从网上下载到汉化包。汉化包的使用方法如下: 1、将汉化包拷贝到stringfiiles目录,如图所示:  2、打开Multisim,选【Option】->【Global Preferences】 3、在弹出的Preferen...

找不到System.Web.dll

找不到System.Web.dll

  这个其实是编译配置选错了。Client Profile里不包含System.Web.dll,只有完整的.Net才有这个。...

Win7 64bit安装keyshot 0xc000007b 错误解决

 先放出keysho 3.2.36的下载地址: 32bit:http://download.keyshot.com/keyshot_w32_3.2.36.exe 64bit:http://download.keyshot.com/keyshot_w64_3.2.36.exe 和谐包下载:...

UltraEdit复制粘贴十六进制(二进制)

UltraEdit复制粘贴十六进制(二进制)

问题: 用UltraEdit打开文件,看其十六进制,需要将十六进制数据复制出来并粘贴到记事本。但是直接复制(或Ctrl+C),无法粘贴到记事本。 原因: 复制到剪贴板的是二进制码流,而不是文本,所以无法贴到只能处理文本的记事本里。 解决办法: 选中要复制的区域,右键--->【十六进制复制所选视...

发表评论

访客

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