CLI-Based Compilation Flows for the C Language Erven Rohou, Andrea Ornstein, Marco Cornero

CLI-Based Compilation Flows for the C Language Erven Rohou, Andrea Ornstein, Marco Cornero

CLI-Based Compilation Flows for the C Language Erven Rohou, Andrea Ornstein, Marco Cornero To cite this version: Erven Rohou, Andrea Ornstein, Marco Cornero. CLI-Based Compilation Flows for the C Language. International Conference on Embedded Computer Systems: Architectures, Modeling and Simulation, Jul 2010, Samos, Greece. pp.162-169, 10.1109/ICSAMOS.2010.5642069. inria-00505640 HAL Id: inria-00505640 https://hal.inria.fr/inria-00505640 Submitted on 25 Jul 2010 HAL is a multi-disciplinary open access L’archive ouverte pluridisciplinaire HAL, est archive for the deposit and dissemination of sci- destinée au dépôt et à la diffusion de documents entific research documents, whether they are pub- scientifiques de niveau recherche, publiés ou non, lished or not. The documents may come from émanant des établissements d’enseignement et de teaching and research institutions in France or recherche français ou étrangers, des laboratoires abroad, or from public or private research centers. publics ou privés. CLI-Based Compilation Flows for the C Language Erven Rohou Andrea C. Ornstein Marco Cornero INRIA Rennes STMicroelectronics ST-Ericsson Rennes, France Castelletto, Italy Agrate Brianza, Italy [email protected] [email protected] [email protected] Abstract—Embedded systems contain a wide variety of proces- duplication, complex build and validation environments and sors. Economical and technological factors favor systems made of rigid distribution channels, reducing their productivity and a combination of diverse but programmable processors. Software market opportunities to a big extent. has a longer lifetime than the hardware for which it is initially designed. Application portability is thus of utmost importance Software has a longer lifetime than hardware: many appli- for the embedded systems industry. cations run on hardware that did not exist at the time they The Common Language Infrastructure (CLI) is a rich virtu- were designed. Hardware binary compatibility comes at a alization environment for the execution of applications written in multiple languages. CLI efficiently captures the semantics high cost, which embedded systems manufacturers can rarely of unmanaged languages, such as C. We investigate the use of afford. These industrial trends make application portability of CLI as a deployment format for embedded systems to reconcile utmost importance. apparently contradictory constraints: the need for portability, the need for high performance and the existence of a large base of Our main motivation is to extend the benefits of processor legacy C code. virtualization for embedded systems. In particular, we focus In this paper, we motivate our CLI-based compilation environ- on the processor virtualization aspects [3], as an independent ment for C, and its different use scenarios. We then focus on the feature, while paying particular attention to performance and specific challenges of effectively mapping the C language to CLI, to integration aspects with existing native or managed envi- and our proposed solutions. We finally analyze the interactions between the CLI environment and native libraries, which is of ronments. Using a platform-neutral bytecode representation primary importance for a practical use of the proposed approach. is an opportunity for split-compilation: a first compilation pass translates the source language into bytecode, and a second pass converts the bytecode to native machine code. I. INTRODUCTION The first pass can run aggressive analyses and encode their Complex embedded systems provide a wide range of dedi- results for the benefit of the second pass [4]. Thanks to this cated and demanding functionalities, such as communication, additional information, the second pass can apply in a dynamic multimedia and user interface. Increasing non-recurring en- environment optimizations that would be otherwise too costly. gineering costs of integrated circuits push manufacturers to Legacy code makes the C language mandatory in embedded use a given circuit in several products. This trend makes software. An additional motivation is the higher performance ASICs less attractive and favors programmable solutions [1]. that programmers can achieve in writing “low-level” C, com- Given the tight area and power constraints, it is impossible pared to higher-level languages, managed ones in particular. to provide these functions using homogeneous programmable In addition, C does not require any managed environment, architectures. Rather, they are composed of different subsys- reducing the run-time system to a minimum, with benefits tems, typically including a host micro-controller running the in terms of memory footprint and real-time responsiveness system software, and a growing number of heterogeneous (though possible, a JIT compiler is not strictly necessary). dedicated processors, such as DSP and/or VLIW. Some studies [2] predict that embedded systems will feature hundreds of This paper analyzes the interactions of the C language cores by 2020. with the CLI (Common Language Infrastructure) framework. Each platform provider has its own proprietary solutions CLI is not a usual processor instruction set. It adds new and evolutions. This results is the extreme diversity of the constraints (evaluation stack, strong typing), but it also opens embedded market, making software productivity a daunting new opportunities in terms of features (support for unmanaged task. Independent software vendors for embedded systems languages) and optimizations. We address in particular porta- must deal with all the combinations of target processors, bility issues and interaction with existing native environments. toolchains and operating systems, forcing them to restrict Section II reviews related work. Section III presents some their developments to niche domains, and to deal with code alternatives to the standard static compilation flow made possible by the design of CLI. We then go into the details This work was supported in part by the European project Advanced of code generation (Section IV), library issues (Section V) Compiler Technologies for Embedded Streaming (ACOTES), under contract IST-5-034869. All authors were with STMicroelectronics when this work was and intrinsics and builtins (Section VI). Limits are described initiated, INRIA also contributed to further developments. in Section VII. We conclude in Section VIII. CLI-based (1) (2) II. RELATED WORK optimizations load-time Embedded CLI CLI run-time Several solutions address platform virtualization. The most CLI file.o file.exe System notable ones are Java, LLVM and CLI. Java proposes a partial solution to the above-mentioned problems. It defines source install-time Flash native memory a bytecode-based virtual machine and a standard library. Java native file.exe Micro Edition has been widely accepted in embedded systems native file.o to provide additional capabilities, like games for cellphones Fig. 1. CLI-based Compilation Scenarios or TV guides for set-top-boxes. However, programs written in Java remain constrained to the host processor for the non- critical part of the application. The primary goal in the defi- III. ACUSTOMIZABLE CLI-BASED COMPILATION FLOW nition of the Java bytecode was to support the Java language A. Compilation Scenarios features, including its safeness characteristics and managed CLI offers several options to introduce flexibility and op- execution environment. It is not well suited to efficiently timization opportunities at different stages of the compilation support unmanaged languages such as C. flow. Our implementation leaves all options open. Consider LLVM [5] is a compiler framework that defines a low- Fig.1. At any stage of the compilation process, we have the level code representation appropriate for program analysis choice to either produce native binaries, or to keep the code in and transformation. The representation is typed and language- CLI format, deferring native code generation to a later stage. independent, but it as at a lower level than CLI, and it is not The decision of which specific scenario is preferable depends meant as a deployment format. LLVM provides a C compiler. on the context, such as distribution format requirements, CLI is a framework that lets applications written in high- availability or not of CLI support in the target device, real- level languages execute on different systems, without re- time requirements, and possibly others. compilation. It is better known as the base of widespread This approach also smoothly integrates in existing build .NET environment. CLI supports a growing set of languages, systems, such as multi-level Makefiles, by adhering to the managed as well as unmanaged. In contrast to Java and LLVM, traditional separate compilation model and using familiar CLI is an international standard [6]. tools: compiler, assembler, linker. We have previously shown that CLI is a convenient interme- a) CLI as compiler internal format: as shown in [8], diate representation not only for code size [7] but also perfor- using CLI as a compiler middle-level intermediate representa- mance [8]. However, a robust C compiler is a prerequisite for tion does not introduce any performance penalty due to loss the adoption of this format in embedded systems, especially of information. In particular, we showed that the GCC internal to program the media part of the system. representation can be dumped to CLI and then re-generated in The DotGNU Portable.NET [9] project developed a CLI order to proceed with the normal GCC native compilation

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us