Description Usage Arguments Value Author(s) References See Also Examples
This function is used for de-serializing LLVM code in intermediate representation form into in-memory description of the code. This can then be converted to machine code and run, including passed through optimization passes. This allows us to create the code description directly using the IR language rather than via the functions to create the function, blocks, instructions incrementally with R code.
1 2 3 4 | parseIR(content, context = NULL,
asText = is(content, "AsIs") || !file.exists(content))
parseAssembly(code, module = NULL, context = NULL,
asText = !file.exists(code))
|
content,code |
the name of a file containing the IR content, or the
actual IR content as a character vector. Content can be identified
via the |
context |
the LLVM context in which to parse the code and create the Module. By default, we use the global context |
module |
the module into which to create the code objects. This will be created if not specified. |
asText |
a logical value that indicates whether |
An object of class Module
, or NULL
if the code cannot be parsed.
Duncan Temple Lang
LLVM API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | InitializeNativeTarget()
## Not run:
ff = system.file("IR", "add.ll", package = "Rllvm")
# Read directly from a file
m = parseIR(ff)
print(showModule(m))
ee = ExecutionEngine(m)
Optimize(m, ee)
foo = getModuleFunctions(m)$foo
run(foo, x = 1L, y = 12L, .ee = ee)
run(foo, x = 30000L, y = 12L, .ee = ee)
# Now read the content of the file into a string and
# work with the code in memory.
ll = readLines(ff)
m = parseIR(ll, asText = TRUE)
# Now actually create the code as a string
ll = 'define i32 @bar() nounwind readnone ssp {
entry:
ret i32 2
}'
m = parseIR(ll, asText = TRUE)
Optimize(m,)
run(getModuleFunctions(m)$bar)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.