Unformatted text preview:

LLVMLLVM Compiler SystemThree primary LLVM componentsThe LLVM C/C++ CompilerThe LLVM C/C++ Compiler (cont)Looking into events at compile-timeExample Intermediate RepresentationCurrent Uses/Projects made with LLVMFuture of LLVMLLVMLLVMDeveloped by University of Developed by University of Illinois at Urbana-Champaign Illinois at Urbana-Champaign CIS deptCIS deptCisc 471Cisc 471Matthew WarnerMatthew WarnerLLVM Compiler SystemLLVM Compiler SystemLLVM = Low Level Virtual Machine LLVM = Low Level Virtual Machine The LLVM Compiler InfrastructureThe LLVM Compiler InfrastructureProvides reusable components for building Provides reusable components for building compilerscompilersReduce the time/cost to build a new compilerReduce the time/cost to build a new compilerBuild static compilers, JITs, trace-based Build static compilers, JITs, trace-based optimizers, ...optimizers, ...The LLVM Compiler FrameworkThe LLVM Compiler FrameworkEnd-to-end compilers using the LLVM infrastructureEnd-to-end compilers using the LLVM infrastructureC and C++ are robust and aggressive:C and C++ are robust and aggressive:Java, Scheme and others are in developmentJava, Scheme and others are in developmentEmit C code or native code for X86, Sparc, PowerPCEmit C code or native code for X86, Sparc, PowerPCThree primary LLVM Three primary LLVM componentscomponentsThe LLVM The LLVM Virtual Instruction SetVirtual Instruction SetThe common language- and target-independent IRThe common language- and target-independent IRInternal (IR) and external (persistent) Internal (IR) and external (persistent) representationrepresentationA collection of well-integrated librariesA collection of well-integrated librariesAnalyses, optimizations, code generators, JIT Analyses, optimizations, code generators, JIT compiler, garbage collection support, profiling, …compiler, garbage collection support, profiling, …A collection of tools built from the librariesA collection of tools built from the librariesAssemblers, automatic debugger, linker, code Assemblers, automatic debugger, linker, code generator, compiler driver, modular optimizer, …generator, compiler driver, modular optimizer, …The LLVM C/C++ The LLVM C/C++ CompilerCompilerFrom the high level, it is a standard compiler:From the high level, it is a standard compiler:Compatible with standard makefilesCompatible with standard makefilesUses GCC 3.4 C and C++ parserUses GCC 3.4 C and C++ parserDistinguishing features:Distinguishing features:Uses LLVM optimizers, not GCC optimizersUses LLVM optimizers, not GCC optimizers.o files contain LLVM IR/bytecode, not machine code.o files contain LLVM IR/bytecode, not machine codeExecutable can be bytecode (JIT’d) or machine codeExecutable can be bytecode (JIT’d) or machine codellvmg++llvmgccC fileC++ file.o file.o filellvm linker executableCompile Time Link TimeThe LLVM C/C++ Compiler The LLVM C/C++ Compiler (cont)(cont)Standard compiler organization, which uses LLVM as midlevel IR:– Language specific front-end lowers code to LLVM IR– Language/target independent optimizers improve code– Code generator converts LLVM code to target (e.g. IA64) codeLooking into events at Looking into events at compile-timecompile-timellvmgccC file .o file llvmg++C++ file .o fileModified version of G++Emits LLVM IR as text fileLowers C++ AST to LLVMModified version of GCCEmits LLVM IR as text fileLowers C AST to LLVMLLVM IR ParserLLVM Verifier40 LLVM Analysis & Optimization PassesLLVM .bc File WriterC to LLVM FrontendCompile-time OptimizerC++ to LLVM FrontendCompile-time Optimizer“cc1” “cc1plus” “gccas”“gccas”Dead Global Elimination, IP Constant Propagation, Dead Argument Elimination, Inlining, Reassociation, LICM, Loop Opts, Memory Promotion, Dead Store Elimination, ADCE, …Example Intermediate Example Intermediate RepresentationRepresentation; Declare the string constant as a global constant...; Declare the string constant as a global [email protected]@.LC0 = = internalinternal constant [13 x i8] c"hello world\0A\00" constant [13 x i8] c"hello world\0A\00" ; [13 x i8]*; [13 x i8]* ; External declaration of the puts function; External declaration of the puts functiondeclare i32 @puts(i8 *) declare i32 @puts(i8 *) ; i32(i8 *)*; i32(i8 *)* ; Definition of main function; Definition of main functiondefine i32 @main() { define i32 @main() { ; i32()*; i32()* ; Convert [13x i8 ]* to i8 *...; Convert [13x i8 ]* to i8 *... %cast210 = getelementptr %cast210 = getelementptr [13 x i8 ]* @.LC0, i64 0, i64 0 [13 x i8 ]* @.LC0, i64 0, i64 0 ; i8 *; i8 * ; Call puts function to write out the string to stdout...; Call puts function to write out the string to stdout... call i32 @puts(i8 * %cast210) call i32 @puts(i8 * %cast210)ret i32 0 ret i32 0 } }Current Uses/Projects made Current Uses/Projects made with LLVMwith LLVMRegister Allocation solving by Using Register Allocation solving by Using Puzzle Solving techniquesPuzzle Solving techniquesScheme compilerScheme compilerJIT Compiler for LLVM bytecodeJIT Compiler for LLVM bytecodeFuture of LLVMFuture of LLVMCurrently a partial version of the Currently a partial version of the Java compiler exists and need to be Java compiler exists and need to be extendedextendedImprove optimizations for Improve optimizations for performanceperformanceMost of LLVM’s current optimizations Most of LLVM’s current optimizations are performance based, need are performance based, need optimizations for sizeoptimizations for


View Full Document

UD CISC 471 - LLVM Compiler System

Download LLVM Compiler System
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LLVM Compiler System and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LLVM Compiler System 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?