ModuleODSigs | R Documentation |
This is a function and also supporting class and methods
that take an LLVM Module in which to create new Function
objects, but which also will search additional Modules
for the signatures of external routines that we want to call.
By external, we mean not in the current module.
If a Function is not found by name in the current module,
this looks in the other Modules provided when we call
ModuleODSigs
.
These can be provided as actual Module objects, or
as a collection of file names which will be read sequentially
when looking for a Function.
These files are loaded only once and the resulting Module cached and
reused across subsequent calls to find a Function.
We have a sequence of Modules and also file names which we will lazily load when looking for a Function by name. This is analogous to the R search path when looking for a symbol.
ModuleODSigs(mod, files = system.file("Rmain.bc", package = "RLLVMCompile"), ..., .modules = list(...))
mod |
the actual |
files |
a character vector of files whose contents can be read by
|
... |
zero or |
.modules |
an alternative form of specifying the list of
|
This uses the externalptr object in the
target Module-class
, i.e., mod
to dynamically or "across-calls" update
the list of Module-class
s
in which to search for the named Function.
If we don't find the named Function, we
sequentially read the remaining files.
As we read each file, we remove it from the list and add the resulting
Module-class
to the available
Module-class
s list for subsequent calls
so that we won't have to parse it again.
An object of class ModuleODSigs-class
which extends the Module-class
class,
i.e. this is a regular Module-class
and is the mod
value passed to the R function.
It just has extra information and functionality.
DTL
Module-class
,
Function-class
m = Module()
Function("x", Int32Type, module = m)
names(m)
em = ModuleODSigs(m, c(system.file("IR/rapiEg.ir", package = "Rllvm"),
system.file("IR/fib.ll", package = "Rllvm")))
em$Rf_allocVector
names(m)
names(em)
em[["Rf_allocVector"]]
em$fib
em$x
# returns NULL.
em[["Rf_allocVector3"]]
# Show the parseIR() calls when they happen and that we load fib when looking for doesnt_exist
# because it is not in the first Module() on the sub-Module list.
other = Module()
Function("foo", VoidType, module = other)
m = Module()
em = ModuleODSigs(m, c(system.file("IR/rapiEg.ir", package = "Rllvm"),
system.file("IR/fib.ll", package = "Rllvm")), other)
trace(parseIR, quote(print(content)))
f0 = files(em)
em$Rf_allocVector
em$foo
f1 = files(em)
em$doesnt_exist
f2 = files(em)
em$fib
em$bob
f0
f1
f2
untrace(parseIR)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.