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

IAR STM8 #pragma optimize 指令

xjtudll8年前 (2017-06-18)技术心得24340

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

Protel99SE英文版添加汉字

Protel99SE英文版添加汉字

需要使用PCB3.0中文输入程序,操作步骤如下: 双击打开ProtelHz.exe,输入汉字,点击确定。 如果双击ProtelHz.exe没有任何反应,请注意以下几点: ① 程序尽量不要放到较深的目录中,最好在三级以内。 ② 该程序所在的文件夹及所有上级文件夹,文件夹名最好不要使...

ListView.setOnItemClickListener 点击无效

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

Multisim导入MOSFET模型

文章来源:NI官网->在Multisim里导入MOSFET 模型 原文网址:http://digital.ni.com/public.nsf/allkb/E1DA418DD7A5E4A1862574B800219513 问题: 如何在Multisim器件里导入以“.MODEL&rd...

sharepoint 安装Office Web Applications 报错

sharepoint 安装Office Web Applications 报错,如下: 未能从程序集“Microsoft.Office.Excel.Server.MossHost, Version=14.0.0.0, Culture=neutral, PublicKeyToken=...

IIS配置允许下载APK文件

IIS配置允许下载APK文件

MIME类型:application/vnd.android.package-archive...

BOS单据审核后插件中解锁字段

m_BillInterface.LockCell   Dim dct As KFO.Dictionary     Dim lBillStatusBak As String     lBillStatusBak = m_BillIn...

发表评论

访客

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