Jump to content

Retargeting

From Wikipedia, the free encyclopedia

In software engineering, retargeting is an attribute of software development tools that have been specifically designed to generate code for more than one computing platform.

Compilers

[edit]

A retargetable compiler is a compiler that has been designed to be relatively easy to modify to generate code for different CPU instruction set architectures. The history of this idea dates back to the 1950s when UNCOL was proposed as the universal intermediate language. The Pascal P-compiler is an example of an early widely used retargetable compiler.

The cost of producing a retargetable compiler that generates code of similar quality to a non-retargetable compiler (i.e., one designed to only ever produce code for a single processor) is higher because it is not possible to make use of cpu specific details throughout all phases of compilation. The benefits of a retargetable compiler is that the total cost over multiple CPUs is much lower than the combined cost of many individual non-targetable compilers.

Some retargetable compilers, e.g., GCC, became so widely ported and developed that they now include support for many optimizations and machine specific details that the quality of code often surpasses that of non-retargetable compilers on many CPUs.

A general-purpose global optimizer followed by machine-specific peephole optimization is a commonly used implementation technique.[1] The optimization of code for some high performance processors requires a detailed and specific knowledge of the architecture and how the instructions are executed. Unless developers invest the large amount of time necessary to write a code generator specifically for an architecture, the optimizations performed by a retargetable compiler will only be those applicable to generic processor characteristics.

A retargetable compiler is a kind of cross compiler. Often (but not always) a retargetable compiler is portable (the compiler itself can run on several different CPUs) and self-hosting.

Examples of retargetable compilers:

Decompiler

[edit]

retdec ("Retargetable Decompiler") is an open source retargetable machine-code decompiler based on LLVM.[citation needed]

  • The decompiler is not limited to any particular target architecture, operating system, or executable file format:
  • Supported file formats: ELF, PE, Mach-O, COFF, AR (archive), Intel HEX, and raw machine code.
  • Supported architectures (currently 32bit only): Intel x86, ARM, MIPS, PIC32, and PowerPC.

Assemblers

[edit]

Conversely, retargetable assemblers are capable of generating object files of different formats, which is useful in porting assembly language programs to various operating systems that run on the same CPU architecture (such as Windows and Linux on the x86 platform). NASM is one such assembler.

Further reading

[edit]
  • A Retargetable C Compiler: Design and Implementation (ISBN 0-8053-1670-1)

References

[edit]
[edit]