1 / 84

IAR Embedded Workbench for ARM Ryan Sheng I AR Systems AB, Shanghai 2005- 10-17

IAR Embedded Workbench for ARM Ryan Sheng I AR Systems AB, Shanghai 2005- 10-17. Outline. IAR Introduction EWARM v4.30 Overview Controlling Compiler Optimization Extended Compiler Features Segments and Memories Runtime Library C-SPY Debugger Systems. IAR Introduction. IAR Systems.

bryony
Télécharger la présentation

IAR Embedded Workbench for ARM Ryan Sheng I AR Systems AB, Shanghai 2005- 10-17

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IAR Embedded Workbench for ARMRyan ShengIAR Systems AB, Shanghai2005-10-17

  2. Outline • IAR Introduction • EWARM v4.30 Overview • Controlling Compiler Optimization • Extended Compiler Features • Segments and Memories • Runtime Library • C-SPY Debugger Systems

  3. IARIntroduction

  4. IAR Systems • 成立于1983年 • 总部位于瑞典第四大城市乌普萨拉 • 于1986年推出世界上首个嵌入式C编译器 • 是一家世界领先的嵌入式软件开发工具供应商 • 2000年在瑞典斯德哥尔摩证券市场成功上市 • 在世界各地拥有70,000多个用户 • 业务遍及世界各地,50多个代理/分销商 • 中国大陆:麦克泰软件技术有限公司 (深圳分公司: 0755-82971846) • http://www.iar.com

  5. IAR Products • Embedded Workbench • 一体化的嵌入式软件集成开发环境 • 完整的工具链,支持整个开发流程 • 产品线覆盖30余种8/16/32-bit微处理器 • 汇编、ANSI C、Embedded C++及IAR扩展语言特性 • 强大而灵活的Size/Speed优化功能 • visualSTATE • 针对嵌入式系统的图形化设计和建模工具 • 基于UML状态图(UML State Chart)机制 • 自动分析和检查模型中的逻辑错误 • 壮态机级别的模拟仿真和On-Target调试 • 自动生成开发文档和精简紧凑的C/C++代码框架

  6. IAR Embedded Workbench • Powerful IDE • IAR C/C++ Compiler • IAR Assembler • IAR XLINK Linker • IAR XAR & XLIB Library Tools • Editor • Project Manager • C-SPY Simulator and Debugger

  7. IDE Host Application Third Party Editors, Source Code Control Systems, etc. Text Editor Project Manager Debugger GUI C-SPY™ Debugger Kernel Tool Chain RDI, J-Link, Angel, Macraigor, … RTOS Support Custom Plug-Ins Linker, Simulator Assembler Libraries Compiler, IAR Embedded Workbench

  8. Linker Compiler Hardware C Source C Source C Source Software Building Process Compiler System C Runtime User Code C Library Object File Object File Object File OS Executable Other Lib Third-Party Code

  9. File with UBROF Object DebugInformation IAR Simulator <library>.r79 (Library File) <design>.xcl (Linker File) ddf-File IAR Debugger RDI <design>.d79 <design>.c (C Code) IAR Linker IAR J-Link IAR C/C++ Compiler <design>.r79 (Object File) RTOS Support e.g. ORTI CMX OSE ThreadX uC/OS-II Fusion Quadros ...... Macraigor <design>.a79 <design>.h (Head File) <design>.map (Map File) Linker can produce multiple output files, e.g. Motorola s-record, Intel hex, coff, elf/dwarf, ... Angel IAR <design>.r79 (Object File) Assembler Third-Party Emulator Driver <design>.s79 (Assembly) Software Building Process

  10. EWARM v4.30Overview

  11. IAR Embedded Workbenchversion 4.30 for ARM • Hierarchical Source Organization • Select ARM Core or Processor • C/C++ Language Support • Configure Compiler Optimizations • MISRA C Support • Configurable Runtime Library • Standard Image Formats • Customizing Linker Command File • Debugger & Target System • Powerful C-SPY Debugger • User Assistance • Find More on the Web • Benchmarks

  12. Hierarchical Source Organization • Workspace • Project • Configuration • Source Group • Source File

  13. Select ARM Core or Processor

  14. C/C++ Language Support • ANSI C • ISO/IEC 9899:1994 with selected features from C99 • Embedded C++ • A proper subset of standard C++ • Defined by Embedded C++ Technical Committee • Class, Polymorphism, Overloading of Operators and Functions, new and delete, Inline Functions • Extended Embedded C++ • Embedded C++ extended by IAR • Template, Name Space, Modern Cast Operators, Mutable Attribute, Standard Template Library (STL) • Tailored C++ Features • Multiple Inheritance, Exception Handling, Runtime Type Information (RTTI)

  15. Configure Compiler Optimizations

  16. MISRA C Support • MISRA • Motor Industry Software Reliability Association • MISRA C • ISO定义了C Syntax,但没有指出怎样才能写出安全的C代码 • MISRA C定义了一套编程规则,以描述如何开发“安全的”C代码 • ”GuidelinesFor the Use Of The C Language In Vehicle Based Software” • IAR从2004年起首家提供MISRA C校验模块,涵盖了所有127条规则 • http://www.misra.org.uk

  17. Configurable Runtime Library • Contents of DLIB • C/C++ library definitions • Runtime environment support, e.g. system startup and exit codes, and some low-level library functions • Runtime support libraries, e.g. low-level floating-point arithmetic routines • Customize a pre-built library without rebuilding • Library Configuration: Normal or Full • Printf & Scanf Formatters: Tiny, Small, Large or Full • Overriding library modules with customized versions • Rebuild a Customized Library • Full source code available

  18. Standard Image Formats • IAR Linker: XLINK • Generates a wide range of industry-standard image formats.

  19. Customizing Linker Command File

  20. Debugger & Target System • IAR C-SPY Simulator • Hardware Debugger Interface • RDI, IAR J-Link, Macraigor, Angel, ROM-monitor, Third-Party Emulator Drivers

  21. Powerful C-SPY Debugger • Seamlessly integrated into the IDE • Editing while debugging • Set breakpoints before starting the debugger • C/C++ source & disassembly level debugging • Powerful code and data breakpoints • STL container awareness • C-like macro system to extend functionalities • Terminal I/O emulation • Trace (also available for simulator) • Code Coverage and Profiling • Generic flash loader • RTOS-aware debugging • Extendable for third-party RTOS or emulators

  22. User Assistance • Ready-made sample projects • Context-sensitive online help manuals with index and searching • Complete PDF guides: • ARM Assembler Reference Guide • ARM Embedded Workbench User Guide • ARMC/C++ Compiler Reference Guide • IAR Linker and Library Tools Reference Guide • IAR MISRA C Reference Guide • …… • Printed user guides with extensive step-by-step tutorials

  23. Find more on the web …… • http://www.iar.com/ewarm • Highlights of the newest version • Supported ARM cores and processors • Download 30-day evaluation version • Download benchmarks comparing with other tools • Download product updates • Download demos within flash format • More features of the product • http://www.iar.com/st • IAR KickStart Kits for STR7 Microprocessors • Download EWARMKickStart v4.30 (32KB Code) • Download Sample Projects for STR7 Microprocessors • Other Products Related to STMicroelectronics

  24. Benchmarks Compiler Options: • IAR: -z9 --cpu=ARM7TDMI • ADS: -cpu 4t –zo -Ospace -O2 • GNU: -mcpu=arm7tdmi -msoft-float -Os • Keil: optimize(7,size) float64, uu(remove)

  25. Controlling Compiler Optimization

  26. Parser High-Level Optimizer Code Generator Low-Level Optimizer Assembler C Source = – x x 15 The Compiler x = x - 15; Compiler Intermediate Code Target Code 000100110101101111011101 LDR R0,xLDRR1,[R0,#0]SUBR1,#15STR R1,[R0,#0] Object Code

  27. Transformations by Optimizer None (Best debug support) Low Limited live-range for variables Medium Live-dead analysis and optimization Dead code elimination Redundant label elimination Redundant branch elimination Code hoisting Peephole optimization Register content analysis Static clustering Common subexpression elimination High Instruction scheduling Cross jumping Advanced register content analysis Loop unrolling Function inlining Code motion Type-based alias analysis

  28. Using Optimization Settings • Use the same optimization settings for the entire project (e.g., minimal code); • Use different optimization settings for individual file or group (e.g., maximum speed for time-critical sources); • Use “#pragma optimize” to fine-tune the optimization for specific functions. • High level optimizations may make debugging more difficult.

  29. Customizing Transformations:Common Subexpression Elimination temp=c*d a=b+temp e=f+temp a=b+c*d e=f+c*d • Only applicable to expressions • Cannot optimize function calls (because of side effects) • Can be done manually void bar() { if (foo(12) && C) { … } if (!foo(12) || D) { … } } void bar() { BOOL b = foo(12); if (b && C) { … } if (!b || D) { … } }

  30. Customizing Transformations:Function Inlining int bar(int a) { return a*7; } void foo() { b = y+bar(x); ... } void foo() { b = y+x*7; ... } • Eliminate the overhead of function calls • May increase code size • Let the compiler to decide which functions to inline • Can be done manually: #pragma inline

  31. Customizing Transformations:Loop Unrolling /* unrolled four times */ for(i=0;i<20;i+=4) { a[i]=b[i]; a[i+1]=b[i+1]; a[i+2]=b[i+2]; a[i+3]=b[i+3]; } /* copy 20 elements */ for(i=0;i<20;++i) { a[i]=b[i]; } • Eliminate the overhead of loops • May increase code size • Let the compiler to decide which loops to unroll • Fewer jumps  Good pipeline performance

  32. Customizing Transformations:Code Motion for(i=0;i<10;i++) { b = k * c; p[i] = b; } b = k * c; for(i=0;i<10;i++) { p[i] = b; } • Move loop-invariant expressions and common sub-expressions our of the loop.

  33. Customizing Transformations:Type-based Alias Analysis short f(short *sptr, long *lptr) { short x = *sptr; *lptr = 0; return *sptr + x; } short f(short *sptr, long *lptr) { short x = *sptr; *lptr = 0; return x<< 1; } A C/C++ application that conforms to ISO/ANSI 9899:1999 standard should access objects only by their declared types or through char types. Compiler will determine what objects may be affected when a pointer indirection (alias) is used in an assignment. For example, assuming that the *lptr = 0 assignment will not affect the object that sptr points to. May cause unexpected behavior for non-conforming C codes.

  34. Customizing Transformations:Static Clustering • Static and global variables are arranged so that variables that are accessed in the same function are stored close to each other. • This makes it possible for the compiler to use the same base pointer for several accesses. • Alignment gaps between variables can also be eliminated.

  35. Customizing Transformations:Instruction Scheduling • IAR C/C++ Compiler for ARM features an instruction scheduler to increase the performance of the generated code. • The scheduler rearranges instructions to minimize the number of pipeline stalls caused by resource conflicts. • ARM7 processor uses a three-stage instruction pipeline: • Fetch • Decode • Execute

  36. Extended Compiler Features

  37. Extended Compiler Features • Extended Keywords • Pragma Directives • Preprocessor Symbols • Intrinsic Functions • IAR Language Extensions • Please refer to: • IAR C/C++ Compiler Reference Guide

  38. Extended Keywords • Extended Keywords are only available when IAR language extensions are enabled.

  39. Extended Keywords for ARM • For Functions • __arm, __thumb, __interwork • __irq, __fiq, __swi • __monitor, __nested • __ramfunc • For Variables • __no_init • __big_endian, __little_endian (ARMv6 or later) • For Both • __root • Inline Assembly • asm, __asm : asm(“nop");

  40. Pragma Directives • Extensions of the preprocessor • Control behaviors of the compiler • how it allocates memory • whether it allows extended keywords • whether it outputs warning messages • …… • Always enabled in the compiler • Manipulated during preprocess • Macros can be substituted in pragma directives.

  41. Pragma Directives for ARM • #pragma inline • #pragma data_alignment • #pragma language • #pragma location • #pragma pack • #pragma object_attribute • #pragma segment • #pragma type_attribute • #pragma optimize • ……

  42. Preprocessor Symbols • Predefined Preprocessor Symbols • User-defined Preprocessor Symbols

  43. Predefined Preprocessor Symbols • __ALIGNOF__ () • __CORE__ • __cplusplus • __CPU_MODE__ • __IAR_SYSTEMS_ICC__ • __ICCARM__ • __LITTLE_ENDIAN__ • __STDC__ • __STDC_VERSION__ • __VER__ • ……

  44. Intrinsic Functions • Intrinsic Function: • Looks like function calls, but it isn’t • Built into the compiler • Generate inline assembly instructions • Use intrinsic functions for: • Providing access to special features of the CPU • Providing functionality that cannot be expressed in C • Generate more efficient code than traditional inline assembly • #include <intrinsic.h>

  45. Intrinsic Functions for ARM • void __disable_interrupt (void); • void __enable_interrupt (void); • unsigned long __get_CPSR (void); • void __set_CPSR (unsigned long); • void __MCR (……); • void __MRC (……); • void * __segment_begin (segment); • void * __segment_end (segment); • int __segment_size (segment); • void __no_operation (void); • ……

  46. IAR Language Extensions • Extensions of the ISO/ANSI standard for C programming language. • Also can be used for C++ programming language. • Only available when “Allow IAR extensions” is selected. • Gain full control over the resources and features of the target core, and can thereby fine-tune your application. • Be aware of portability issues.

  47. Absolute Address or Segment • Example 1 • volatile __no_init BYTE PORT1 @ 0x1000; • An absolute declared variable cannot have an initializer, which means the variable must also be __no_init or const declared. • #pragma location = address • Example 2 • void test (void) @ “MYOWNSEGMENT”{ ... } • The location of each segment is assigned in the linker command file. • #pragma location = segment

  48. Anonymous Struct and Union • C++ feature • An anonymous struct or union defines an unnamed object (not a type) whose members are promoted to the surrounding scope. struct str { int a; union { int b; int c; }; }; struct str obj; obj.b = 0; struct str { int a; union { int b; int c; } u; }; struct str obj; obj.u.b = 0;

  49. Bit-fields with Non-Standard Types • In ISO/ANSI C, a bit-field must be of the type int or unsigned int. • Using IAR language extensions, any integer types and enums may be used. • Example: an unsigned char is used for holding 3 bits. The struct will be smaller. struct ThreeBits { unsigned char bitOne : 1; unsigned char bitTwo : 1; unsigned char bitThree : 1; };

  50. Example: Syntax for SFRs • Absolutely addressed • Anonymous structs and unions • Anonymous bit-fields • Bit-fields with non-standard types volatile __no_init union{ unsigned char P0; /* Port 0 */ struct /* bits of Port 0 */ { unsigned char P0_0 : 1; unsigned char P0_1 : 1; unsigned char P0_2 : 1; unsigned char P0_3 : 1; unsigned char P0_4 : 1; unsigned char : 3; }} @ 0x1000;

More Related