backend: import external functions with proper attributes
This commit is contained in:
committed by
SvyatoslavScherbina
parent
b531d984c8
commit
7374ea642f
+8
-1
@@ -202,7 +202,14 @@ internal class Llvm(val context: Context, val llvmModule: LLVMModuleRef) {
|
||||
val externalFunction = LLVMGetNamedFunction(otherModule, name)!!
|
||||
|
||||
val functionType = getFunctionType(externalFunction)
|
||||
return LLVMAddFunction(llvmModule, name, functionType)!!
|
||||
val function = LLVMAddFunction(llvmModule, name, functionType)!!
|
||||
val attributes = LLVMGetFunctionAttrSet(externalFunction)
|
||||
for (attribute in LLVMAttribute.values()) {
|
||||
if (attribute in attributes) {
|
||||
LLVMAddFunctionAttr(function, attribute)
|
||||
}
|
||||
}
|
||||
return function
|
||||
}
|
||||
|
||||
private fun importMemset() : LLVMValueRef {
|
||||
|
||||
+4
@@ -230,3 +230,7 @@ fun llvmtype2string(type: LLVMTypeRef?): String {
|
||||
return LLVMPrintTypeToString(type)!!.asCString().toString()
|
||||
}
|
||||
|
||||
internal operator fun LLVMAttributeSet.contains(attribute: LLVMAttribute): Boolean {
|
||||
return (this and attribute.value) != 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user