请输入您要查询的百科知识:

 

词条 LLVM
释义

  1. History

  2. Features

  3. Components

      Front ends    Intermediate representation    Back ends    Linker    C++ Standard Library    Debugger  

  4. Version history

  5. See also

  6. Literature

  7. References

  8. External links

{{lead too short|date=September 2018}}{{Infobox software
| name = LLVM
| logo =
| author = Vikram Adve, Chris Lattner
| developer = LLVM Developer Group
| released = {{start date and age|2003}}
| latest release version = 8.0.0
| latest release date = {{start date and age|2019|3|20}}[1]
| programming language = C++
| operating system = Cross-platform
| genre = Compiler
| license = University of Illinois/NCSA Open Source License[2]
| website = {{URL|llvm.org}}
}}

The LLVM compiler infrastructure project is a "collection of modular and reusable compiler and toolchain technologies"[3] used to develop compiler front ends and back ends.

LLVM is written in C++ and 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 of LLVM has since spawned a wide variety of front ends: languages with compilers that use LLVM include ActionScript, Ada, C#,[4][5][6] Common Lisp, Crystal, CUDA, D, Delphi, Dylan, Fortran, Graphical G Programming Language,[7] Halide, Haskell, Java bytecode, Julia, Kotlin, Lua, Objective-C, OpenGL Shading Language, Pony,[8] Python, R, Ruby,[9] Rust, Scala,[10] Swift, and Xojo.

History

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/NCSA Open Source License,[2] a permissive free software licence. In 2005, Apple Inc. hired Lattner and formed a team to work on the LLVM system for various uses within Apple's development systems.[11] LLVM is an integral part of Apple's latest development tools for macOS and iOS.[12] Since 2013, Sony has been using LLVM's primary front end Clang compiler in the software development kit (SDK) of its PlayStation 4 console.[13]

The name LLVM was originally an initialism for Low Level Virtual Machine. This initialism has officially been removed to avoid confusion, as the LLVM has evolved into an umbrella project that has little relationship to what most current developers think of as virtual machines.[14] Now, LLVM is a brand that applies to the LLVM umbrella project, the LLVM intermediate representation (IR), the LLVM debugger, the LLVM implementation of the C++ Standard Library (with full support of C++11 and C++14[15]), etc. LLVM is administered by the LLVM Foundation. Its president is compiler engineer Tanya Lattner.[16]

"For designing and implementing LLVM", the Association for Computing Machinery presented Vikram Adve, Chris Lattner, and Evan Cheng with the 2012 ACM Software System Award.[17]

Features

LLVM can provide the middle layers of a complete compiler system, taking intermediate representation (IR) code from a compiler and emitting an optimized IR. This new IR can then be converted and linked into machine-dependent assembly language code for a target platform. LLVM can accept the IR from the GNU Compiler Collection (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.[18] Each instruction is in static single assignment form (SSA), meaning that each variable (called a typed register) is assigned once and then 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 IR to machine code via just-in-time compilation (JIT), similar to Java. The type system consists of basic types such as integer or floating point numbers 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 mix 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.[19]

Graphics code within the OpenGL stack can be left in intermediate representation, and then compiled when run on the target machine. On systems with high-end graphics processing units (GPUs), the resulting code remains quite thin, passing the instructions on to the GPU with minimal changes. On systems with low-end GPUs, LLVM will 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 proper 3D hardware driver loaded.[20]

For run-time performance of the compiled programs, GCC formerly outperformed LLVM by 10% on average in 2011.[21][22] Newer results in 2013 indicate that LLVM has now caught up with GCC in this area, and is now compiling binaries of approximately equal performance.[23]

Components

LLVM has become an umbrella project containing multiple components.

Front ends

LLVM was originally written to be a replacement for the existing code generator in the GCC stack,[24]

and many of the GCC front ends have been modified to work with it. LLVM currently supports compiling of Ada, C, C++, D, Delphi, Fortran, Haskell, Julia, Objective-C, Rust, and Swift 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 several efforts to develop new front ends for a variety of languages. The one that has received the most attention is Clang, a new compiler supporting C, C++, and Objective-C. Primarily supported by Apple, Clang is aimed at replacing the C/Objective-C compiler in the GCC system with a system that is more easily integrated with integrated development environments (IDEs) and has wider support for multithreading. Support for OpenMP directives has been included in Clang since release 3.8.[25]

The Utrecht Haskell compiler can generate code for LLVM. Though the generator is in the early stages of development, in many cases it has been more efficient than the C code generator.[26] The Glasgow Haskell Compiler (GHC) has a working LLVM backend that achieves a 30% speed-up of the compiled code relative to native code compiling via GHC or C code generation followed by compiling, missing only one of the many optimizing techniques implemented by the GHC.[27]

Many other components are in various stages of development, including, but not limited to, the Rust compiler, 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|date=June 2012}}

