Sign in



Don't have an account?

Signing up is free and easy
Home -> Our Services -> Programming Tools BU -> Open Source Tools -> GNU Compiler porting for MIPS like processor

GNU Compiler porting for MIPS like processor

Requirements

Requirement is to port GNU C Compiler to a new architecture. Our selected target architecture is subset of Tx39 (which is based on MIPS Technologies, Inc.'s R3000A architecture.). This is an in-house project.

Challenges

  • Lack of knowledge in GNU Compiler porting
  • Determining the direction and the footsteps. We didn't know how to start and where to start
  • Not clear documentation Or directions available for GNU Compiler porting

Solution

  • Environment
    OS Linux
    Language/Platform C
    Development model Incremental development model
  • Description

    Programming tools business unit of acmet explored about the market requirement for GNU Compiler porting. We believe that GNU Compiler open source might have good market in future. So we have decided to upgrade our skill in GNU Compiler porting.

    We have decided to acquire the following skills.

    • Port the GNU Compiler to new architecture
    • Fix defects identified in GNU Compiler

    As a first step it is decided that to acquire the porting skill. We have already developed the compiler for 32-bit/16-bit MIPS like processor. Since we have familiarity in MIPS like architecture and compiler technologies, we have decided to port the GNU Compiler for MIPS like processor.

    The project is developed in incremental development model.

    GNU Compiler porting work is split into multiple defined increments. This division of task enables concentrating on a small defined set of tasks at a time. GNU Compiler machine descriptions and the correlation between them are not easy to understand. For someone new to GNU Compiler porting, unless a systematic approach is used, the progress on development of machine descriptions can be really slow.

    Normally, if we have to take an incremental approach for the porting task; we would have split the features such that each increment adds more target architecture specific features. But interestingly, we found that for the case of GNU Compiler machine descriptions, it is the increment in the source language which results in understandable increments in machine descriptions rather than increments in the target architecture.

    So the increments are split based on 'C' language constructs. For each increment, the machine descriptions will cover the 'C' source constructs for that level ensuring the following:

    • Successful compilation of any program,
    • Correctness of the generated assembly program (if any generated needs to be verified manually)

    After writing the machine descriptions for each increment, tests are written to verify the machine descriptions based on the language constructs supported in that increment.

    The following increments are defined for porting GNU Compiler.

    • First Increment
      Level 1.0

      Deciding and finalizing the build environment (setting up the environment in native linux). This includes building the native GNU Compiler.

    • Second Increment

      This increment has three sublevels which involve defining the mandatory macros. Assembly output is not produced in these levels.

      Level 2.0

      Making GNU Compiler recognize new target, identifying the mandatory macros and filling them with dummy values.

      Level 2.1

      Filling the mandatory macros with actual values required for porting (excluding the macros that deal with RTLs) GNU Compiler to target architecture.

      Level 2.2

      Filling the mandatory macros that use RTLs with actual values

    • Third Increment

      This increment involves writing machine descriptions. They produce assembly output which needs to be verified manually.

      Level 3.0

      Write machine descriptions that support unconditional jump and move operations.

      Level 3.1

      Write machine descriptions that support arithmetic and shift instructions

      Level 3.2

      Support function prologue, function epilogue, function calls, relational operators & conditional branch.

  • Current status

    We have completed the compiler porting. We can able to generate the assembly files for the given C test program. Also we have done minimal testing.

    TX32 is already ported (compiler/assembler/linker) to GNU Compiler. Since our selected target architecture is subset of TX32, we have used the assembler and linker of TX32. Currently we are building the necessary library to execute the test files for compiler port.