R
Byte Code to LLVM
An interesting and potentially very valuable approach might
be to take R
byte-code created by the compiler package
and map it into LLVM IR and compile that to machine code.
We might end up just repeating the same optimization steps. However, we could get the code to machine code.
We can get the byte-code via the disassemble() function:
disassemble(cf) list(.Code, list(7L, LDCONST.OP, 1L, SETVAR.OP, 2L, POP.OP, GETVAR.OP, 3L, STARTFOR.OP, 5L, 4L, 21L, GETVAR.OP, 2L, GETVAR.OP, 4L, ADD.OP, 6L, SETVAR.OP, 2L, POP.OP, STEPFOR.OP, 12L, ENDFOR.OP, INVISIBLE.OP, RETURN.OP), list({ ans = 0 for (i in x) ans = ans + i }, 0, ans, x, i, for (i in x) ans = ans + i, ans + i))