Jump to content

LLVM: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m Cleaned up some references.
Zyx (talk | contribs)
m +pl
Line 106: Line 106:
[[it:LLVM]]
[[it:LLVM]]
[[ja:Low Level Virtual Machine]]
[[ja:Low Level Virtual Machine]]
[[pl:Low Level Virtual Machine]]
[[ru:Low Level Virtual Machine]]
[[ru:Low Level Virtual Machine]]
[[zh:LLVM]]
[[zh:LLVM]]

Revision as of 17:14, 4 May 2010

LLVM
Developer(s)LLVM Developer Group
Initial release2003
Stable release
2.7 / April 26, 2010 (2010-04-26)
Repository
Written inC++
Operating systemCross-platform
TypeCompiler
LicenseUniversity of Illinois/NCSA Open Source License
Websitellvm.org

The Low Level Virtual Machine (LLVM) is a compiler infrastructure, written in C++, which is designed for compile-time, link-time, run-time, and "idle-time" optimization of programs written in arbitrary programming languages. Originally implemented for C/C++, the language-independent design (and the success) of LLVM has since spawned a wide variety of front-ends, including Objective C, Fortran, Ada, Haskell, Java bytecode, Python, Ruby, ActionScript, GLSL, and others.

The LLVM project started in 2000 at the University of Illinois at Urbana-Champaign, under the direction of Vikram Adve and Chris Lattner. LLVM was originally developed as a research infrastructure to investigate dynamic compilation techniques for static and dynamic programming languages. LLVM was released under a BSD-style license. In 2005, Apple Inc. hired Lattner and formed a team to work on the LLVM system for various uses within Apple's development systems.[1] LLVM is an integral part of Apple's latest development tools for the Mac OS X and iPhone.

Description

LLVM can provide the middle layers of a complete compiler system, taking intermediate form (IF) code from a compiler and outputting an optimized IF that can then be converted and linked into machine-dependent assembler code for a target platform. LLVM can accept the IF from the GCC toolchain, allowing it to be used with a wide array of existing compilers written for that project.

LLVM can also generate relocatable machine code at compile-time or link-time or even binary machine code at run-time.

LLVM supports a language-independent instruction set and type system. Each instruction is in static single assignment form (SSA), meaning that each variable (called a typed register) is assigned once and is frozen. This helps simplify the analysis of dependencies among variables. LLVM allows code to be compiled statically, as it is under the traditional GCC system, or left for late-compiling from the IF to machine code in a just-in-time compiler (JIT) in a fashion similar to Java.

Any form of type conversion, from coercion to the downcasting of an object, is performed explicitly using the cast instruction. LLVM has basic types, like integers of fixed sizes, and exactly five derived types: pointers, arrays, vectors, structures, and functions. A type construct in a concrete language can be represented by combining these basic types in LLVM. For example, a class in C++ can be represented by a combination of structures, functions and arrays of function pointers.

The LLVM JIT compiler is capable of optimizing unnecessary static branches out of a program at runtime, and is therefore useful for partial evaluation in cases where a program has many options—most of which can easily be determined unnecessary in a specific environment. This feature is used in the OpenGL pipeline of Mac OS X Leopard (v10.5) to provide support for missing hardware features.[2] Graphics code within the OpenGL stack was left in intermediate form, and then compiled when run on the target machine. On systems with high-end GPUs the resulting code was quite thin, passing the instructions onto the GPU with minimal changes. On systems with low-end GPUs, LLVM would compile optional procedures that run on the local CPU that emulate instructions that the GPU can not run internally. LLVM was instrumental in improving performance on low-end machines using Intel GMA chipsets.

Front-ends

LLVM was originally written to be a more aggressive, higher performance system for the existing GCC stack,[3] and many of the GCC front-ends have been modified to work with it. LLVM currently supports the compilation of C, C++, Fortran, Objective-C, Ada, D, using front-ends derived from version 4.0.1 and 4.2 of the GNU Compiler Collection (GCC).

Widespread interest in LLVM has led to a number of efforts to develop entirely new front-ends for a variety of languages. One that has received the most attention is clang, a new compiler supporting C, Objective-C and C++. Primarily supported by Apple, clang is aimed at replacing the C/Objective-C compiler in the GCC system with a modern system that is more easily integrated with IDEs, and has wider support for multithreading. Objective-C development under GCC was stagnant and Apple's changes to the language were supported in a separately maintained branch. Creating their own compiler allowed them to address many of the same problems LLVM addressed in terms of IDE integration and other modern features, while also making the primary development branch the primary Objective-C implementation.[citation needed]

The Utrecht Haskell Compiler can generate code for LLVM which, though the generator is in the early stages of development, has been shown in many cases to be more efficient than the C code generator.[4] There are many other components in various stages of development; including, but not limited to, a Java bytecode front-end, a CIL front-end, a CPython front-end, [5] various frontends for Standard ML, and a new graph coloring register allocator.

See also

References

  1. ^ Adam Treat, mkspecs and patches for LLVM compile of Qt4
  2. ^ Chris Lattner (August 15, 2006). "A cool use of LLVM at Apple: the OpenGL stack". LLVMdev mailing list. Retrieved 2008-10-26.
  3. ^ Lattner, Chris (May 2003). Architecture For a Next-Generation GCC. First Annual GCC Developers' Summit. Retrieved 2009-09-06. {{cite conference}}: Unknown parameter |coauthors= ignored (|author= suggested) (help)
  4. ^ "Compiling Haskell To LLVM". Retrieved 2009-02-22.
  5. ^ "unladen-swallow - A faster implementation of Python". Retrieved 2009-05-07.

External links