词条 | Intermediate representation |
释义 |
An Intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive for further processing, such as optimization and translation.[1] A "good" IR must be accurate – capable of representing the source code without loss of information[2] – and independent of any particular source or target language.[1] An IR may take one of several forms: an in-memory data structure, or a special tuple- or stack-based code readable by the program.[3] In the latter case it is also called an intermediate language. A canonical example is found in most modern compilers, where the linear human-readable text representing a program is transformed into an intermediate graph structure that allows flow analysis and re-arrangement before creating a sequence of actual CPU instructions. Use of an intermediate representation such as this allows compiler systems like the GNU Compiler Collection and LLVM to be used by many different source languages to generate code for many different target architectures. Intermediate languageAn intermediate language is the language of an abstract machine designed to aid in the analysis of computer programs. The term comes from their use in compilers, where the source code of a program is translated into a form more suitable for code-improving transformations before being used to generate object or machine code for a target machine. The design of an intermediate language typically differs from that of a practical machine language in three fundamental ways:
A popular format for intermediate languages is three-address code. The term is also used to refer to languages used as intermediates by some high-level programming languages which do not output object or machine code themselves, but output the intermediate language only. This intermediate language is submitted to a compiler for such language, which then outputs finished object or machine code. This is usually done to ease the process of optimization or to increase portability by using an intermediate language that has compilers for many processors and operating systems, such as C. Languages used for this fall in complexity between high-level languages and low-level languages, such as assembly languages. LanguagesThough not explicitly designed as an intermediate language, C's nature as an abstraction of assembly and its ubiquity as the de facto system language in Unix-like and other operating systems has made it a popular intermediate language: Eiffel, Sather, Esterel, some dialects of Lisp (Lush, Gambit), Haskell (Glasgow Haskell Compiler), Squeak's Smalltalk-subset Slang, Cython, Seed7, SystemTap, Vala, and others make use of C as an intermediate language. Variants of C have been designed to provide C's features as a portable assembly language, including C-- and the C Intermediate Language. Any language targeting a virtual machine or p-code machine can be considered an intermediate language:
The GNU Compiler Collection (GCC) uses several intermediate languages internally to simplify portability and cross-compilation. Among these languages are
The LLVM compiler framework is based on the LLVM IR intermediate language, of which the compact, binary serialized representation is also referred to as "bitcode" and has been productized by Apple.[4][5] The ILOC intermediate language[6] is used in classes on compiler design as a simple target language.[7] OtherStatic analysis tools often use an intermediate representation. For instance, radare2 is a toolbox for binary files analysis and reverse-engineering. It uses the intermediate languages ESIL[8] et REIL[9] to analyze binary files. See also
References1. ^1 {{Cite web| last = Walker| first = David| title = CS320: Compilers: Intermediate Representation | format = Lecture slides | accessdate = 2016-02-12 | url = http://www.cs.princeton.edu/courses/archive/spr03/cs320/notes/IR-trans1.pdf}} 2. ^{{Cite journal| volume = 11| issue = 10| last = Chow| first = Fred| title = The Challenge of Cross-language Interoperability| journal = ACM Queue| accessdate = 2016-02-12| date = 2013-11-22| url = https://queue.acm.org/detail.cfm?id=2544374}} 3. ^{{Cite web| last = Toal| first = Ray| title = Intermediate Representations| accessdate = 2016-02-12| url = http://cs.lmu.edu/~ray/notes/ir/}} 4. ^{{cite web | url=https://news.ycombinator.com/item?id=9684223 | title=Bitcode (iOS, watchOS) | publisher=Hacker News | date=10 June 2015 | accessdate=17 June 2015}} 5. ^{{cite web | url=http://llvm.org/docs/BitCodeFormat.html | title=LLVM Bitcode File Format | publisher=llvm.org | accessdate=17 June 2015}} 6. ^"An ILOC Simulator" {{webarchive|url=https://web.archive.org/web/20090507084132/http://www.engr.sjsu.edu/wbarrett/Parser/simManual.htm |date=2009-05-07 }}by W. A. Barrett 2007, paraphrasing Keith Cooper and Linda Torczon, "Engineering a Compiler", Morgan Kaufmann, 2004. {{ISBN|1-55860-698-X}}. 7. ^"CISC 471 Compiler Design" by Uli Kremer 8. ^{{cite web | url=https://radare.gitbooks.io/radare2book/content/esil.html | title=ESIL | publisher=radare2 project | accessdate=17 June 2015 | author=The radare2 contributors}} 9. ^{{cite web | url=http://blog.zynamics.com/2010/03/07/the-reil-language-part-i/ | title=The REIL language – Part I | publisher=zynamics.com | date=7 March 2010 | accessdate=17 June 2015 | author=Sebastian Porst}} External links
2 : Compiler construction|Programming language classification |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。