Rllvm v0.7-0

Interface to llvm for dynamically compiling native code.

This package is currently an interface to some of the functionality in the llvm toolkit for programmaticall constructing native code. This allows us to build "compilers" in R and use llvm's optmization and JIT techniques to improve the code we generate and then turn it into machine code. This is currently not a compiler. There are examples that illustrate how to generate code to create native functions that are equivalent to some simple R functions. The goal is to build on this and create a compiler, hopefully building on the framework that Luke Tierney has created in his compiler package (see http://www.cs.uiowa.edu/~luke/R/compiler/). This is in the RLLVCompile package. The speed up we achieve compiling R code in our examples illustrate that we can significantly outperform the R interpreter and also can outperform some of R's vectorized code by rearranging the computations, e.g. fusing loops, avoiding memory usage.

Readme

RLLVM

RLLVM is an R interface to LLVM. This interface allows one to create compiled code from within R through LLVM's intermediate representation (IR), which LLVM can then extensively and efficiently optimize.

For examples, see the RLLVM page on Omegahat.

The current repository builds against LLVM 3.5, 3.6, 3.7, and3.8. Importantly, recent versions of LLVM default to the MCJIT execution engine. This unfortunately has very limited ability to invoke routines compiled via Rllvm, i.e., using the .llvm() and run() functions. Acccordingly, we have implemented a simple (but reasonably comprehensive) mechanism to invoke these routines. We use the Rffi package to do this. We might shift to the rdyncall package.

So this package now requires the Rffi package. This comes with its own version of libffi, but will find a more up-to-date version if it is installed (see pkg-config).

These packages are not yet on CRAN.

Related packages are Rffi, Rllvm (this one), RLLVMCompile, RCUDA, RCIndex.

Functions in Rllvm

Name Description
Block Create an LLVM block
createIsNotNull Create LLVM operations
declareFunction Declare a function in a module
.llvm Invoke an LLVM Function from R
clone Collection of generic functions for LLVM objects
addCases Add cases to a switch instruction
createICmp Create an integer comparison instruction
createGlobalVariable Define a native global variable
binOp Create a binary operation instruction
ExecutionEngine Create LLVM engine for calling functions
getGetElementPtr Create LLVM instruction to access an element in an array or via pointer
getModuleFunctions Get a list of the functions in an LLVM module
createLogicalConstant Create constants in native code
getGlobalContext Retrieve the default LLVM context
getPassManager Create an LLVM pass manager
generatePTX Generate PTX code to run on a NVIDIA GPU
getOpcode Get the operation code/identifier for an LLVM instruction
Function Create an LLVM function/routine
formattedRawOstream Create and access LLVM output streams
getCallingConv Get and set the calling convention for a routine
isCast Miscellaneous functions operating on LLVM Instruction objects
getIntrinsic Functions for working with LLVM Intrinsic routines
getSuccessor Get different aspects of a Branch Instruction
llvmAddSymbol Resolving external symbols
getValue Get the value from an LLVM entity
isArrayType Predicate functions for testing a type
isInBounds Query or set bounds checking flag
InitializeNativeTarget Initialize the LLVM engine for JIT operations
isa Queries if an LLVM Instruction is a particular sub-type
IRBuilder Create an IR builder object for LLVM construction
parseIRError Raise an error from parseIR
setArgByVal Set and Query Pass-By-Value Semantics for a Parameter
setAlignment Set the alignment for an LLVM instruction or object
parseIR Read LLVM Code in the Intermediate Representation (IR) Language
createAggressiveDCEPass Create LLVM Pass Instances
Module Create an LLVM module for one or more functions and variables
llvmDump Create a text representation of an LLVM object
onlyReadsMemory Determines if the LLVM does not write to memory
Rllvm-package The Rllvm Package
RC++Reference-class Class "RC++Reference"
simpleFunction Define the skeleton of an LLVM Function
string Initialize a string object
writeBitcode Read and Write LLVM Bitcode
VoidType Objects representing different LLVM common Types
setInitializer Set the initializer for an LLVM Value
targetLibraryInfo Functions related to different targets
setMetadata Functions for working with LLVM metadata
arrayType Miscellaneous functions for LLVM Types
No Results!

Details

SystemRequirements llvm (>= 2.7)
License GPL-2
URL http://www.omegahat.net/Rllvm https://github.com/duncantl/Rllvm
Note We hope to build on this to build a compiler for parts of the R language. See the RLLVMCompile package at http://www.omegahat.net/RLLVMCompile and https://github.com/duncantl/RLLVMCompile/
Collate llvmVersion.R classDefs.R manual_generics.R block.R module.R typeDefs.R ExecutionEngine.R IRBuilder.R onLoad.R ICmpEnums.R constants.R externalLinkage.R globalVar.R value.R dso.R context.R TypeID.R generics.R instruction.R manual_instruction.R mkFun.R intrinsic.R IntrinsicEnums.R sexpTypes.R utils.R targets.R simpleFunction.R PassManager.R llvm.R declareFunction.R typeName.R ostream.R targetMachine.R metadata.R opCodeClassMap.R classof.R initialize.R CallingConvEnum.R llvmPTXUtils.R byVal.R getCondition.R passConstructors.R showBlocks.R z_enumDefs_3.4.R z_enumDefs_3.5.R z_enumDefs_3.6.R z_enumDefs_3.7.R z_enumDefs_3.8.R z_enumDefs_3.9.R z_enumDefs_4.0.R z_enumDefs_5.0.R z_enumDefs_6.0.R types.R Function.R ascii.R user.R phi.R datalayout.R DIBuilder.R procEnumValues.R streams.R ffi.R assembler.R

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/Rllvm)](http://www.rdocumentation.org/packages/Rllvm)