Function: Create an LLVM function/routine

View source: R/Function.R

FunctionR Documentation

Create an LLVM function/routine

Description

This function and class creates a template Function object which we can use to build a native, compiled function.

This is not to be confused with the R reserved word function.

Usage

Function(name, retType, paramTypes = list(), module = Module(), varArgs = FALSE, ...)

Arguments

name

a string giving the name of the function

retType

the return type of the new function. This should be of class Type-class.

paramTypes

a list giving the types of the parameters of the function. These can be named or not.

module

the module in which the function is to be defined

varArgs

a logical value that indicates whether the routine has variadic arguments, i.e. passed to it via ... (not the ... in this function)

...

additional inputs for this call (not for calling the routine)

Value

An object of class Function

Author(s)

Duncan Temple Lang

References

LLVM Documentation http://llvm.org/docs/

See Also

simpleFunction, Block, IRBuilder

Examples

    # This shows how we can use LLVM to call an existing routine.
m = Module()
ee = ExecutionEngine(m)
Rf_PrintValue = declareFunction(list(VoidType, SEXPType),  "Rf_PrintValue", m)
#llvmAddSymbol("Rf_PrintValue")
.llvm(Rf_PrintValue, 1:10)



m = Module()
f = Function("f", Int32Type, module = m)
ir = IRBuilder(f)
ir$createReturn(ir$createConstant(3L))
showModule(m)
.llvm(f)



f = system.file("IR/fib.ir", package = 'Rllvm')
m = parseIR(f)
a1 = getFuncAttributes(m$fib)
a2 = getFuncAttributes(m$fib, FALSE)

names(a2)
names(a2)[a2]

duncantl/Rllvm documentation built on April 23, 2024, 6:14 p.m.