Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
LLVM
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Intermediate representation=== [[File:Mesa layers of crap 2016.svg|thumb|LLVM IR is used e.g., by radeonsi and by llvmpipe. Both are part of [[Mesa 3D]].]] 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 computer]] (RISC) instruction set which abstracts away most details of the target. For example, the [[calling convention]] is abstracted through <code>call</code> and <code>ret</code> 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 equivalent forms of IR: a human-readable assembly format,<ref name=IRref>{{cite web |url=https://llvm.org/docs/LangRef.html |title=LLVM Language Reference Manual |author=<!-- Unstated staff writers --> |date=10 January 2023 |website=LLVM.org}}</ref> an in-memory format suitable for frontends, and a dense bitcode format for serializing. A simple [["Hello, world!" program]] in the human-readable IR format: <syntaxhighlight lang="llvm"> @.str = internal constant [14 x i8] c"Hello, world\0A\00" declare i32 @printf(ptr, ...) define i32 @main(i32 %argc, ptr %argv) nounwind { entry: %tmp1 = getelementptr [14 x i8], ptr @.str, i32 0, i32 0 %tmp2 = call i32 (ptr, ...) @printf( ptr %tmp1 ) nounwind ret i32 0 } </syntaxhighlight> The many different conventions used and features provided by different targets mean that LLVM cannot truly produce a target-independent IR and retarget it without breaking some established rules. Examples of target dependence beyond what is explicitly mentioned in the documentation can be found in a 2011 proposal for "wordcode", a fully target-independent variant of LLVM IR intended for online distribution.<ref>{{cite web |last1=Kang |first1=Jin-Gu |title=Wordcode: more target independent LLVM bitcode |url=https://llvm.org/devmtg/2011-09-16/EuroLLVM2011-MoreTargetIndependentLLVMBitcode.pdf |access-date=1 December 2019}}</ref> A more practical example is [[PNaCl]].<ref>{{cite web|url=http://nativeclient.googlecode.com/svn/data/site/pnacl.pdf |title=PNaCl: Portable Native Client Executables |access-date=25 April 2012 |url-status=dead |archive-url=https://web.archive.org/web/20120502135033/http://nativeclient.googlecode.com/svn/data/site/pnacl.pdf |archive-date=2 May 2012 |df=dmy-all}}</ref> The LLVM project also introduces another type of intermediate representation named [[MLIR (software)|MLIR]]<ref>{{Cite web |title=MLIR |url=https://mlir.llvm.org/ |access-date=2022-06-07 |website=mlir.llvm.org}}</ref> which helps build reusable and extensible compiler infrastructure by employing a plugin architecture named Dialect.<ref>{{Cite web |title=Dialects - MLIR |url=https://mlir.llvm.org/docs/Dialects/ |access-date=2022-06-07 |website=mlir.llvm.org}}</ref> It enables the use of higher-level information on the program structure in the process of optimization including [[Polytope model|polyhedral compilation]].
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)