# NOT RUN {
InitializeNativeTarget()
# }
# NOT RUN {
<!-- % format not quite correct due to different versions -->
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)
# }
Run the code above in your browser using DataLab