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

IAR STM8 #pragma optimize 指令

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

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

光耦应用笔记

1、光耦的简介及分类 光耦合器(opticalcoupler,英文缩写为OC)亦称光电隔离器或光电耦合器,简称光耦。它是以光为媒介来传输电信号的器件,通常把发光器(红外线发光二极管LED)与受光器(光敏半导体管)封装在同一管壳内。当输入端加电信号时发光器发出光线,受光器接受光线之后就产生光电流,从...

CC2541  HOGP Android 5.x无法自动回连

CC2541 HOGP Android 5.x无法自动回连

参考资料: https://e2e.ti.com/support/wireless_connectivity/bluetooth_low_energy/f/538/t/406142 问题: 使用CC254x做BLE键盘,利用HOGP(HID Over Gatt Profile),成功实现了键盘的功能...

ListView.setOnItemClickListener 点击无效

如果ListView中的单个Item的view中存在checkbox,button等view,会导致ListView.setOnItemClickListener无效, 事件会被子View捕获到,ListView无法捕获处理该事件. 解决方法: 在checkbox、button对应的view处加...

使用Doxygen生成Html文档

使用Doxygen生成Html文档

Doxygen是一种开源跨平台的,以类似JavaDoc风格描述的文档系统,完全支持C、C++、Java、Objective-C和IDL语言,部分支持PHP、C#。注释的语法与Qt-Doc、KDoc和JavaDoc兼容。Doxgen可以从一套归档源文件开始,生成HTML格式的在线类浏览器,或离线的LA...

Android APK反编译

Android APK反编译

  反编译需要使用到以下两个软件 1、dex2jar http://code.google.com/p/dex2jar/downloads/list 2、jdgui http://code.google.com/p/innlab/downloads/list 反编译步骤如下: 1、将APK...

如何查看bat文件运行后的显示信息

@echo off 接着中间是批处理的命令! 最后用pause做为结尾,可以是窗口不自动关闭,就可以看到窗口内的运行信息...

发表评论

访客

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