Runtime: export function to import own functionality to target module (perhaps it's frontend task)

This commit is contained in:
Vasily Levchenko
2016-10-21 05:29:28 +03:00
parent 7d243378cd
commit 0523505354
@@ -34,6 +34,15 @@ class Runtime(private val bitcodeFile: String) {
val fieldTableRecordType = LLVMGetTypeByName(llvmModule, "struct.FieldTableRecord")
val methodTableRecordType = LLVMGetTypeByName(llvmModule, "struct.MethodTableRecord")
val globalhHashType = LLVMGetTypeByName(llvmModule, "struct.GlobalHash")
val allocInstanceFunction = LLVMGetNamedFunction(llvmModule, "AllocInstance")
fun importRuntime(module: LLVMOpaqueModule) {
memScoped {
val params = allocNativeArrayOf(LLVMOpaqueType, pointerType(typeInfoType), LLVMInt32Type())
val functionAllocInstanceType = LLVMFunctionType(pointerType(LLVMInt8Type()),params[0], 2, 0)
LLVMAddFunction(module, "AllocInstance", functionAllocInstanceType)
}
}
val target = LLVMGetTarget(llvmModule)!!.asCString().toString()