Intermediate representation

The core of LLVM is the intermediate representation (IR), a low-level programming language similar to assembly. IR is a strongly typed reduced instruction set computing (RISC) instruction set which abstracts away details of the target. For example, the calling convention is abstracted through call and ret instructions with explicit arguments. Also, instead of a fixed set of registers, IR uses an infinite set of temporaries of the form %0, %1, etc. LLVM supports three isomorphic (i.e., functionally equivalent) forms of IR: a human-readable assembly format, an in-memory format suitable for frontends, and a dense bitcode format for serializing. A simple "Hello, world!" program in the assembly format:[28]

@.str = internal constant [14 x i8] c"hello, world\\0A\\00"

declare i32 @printf(i8*, ...)

define i32 @main(i32 %argc, i8** %argv) nounwind {

entry:

    %tmp1 = getelementptr [14 x i8], [14 x i8]* @.str, i32 0, i32 0    %tmp2 = call i32 (i8*, ...) @printf( i8* %tmp1 ) nounwind    ret i32 0

}

Back ends

At version 3.4, LLVM supports many instruction sets, including ARM, Qualcomm Hexagon, MIPS, Nvidia Parallel Thread Execution (PTX; called NVPTX in LLVM documentation), PowerPC, AMD TeraScale,[29] AMD Graphics Core Next (GCN), SPARC, z/Architecture (called SystemZ in LLVM documentation), x86, x86-64, and XCore. Some features are not available on some platforms. Most features are present for x86, x86-64, z/Architecture, ARM, and PowerPC.[30] RISC-V is supported as of version 7.

The LLVM machine code (MC) subproject is LLVM's framework for translating machine instructions between textual forms and machine code. Formerly, LLVM relied on the system assembler, or one provided by a toolchain, to translate assembly into machine code. LLVM MC's integrated assembler supports most LLVM targets, including x86, x86-64, ARM, and ARM64. For some targets, including the various MIPS instruction sets, integrated assembly support is usable but still in the beta stage.

Linker

The lld subproject is an attempt to develop a built-in, platform-independent linker for LLVM.[31] lld aims to remove dependence on a third-party linker. {{As of|2017|05}}, lld supports ELF, PE/COFF, and Mach-O in descending order of completeness.[31] In cases where lld is insufficient, another linker such as GNU ld can be used.

Using lld allows link-time optimization. When link-time optimization is enabled, the compiler generates LLVM bitcode instead of native code, and native code generation is done by the linker.

C++ Standard Library

The LLVM project includes an implementation of the C++ Standard Library, dual-licensed under the MIT License and the UIUC license.[32]

Debugger

{{Main article|LLDB (debugger)}}

Version history

See also

{{Portal|Free and open-source software}}
  • AMD Optimizing C/C++ Compiler
  • C--
  • Amsterdam Compiler Kit (ACK)
  • LLDB (debugger)
  • GNU lightning
  • GNU Compiler Collection (GCC)
  • Pure
  • OpenCL
  • Emscripten
  • TenDRA Distribution Format
  • Architecture Neutral Distribution Format (ANDF)
  • Comparison of application virtual machines
  • SPIR-V
  • University of Illinois at Urbana Champaign discoveries & innovations

