Download Markus Moisio Compiler Implementation For a New Embedded
Transcript
VII CONTENTS 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2. The Coee RISC core project . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1 COFFEE RISC core Overview . . . . . . . . . . . . . . . . . . . . . . 2.2 Processor Properties Relevant to the Compiler 5 . . . . . . . . . . . . . 5 2.2.1 Pipeline Data Hazards . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2.2 Delay Slots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2.3 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.2.4 Separate Modes for Superuser and Regular User . . . . . . . . . . 7 2.2.5 Predication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.2.6 Instruction Coding Size . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.7 Floating Point Coprocessor . . . . . . . . . . . . . . . . . . . . . . 8 3. Introduction to C compilers and GCC . . . . . . . . . . . . . . . . . . . . . 9 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1 Compilation Flow 3.2 Dierent Implementation Strategies 3.3 Benets of Open Source Software and GCC . . . . . . . . . . . . . . . . . . . 10 . . . . . . . . . . . . . . . 12 4. The COFFEE ABI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.1 Basic Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 4.2 Structures and Unions . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 4.3 Function Calls 15 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.3.1 Register Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . 15 4.3.2 Function Calling Sequence . . . . . . . . . . . . . . . . . . . . . . 15 4.3.3 Stack Frame Layout . . . . . . . . . . . . . . . . . . . . . . . . . . 16 5. Porting Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 5.1 Basic Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 5.2 Machine Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 5.2.1 Example of dene_insn . . . . . . . . . . . . . . . . . . . . . . . . 21 5.2.2 Example of dene_expand . . . . . . . . . . . . . . . . . . . . . . 23 5.2.3 Example of dene_split . . . . . . . . . . . . . . . . . . . . . . . . 23 5.3 Instruction Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 5.4 The Handling of Function Calls . . . . . . . . . . . . . . . . . . . . . . 25 5.4.1 Register Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . 25 5.4.2 Stack Frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 5.5 The GCC Low Level Runtime Library . . . . . . . . . . . . . . . . . . 6. Handling of sub-word accesses in the COFFEE compiler port 6.1 . . . . . . . . 28 Synthesized sub-word access . . . . . . . . . . . . . . . . . . . . . . . . 28 6.1.1 6.2 27 Implementation of sub-word Accesses . . . . . . . . . . . . . . . . Other Support Routines for sub-word Accesses . . . . . . . . . . . . . 29 33