Browse files

compile for 3.2 and 3.2 for attributes, numerous additions. See

  • Loading branch information...
1 parent 85b3a2f commit a0f2c383644df93bbddb8ea3085c31f23eaf5c87 @duncantl committed Jun 2, 2013
@@ -1,5 +1,12 @@
Version 0.5-0
+ * show() methods for Module, Function, Type to make the
+ objects more informative when displayed.
+ * export getBlocks() function.
+ * sapply() method for iterating over a block
* get function attributes
* Set and get attributes on parameters
@@ -20,7 +27,7 @@ Version 0.5-0
* Retrieve global variable arrays as R objects.
- * createStructGEP().
+ * createStructGEP() function.
* ExecutionEngine() supports specifying optimization level.
@@ -1,6 +1,6 @@
Package: Rllvm
Version: 0.5-0
-Title: Interface to llvm for creating native functions
+Title: Interface to llvm for dynamically compiling native code.
Author: Duncan Temple Lang, Vince Buffalo
SystemRequirements: llvm (>= 2.7)
Maintainer: Duncan Temple Lang <>
@@ -23,12 +23,12 @@ Depends: R (>= 2.7.0), methods, RAutoGenRunTime
Note: We hope to build on this to build a compiler for parts of the R language.
-Collate: classDefs.R manual_generics.R BinaryOpEnums.R Function.R block.R module.R typeDefs.R
+Collate: llvmVersion.R classDefs.R manual_generics.R BinaryOpEnums.R Function.R block.R module.R typeDefs.R
ExecutionEngine.R IRBuilder.R onLoad.R ICmpEnums.R types.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
+ declareFunction.R typeName.R
@@ -146,7 +146,8 @@ pointerType,
run, .llvm, .llvmCallFunction,
@@ -347,3 +348,11 @@ export(setParamAttributes)
+export(getNumOperands, getOperand)
7 Notes
@@ -20,4 +20,9 @@ The opt command line executable is for passing IR code through the LLVM optimize
Activating Different Targets
- For example, the NVPTX
+ For example, the NVPTX
+A call instruction is represented as
+ arg1, arg2, ..., called routine
+This the order of the opernds.
@@ -0,0 +1,10 @@
+Rllvm.pdf: Rllvm.tex rllvm.bib GNUmakefile jssMacros.tex
+ -pdflatex $(<F)
+ -pdflatex $(<F)
+ -bibtex Rllvm
+ -pdflatex $(<F)
+ -rm Rllvm.{aux,log,out,blg}
@@ -0,0 +1,131 @@
+%% declarations for jss.cls %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% almost as usual
+\author{Duncan Temple Lang\\University of California at Davis}
+\title{The \Rpkg{Rllvm} package: generating fast code in \R{} by compiling with \llvm.}
+%% for pretty printing and a nice hypersummary also set:
+\Plainauthor{Duncan Temple Lang}
+\Plaintitle{The Rllvm package: generating fast code in R by compiling with LLVM.}
+%% an abstract and keywords
+\Keywords{\R, \Rpkg{Rllvm} package, compiled code}
+\Plainkeywords{R, RCIndex} %% without formatting
+%% at least one keyword must be supplied
+%% publication information
+%% NOTE: Typically, this can be left commented and will be filled out by the technical editor
+%% \Volume{13}
+%% \Issue{9}
+%% \Month{September}
+%% \Year{2004}
+%% \Submitdate{2004-09-29}
+%% \Acceptdate{2004-09-29}
+%% The address of (at least) one author should be given
+%% in the following format:
+ Duncan Temple Lang\\
+ 4210 Math Sciences Building, \\
+ University of California at Davis \\
+ One Shields Avenue\\
+ Davis, CA 95616\\
+ E-mail: \email{}\\
+ URL: \url{}
+\section{Overview \& Motivation}\label{sec:Introduction}
+The potential readers of this paper are people who are interested in
+exploring how to create machine code directly within R for either
+compiling R code or for developing domain specific languages in R.
+We are using this to compile simple functions in R for speed
+and also to get them to run on the GPU to take advantage
+of massively parallel architectures.
+This is more of a manual about how to program with the \Rpkg{Rllvm}
+package than what we can do with it our how we compile \R{} code. We
+will explain some of this using example code from the
+\Rpkg{RLLVMCompile} package. However, this is not a paper that
+describes that package and its compilation approach.
+In many respects, this article is an overview of what the \llvm{}
+API provides for applications which use it. We describe the concepts,
+classes and methods in that API, but in terms of how we manipulate these
+in \R.
+We will show how we can call existing \C{} routines using a
+combination of \RClang and \Rllvm. We also show how we can compile
+simple functions such as the fibonacci sequence. Similarly, we'll
+show how to compile simple loops which can remove the need to write
+vectorized code. We'll show how to write a simple DSL, e.g. map a
+BUGS hierarchical model to a sampler. (Too ambitious.)
+We'll show how we can generate code for different input types
+and so think of the high-level code as a template.
+(This is done for the sort routine in C code in qsort.c by redefining the
+type NUMERIC.
+Show how to make code use multiple cores directly, with shared data?
+Some readers may say the examples are unrealistic as \R{} already has
+fast code to implement, e.g., \Rfunc{sum} and so on. The point is not
+to compete with those existing functions that are implemented in
+C. Rather, the point is to say that we could implement them in \R{}
+code, make them more flexible so that they can run on multiple
+processors, take advantage of contextual information, e.g. no \na's,
+reusing memory. The examples are intentionally simple to focus on how
+we generate the equivalent machine code.
+\section{The basic steps of generating machine code}
+%LLVM Concepts
+We start with some parsed code. To illustrate, consider computing the
+sum of the elements of a vector. %better example that R doesn't
+already do. A distribution function that can't be vectorized?%
+% How about a bootstrap or call to replicate() and reuse the memory.
+% Compile the loop to not need the vector to be expanded, but use a counter
+% Call R's internal functions. Since a primitive
+We need to create two routines.
+% Sharing code with other systems.
+\section{Future Work}
Oops, something went wrong.

0 comments on commit a0f2c38

Please sign in to comment.