Literature

  • Chris Lattner - The Architecture of Open Source Applications - Chapter 11 LLVM, {{ISBN|978-1257638017}}, released 2012 under CC BY 3.0 (Open Access).[34]
  • LLVM: A Compilation Framework for Lifelong Program Analysis & Transformation, a published paper by Chris Lattner, Vikram Adve

References

1. ^{{cite mailing list |url=http://lists.llvm.org/pipermail/llvm-announce/2019-March/000082.html|title=[llvm-announce] LLVM 8.0.0 Release|first=Hans|last=Wennborg|mailinglist=llvm-announce|date=20 March 2018|accessdate=20 March 2018}}
2. ^{{citation |url=http://llvm.org/docs/FAQ.html#license |title=License |work=LLVM: Frequently Asked Questions |publisher=llvm.org |accessdate=January 27, 2012}}
3. ^{{Cite web| title = The LLVM Compiler Infrastructure Project| accessdate = March 11, 2016| url = http://llvm.org/}}
4. ^{{citation |title= Announcing LLILC - A new LLVM-based Compiler for .NET |accessdate= April 17, 2015 |url= http://www.dotnetfoundation.org/blog/announcing-llilc-llvm-for-dotnet}}
5. ^{{citation |title= Mono LLVM |accessdate= March 10, 2013 |url= http://www.mono-project.com/Mono_LLVM}}
6. ^{{cite book|title=The Architecture of Open Source Applications|url=http://www.aosabook.org/|chapter=LLVM|chapter-url=http://www.aosabook.org/en/llvm.html|author=Chris Lattner|editor1=Amy Brown|editor2=Greg Wilson|year=2011}}
7. ^{{cite web|url=http://www.electronicdesign.com/test-measurement/what-s-difference-between-labview-2017-and-labview-nxg|title=What’s the Difference Between LabVIEW 2017 and LabVIEW NXG?|author=William Wong|date=May 23, 2017|website=Electronic Design}}
8. ^{{Cite web|url=http://llvm.org/ProjectsWithLLVM/#pony|title=The LLVM Compiler Infrastructure Project|website=llvm.org|access-date=May 25, 2016}}
9. ^{{cite web|title=Features|url=http://www.rubymotion.com/tour/features/|website=RubyMotion|publisher=Scratchwork Development LLC|accessdate=June 17, 2017|quote=RubyMotion transforms the Ruby source code of your project into ... machine code using a[n] ... ahead-of-time (AOT) compiler, based on LLVM.}}
10. ^{{Cite journal |last= Reedy |first= Geoff |title= Compiling Scala to LLVM |location= St. Louis, Missouri, United States |accessdate= February 19, 2013 |date= September 24, 2012 |url= http://www.infoq.com/presentations/Scala-LLVM}}
11. ^{{citation|url=http://lists.trolltech.com/qt4-preview-feedback/2005-02/msg00691.html |title=mkspecs and patches for LLVM compile of Qt4 |author=Adam Treat |date=February 19, 2005 |accessdate=January 27, 2012 |deadurl=yes |archiveurl=https://web.archive.org/web/20111004073001/http://lists.trolltech.com/qt4-preview-feedback/2005-02/msg00691.html |archivedate= October 4, 2011 |df= }}
12. ^{{citation |url=https://developer.apple.com/technologies/tools/ |title=Apple LLVM Compiler |work=Developer Tools |publisher=Apple |accessdate=January 27, 2012}}
13. ^{{citation |url=http://llvm.org/devmtg/2013-11/slides/Robinson-PS4Toolchain.pdf |title=Developer Toolchain for ps4 |accessdate=February 24, 2015}}
14. ^{{cite mailing list |title=The name of LLVM |url=http://lists.llvm.org/pipermail/llvm-dev/2011-December/046445.html |first=Chris |last=Lattner |mailinglist=llvm-dev |date=December 21, 2011 |accessdate=March 2, 2016}}
15. ^{{cite web|url=http://libcxx.llvm.org/|title="libc++" C++ Standard Library}}
16. ^{{cite web |url=http://blog.llvm.org/2014/04/the-llvm-foundation.html |title=The LLVM Foundation |work=LLVM Project Blog |date=April 3, 2014 |author=Chris Lattner}}
17. ^{{cite web |url=https://awards.acm.org/software-system/award-winners?year=2012&award=149®ion=&submit=Submit&isSpecialCategory= |title=ACM Software System Award |publisher=ACM}}
18. ^{{cite web | url=http://llvm.org/docs/LangRef.html | title=LLVM Language Reference Manual | accessdate=April 16, 2012}}
19. ^{{cite mailing list | url=http://lists.llvm.org/pipermail/llvm-dev/2006-August/006497.html | title=A cool use of LLVM at Apple: the OpenGL stack | author=Chris Lattner | date=August 15, 2006 | mailinglist=llvm-dev | accessdate=March 1, 2016}}
20. ^Michael Larabel, [https://www.phoronix.com/scan.php?page=news_item&px=MTAxMjI "GNOME Shell Works Without GPU Driver Support"], phoronix, November 6, 2011
21. ^{{cite web | url=http://vmakarov.fedorapeople.org/spec/2011/llvmgcc32.html | author=V. Makarov | title=SPEC2000: Comparison of LLVM-2.9 and GCC4.6.1 on x86 | accessdate=October 3, 2011}}
22. ^{{cite web | url=http://vmakarov.fedorapeople.org/spec/2011/llvmgcc64.html | author=V. Makarov | title=SPEC2000: Comparison of LLVM-2.9 and GCC4.6.1 on x86_64 | accessdate=October 3, 2011}}
23. ^{{cite web | url=https://www.phoronix.com/scan.php?page=article&item=llvm_clang32_final | author=Michael Larabel | title=LLVM/Clang 3.2 Compiler Competing With GCC | date = December 27, 2012 | accessdate=March 31, 2013}}
24. ^{{cite conference | first=Chris | last=Lattner | authorlink=Chris Lattner | author2=Vikram Adve | title=Architecture For a Next-Generation GCC | url=http://llvm.org/pubs/2003-05-01-GCCSummit2003.html | conference=First Annual GCC Developers' Summit | date=May 2003 | accessdate=September 6, 2009}}
25. ^{{cite web | url=http://llvm.org/releases/3.8.0/tools/clang/docs/ReleaseNotes.html#openmp-support-in-clan | title=Clang 3.8 Release Notes | accessdate=August 24, 2016}}
26. ^{{cite web | url=http://www.cs.uu.nl/wiki/bin/view/Stc/CompilingHaskellToLLVM | title=Compiling Haskell To LLVM | accessdate=February 22, 2009}}
27. ^{{cite web | url=http://blog.llvm.org/2010/05/glasgow-haskell-compiler-and-llvm.html | title=LLVM Project Blog: The Glasgow Haskell Compiler and LLVM | accessdate=August 13, 2010}}
28. ^For the full documentation, refer to {{URL|http://llvm.org/docs/LangRef.html}}.
29. ^{{cite mailing list |url=http://lists.llvm.org/pipermail/llvm-dev/2012-March/048409.html |title=[LLVMdev] RFC: R600, a new backend for AMD GPUs |mailinglist=llvm-dev |first=Tom |last=Stellard |date=March 26, 2012}}
30. ^Target-specific Implementation Notes: Target Feature Matrix // The LLVM Target-Independent Code Generator, LLVM site.
31. ^{{cite web|title=lld - The LLVM Linker|url=http://lld.llvm.org/|publisher=The LLVM Project|accessdate=May 10, 2017}}
32. ^{{cite web|url=http://libcxx.llvm.org|title="libc++" C++ Standard Library}}
33. ^{{Cite web|url=http://llvm.org/releases/|title=Download LLVM releases|website=llvm.org|access-date=November 23, 2017}}
34. ^{{cite book|title=The Architecture of Open Source Applications|publisher=Amy Brown, Greg Wilson |chapter=Chapter 11|author=Chris Lattner|date=March 15, 2012|ISBN=978-1257638017|url=http://www.aosabook.org/en/llvm.html}}

External links

  • {{Official website}}


{{FLOSS}}

{{Use mdy dates|date=October 2018}}

4 : Compilers|Free compilers and interpreters|Register-based virtual machines|Software using the NCSA license

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/9/23 7:34:12