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

IAR STM8 #pragma optimize 指令

xjtudll10年前 (2017-06-18)技术心得32280

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

Mac OS X下写入文件到NTFS格式U盘/移动硬盘

Mac OS X下写入文件到NTFS格式U盘/移动硬盘

苹果电脑的 Mac OS X 10.6 雪豹系统本来是自带 NTFS 格式磁盘分区读写功能的,但默认只开启读取功能,所以你把 NTFS 格式的 U 盘或移动硬盘插到苹果电脑上,会发现 Mac 能从里面拷文件,却不能把本机的文件拷进盘里去。 NTFS 磁盘写入功能的方法很多,但命令行、资源库什么的普...

eclipse显示行号及字体设置

eclipse显示行号及字体设置

1 编辑器显示行号 Windows -> Preferences -> General -> Editors -> Text Editors -> Show line numbers(勾选) 2 显示字体设置 Windows -> Preferences -&g...

销售订单序时簿中过滤界面中,【名称】的下拉列表中无法选择到【购货单位】,也就是无法按【购货单位】过滤销售订单?

【操作步骤】   1、使用有权限的用户登录K3主界面后,单击左上角【系统】→【K/3BOS】,输入用户名及密码,登入账套,依次单击打开【供应链】→【销售管理】,找出业务单据销售订单并双击打开;   2、单击菜单【编辑】-【序时簿设置】,找到字段【购货单位$】,...

ZBlog 1.8 ASP转PHP

ZBlog 1.8 ASP转PHP

ZBlog 1.8 ASP转PHP版本过程第一步:将ZBlog升级到2.x版本,因为只有2.x才支持【ZBlog PHP转换工具】需要注意的是:官方下载最新的ASP版本里面没有zb_update18to20这个文件夹,需要从GitHub(https://github.com/zblogcn/zblo...

TM87&TM89文件组织架构

TM87&TM89文件组织架构

一、工程文件TM87,TM89系列每个工程至少包含以下文件:文件后缀名作用PRJ工程组织文件ASM汇编代码文件CC代码文件(仅适用于TM89系列)INC汇编头文件HC头文件(仅适用于TM89系列)LCDLCD配置文件,含仿真信息CFGLCD SEG,COM配置文件OPTMask Option文件OB...

Protel99SE英文版添加汉字

Protel99SE英文版添加汉字

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

发表评论

访客

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