Ilmu Informatika    
   
Daftar Isi
(Sebelumnya) LiVESLoad balancing (computing) (Berikutnya)

LLVM

LLVM
LLVM Logo
Developer(s)LLVM Developer Group
Initial release2003
Stable release3.2 / 20 December 2012; 2 months ago (2012-12-20)
Written inC++
Operating systemCross-platform
TypeCompiler
LicenseUniversity of Illinois/NCSA Open Source License[1]
Websitellvm.org

LLVM (formerly Low Level Virtual Machine) is a compiler infrastructure written in C++; it is designed for compile-time, link-time, run-time, and "idle-time" optimization of programs written in arbitrary programming languages. Originally implemented for C and C++, the language-agnostic design (and the success) of LLVM has since spawned a wide variety of front ends: languages with compilers which use LLVM include ActionScript, Ada, D, Fortran, GLSL, Haskell, Java bytecode, Objective-C, Python, Ruby, Rust, Scala and C#.[2][3][citation needed]

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 the University of Illinois Open Source License,[1] 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.[4] LLVM is an integral part of Apple's latest development tools for Mac OS X and iOS.[5]

The name LLVM was originally an initialism for Low Level Virtual Machine, but the initialism caused widespread confusion because the scope of the project is not limited to the creation of virtual machines. As the scope of LLVM grew, it became an umbrella project that included a variety of other compiler and low-level tool technologies as well, making the name even less apt. As such, the project abandoned the initialism.[6] Now, LLVM is a brand that applies to the LLVM umbrella project, the LLVM intermediate representation, the LLVM debugger, the LLVM C++ standard library, etc.

Contents

Description

LLVM can provide the middle layers of a complete compiler system, taking intermediate form (IF) code from a compiler and emitting an optimized IF. This new IF can then be converted and linked into machine-dependent assembly code for a target platform. LLVM can accept the IF from the GCC toolchain, allowing it to be used with a wide array of extant 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.[7] 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) fashion similar to Java. The type system consists of basic types such as integers or floats and 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 can optimize unneeded static branches out of a program at runtime, and thus is useful for partial evaluation in cases where a program has many options, most of which can easily be determined unneeded 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.[8] 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 central processing unit (CPU) that emulate instructions that the GPU cannot run internally. LLVM improved performance on low-end machines using Intel GMA chipsets. A similar system was developed under the Gallium3D LLVMpipe, and incorporated into the GNOME shell to allow it to run without a GPU.[9]

When it comes to the run-time performance of the compiled programs, GCC previously outperformed LLVM by about 10% on average.[10][11] Newer results do indicate, however, that LLVM has now caught up with GCC in this area, and is now compiling binaries of approximately equal performance.[12]

Front ends

LLVM was originally written to be a replacement for the existing code generator in the GCC stack,[13] and many of the GCC front ends have been modified to work with it. LLVM currently supports compiling of Ada, C, C++, D, Fortran, and Objective-C, using various front ends, some 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. The 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 integrated development environments (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.

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.[14] The Glasgow Haskell Compiler (GHC) has a working LLVM backend that achieves a 30% speed-up of the compiled code when compared to native code compiling via GHC or C code generation followed by compilation, missing only one of the many optimization techniques implemented by the GHC.[15]

There are many other components in various stages of development; including, but not limited to, a Java bytecode front end, a Common Intermediate Language (CIL) front end, the MacRuby implementation of Ruby 1.9, various front ends for Standard ML, and a new graph coloring register allocator.[citation needed]

See also

References

  1. ^ a b "License", LLVM: Frequently Asked Questions (llvm.org), http://llvm.org/docs/FAQ.html#license, retrieved 2012-01-27
  2. ^ Reedy, Geoff (2012-09-24). Compiling Scala to LLVM. St. Louis, Missouri, United States. http://www.infoq.com/presentations/Sc ala-LLVM. Retrieved 2013-02-19.
  3. ^ Mono LLVM, http://www.mono-project.com/Mono_LLVM, retrieved 2013-03-10
  4. ^ Adam Treat (2005-02-19), mkspecs and patches for LLVM compile of Qt4, http://lists.trolltech.com/qt4-previe w-feedback/2005-02/msg00691.html, retrieved 2012-01-27
  5. ^ "Apple LLVM Compiler", Developer Tools (Apple), http://developer.apple.com/technologi es/tools/, retrieved 2012-01-27
  6. ^ "Chris Lattner discusses the name LLVM". http://lists.cs.uiuc.edu/pipermail/ll vmdev/2011-December/046440.html. Retrieved 22 December 2011.
  7. ^ "LLVM Language Reference Manual". http://llvm.org/docs/LangRef.html. Retrieved 16 April 2012.
  8. ^ Chris Lattner (15 August 2006). "A cool use of LLVM at Apple: the OpenGL stack". LLVMdev mailing list. http://lists.cs.uiuc.edu/pipermail/ll vmdev/2006-August/006492.html. Retrieved 26 October 2008.
  9. ^ Michael Larabel, "GNOME Shell Works Without GPU Driver Support", phoenix, 6 November 2011
  10. ^ V. Makarov. "SPEC2000: Perbandingan -- LLVM-2.9 and GCC4.6.1 on x86". http://vmakarov.fedorapeople.org/spec /2011/llvmgcc32.html. Retrieved 3 October 2011.
  11. ^ V. Makarov. "SPEC2000: Perbandingan -- LLVM-2.9 and GCC4.6.1 on x86_64". http://vmakarov.fedorapeople.org/spec /2011/llvmgcc64.html. Retrieved 3 October 2011.
  12. ^ Michael Larabel. "GCC 4.6/4.7 vs. LLVM-Clang 3.0/3.1 Compilers". http://www.phoronix.com/scan.php?page =news_item&px=MTA5Nzc. Retrieved 7 January 2013.
  13. ^ Lattner, Chris; Vikram Adve (May 2003). "Architecture For a Next-Generation GCC". First Annual GCC Developers' Summit. http://llvm.org/pubs/2003-05-01-GCCSu mmit2003.html. Retrieved 6 September 2009.
  14. ^ "Compiling Haskell To LLVM". http://www.cs.uu.nl/wiki/bin/view/Stc /CompilingHaskellToLLVM. Retrieved 22 February 2009.
  15. ^ "LLVM Project Blog: The Glasgow Haskell Compiler and LLVM". http://blog.llvm.org/2010/05/glasgow- haskell-compiler-and-llvm.html. Retrieved 13 August 2010.

External links

(Sebelumnya) LiVESLoad balancing (computing) (Berikutnya)