Skip to content

Commit

Permalink
Change name and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
gbaraldi committed May 24, 2023
1 parent 9b418ed commit fe67d67
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 33 deletions.
22 changes: 11 additions & 11 deletions src/codegen-stubs.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,24 +140,24 @@ JL_DLLEXPORT void LLVMExtraAddDemoteFloat16Pass_fallback(void *PM) UNAVAILABLE
JL_DLLEXPORT void LLVMExtraAddCPUFeaturesPass_fallback(void *PM) UNAVAILABLE

//LLVM C api to the julia JIT
JL_DLLEXPORT void* LLVMExtraJLJITGetLLVMOrcExecutionSession_fallback(void* JIT) UNAVAILABLE
JL_DLLEXPORT void* JLJITGetLLVMOrcExecutionSession_fallback(void* JIT) UNAVAILABLE

JL_DLLEXPORT void* LLVMExtraJLJITGetJuliaOJIT_fallback(void) UNAVAILABLE
JL_DLLEXPORT void* JLJITGetJuliaOJIT_fallback(void) UNAVAILABLE

JL_DLLEXPORT void* LLVMExtraJLJITGetExternalJITDylib_fallback(void* JIT) UNAVAILABLE
JL_DLLEXPORT void* JLJITGetExternalJITDylib_fallback(void* JIT) UNAVAILABLE

JL_DLLEXPORT void* LLVMExtraJLJITAddObjectFile_fallback(void* JIT, void* JD, void* ObjBuffer) UNAVAILABLE
JL_DLLEXPORT void* JLJITAddObjectFile_fallback(void* JIT, void* JD, void* ObjBuffer) UNAVAILABLE

JL_DLLEXPORT void* LLVMExtraJLJITAddLLVMIRModule_fallback(void* JIT, void* JD, void* TSM) UNAVAILABLE
JL_DLLEXPORT void* JLJITAddLLVMIRModule_fallback(void* JIT, void* JD, void* TSM) UNAVAILABLE

JL_DLLEXPORT void* LLVMExtraJLJITLookup_fallback(void* JIT, void* Result, const char *Name) UNAVAILABLE
JL_DLLEXPORT void* JLJITLookup_fallback(void* JIT, void* Result, const char *Name) UNAVAILABLE

JL_DLLEXPORT void* LLVMExtraJLJITMangleAndIntern_fallback(void* JIT, const char *Name) UNAVAILABLE
JL_DLLEXPORT void* JLJITMangleAndIntern_fallback(void* JIT, const char *Name) UNAVAILABLE

JL_DLLEXPORT const char *LLVMExtraJLJITGetTripleString_fallback(void* JIT) UNAVAILABLE
JL_DLLEXPORT const char *JLJITGetTripleString_fallback(void* JIT) UNAVAILABLE

JL_DLLEXPORT const char LLVMExtraJLJITGetGlobalPrefix_fallback(void* JIT) UNAVAILABLE
JL_DLLEXPORT const char JLJITGetGlobalPrefix_fallback(void* JIT) UNAVAILABLE

JL_DLLEXPORT const char *LLVMExtraJLJITGetDataLayoutString_fallback(void* JIT) UNAVAILABLE
JL_DLLEXPORT const char *JLJITGetDataLayoutString_fallback(void* JIT) UNAVAILABLE

JL_DLLEXPORT void* LLVMExtraJLJITGetIRCompileLayer_fallback(void* JIT) UNAVAILABLE
JL_DLLEXPORT void* JLJITGetIRCompileLayer_fallback(void* JIT) UNAVAILABLE
22 changes: 11 additions & 11 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -573,17 +573,17 @@
YY(LLVMExtraAddGCInvariantVerifierPass) \
YY(LLVMExtraAddDemoteFloat16Pass) \
YY(LLVMExtraAddCPUFeaturesPass) \
YY(LLVMExtraJLJITGetLLVMOrcExecutionSession) \
YY(LLVMExtraJLJITGetJuliaOJIT) \
YY(LLVMExtraJLJITGetExternalJITDylib) \
YY(LLVMExtraJLJITAddObjectFile) \
YY(LLVMExtraJLJITAddLLVMIRModule) \
YY(LLVMExtraJLJITLookup) \
YY(LLVMExtraJLJITMangleAndIntern) \
YY(LLVMExtraJLJITGetTripleString) \
YY(LLVMExtraJLJITGetGlobalPrefix) \
YY(LLVMExtraJLJITGetDataLayoutString) \
YY(LLVMExtraJLJITGetIRCompileLayer) \
YY(JLJITGetLLVMOrcExecutionSession) \
YY(JLJITGetJuliaOJIT) \
YY(JLJITGetExternalJITDylib) \
YY(JLJITAddObjectFile) \
YY(JLJITAddLLVMIRModule) \
YY(JLJITLookup) \
YY(JLJITMangleAndIntern) \
YY(JLJITGetTripleString) \
YY(JLJITGetGlobalPrefix) \
YY(JLJITGetDataLayoutString) \
YY(JLJITGetIRCompileLayer) \


// end of file
1 change: 1 addition & 0 deletions src/julia.expmap
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
_Z22jl_coverage_alloc_lineN4llvm9StringRefEi;
_Z22jl_malloc_data_pointerN4llvm9StringRefEi;
LLVMExtra*;
JLJIT*;
llvmGetPassPluginInfo;

/* Make visible so that linker will merge duplicate definitions across DSO boundaries */
Expand Down
22 changes: 11 additions & 11 deletions src/llvm_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,40 +52,40 @@ DEFINE_SIMPLE_CONVERSION_FUNCTIONS(orc::MaterializationResponsibility,
LLVMOrcMaterializationResponsibilityRef)
extern "C" {

JL_DLLEXPORT_CODEGEN JuliaOJITRef LLVMExtraJLJITGetJuliaOJIT_impl(void)
JL_DLLEXPORT_CODEGEN JuliaOJITRef JLJITGetJuliaOJIT_impl(void)
JL_NOTSAFEPOINT
{
return wrap(jl_ExecutionEngine);
}

JL_DLLEXPORT_CODEGEN LLVMOrcExecutionSessionRef
LLVMExtraJLJITGetLLVMOrcExecutionSession_impl(JuliaOJITRef JIT) JL_NOTSAFEPOINT
JLJITGetLLVMOrcExecutionSession_impl(JuliaOJITRef JIT) JL_NOTSAFEPOINT
{
return wrap(&unwrap(JIT)->getExecutionSession());
}

JL_DLLEXPORT_CODEGEN LLVMOrcJITDylibRef
LLVMExtraJLJITGetExternalJITDylib_impl(JuliaOJITRef JIT) JL_NOTSAFEPOINT
JLJITGetExternalJITDylib_impl(JuliaOJITRef JIT) JL_NOTSAFEPOINT
{
return wrap(&unwrap(JIT)->getExternalJITDylib());
}

JL_DLLEXPORT_CODEGEN LLVMErrorRef LLVMExtraJLJITAddObjectFile_impl(
JL_DLLEXPORT_CODEGEN LLVMErrorRef JLJITAddObjectFile_impl(
JuliaOJITRef JIT, LLVMOrcJITDylibRef JD, LLVMMemoryBufferRef ObjBuffer) JL_NOTSAFEPOINT
{
return wrap(unwrap(JIT)->addObjectFile(
*unwrap(JD), std::unique_ptr<MemoryBuffer>(unwrap(ObjBuffer))));
}

JL_DLLEXPORT_CODEGEN LLVMErrorRef LLVMExtraJLJITAddLLVMIRModule_impl(
JL_DLLEXPORT_CODEGEN LLVMErrorRef JLJITAddLLVMIRModule_impl(
JuliaOJITRef JIT, LLVMOrcJITDylibRef JD, LLVMOrcThreadSafeModuleRef TSM) JL_NOTSAFEPOINT
{
std::unique_ptr<orc::ThreadSafeModule> TmpTSM(unwrap(TSM));
return wrap(unwrap(JIT)->addExternalModule(*unwrap(JD), std::move(*TmpTSM)));
}

JL_DLLEXPORT_CODEGEN LLVMErrorRef
LLVMExtraJLJITLookup_impl(JuliaOJITRef JIT, LLVMOrcExecutorAddress *Result,
JLJITLookup_impl(JuliaOJITRef JIT, LLVMOrcExecutorAddress *Result,
const char *Name, int ExternalJDOnly) JL_NOTSAFEPOINT
{
auto Sym = unwrap(JIT)->findExternalJDSymbol(Name, ExternalJDOnly);
Expand All @@ -101,32 +101,32 @@ LLVMExtraJLJITLookup_impl(JuliaOJITRef JIT, LLVMOrcExecutorAddress *Result,
}

JL_DLLEXPORT_CODEGEN LLVMOrcSymbolStringPoolEntryRef
LLVMExtraJLJITMangleAndIntern_impl(JuliaOJITRef JIT,
JLJITMangleAndIntern_impl(JuliaOJITRef JIT,
const char *Name) JL_NOTSAFEPOINT
{
return wrap(orc::OrcV2CAPIHelper::moveFromSymbolStringPtr(unwrap(JIT)->mangle(Name)));
}

JL_DLLEXPORT_CODEGEN const char *
LLVMExtraJLJITGetTripleString_impl(JuliaOJITRef JIT)
JLJITGetTripleString_impl(JuliaOJITRef JIT)
{
return unwrap(JIT)->getTargetTriple().str().c_str();
}

JL_DLLEXPORT_CODEGEN const char
LLVMExtraJLJITGetGlobalPrefix_impl(JuliaOJITRef JIT)
JLJITGetGlobalPrefix_impl(JuliaOJITRef JIT)
{
return unwrap(JIT)->getDataLayout().getGlobalPrefix();
}

JL_DLLEXPORT_CODEGEN const char *
LLVMExtraJLJITGetDataLayoutString_impl(JuliaOJITRef JIT)
JLJITGetDataLayoutString_impl(JuliaOJITRef JIT)
{
return unwrap(JIT)->getDataLayout().getStringRepresentation().c_str();
}

JL_DLLEXPORT_CODEGEN LLVMOrcIRCompileLayerRef
LLVMExtraJLJITGetIRCompileLayer_impl(JuliaOJITRef JIT)
JLJITGetIRCompileLayer_impl(JuliaOJITRef JIT)
{
return wrap(&unwrap(JIT)->getIRCompileLayer());
}
Expand Down
13 changes: 13 additions & 0 deletions test/llvmcall2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,16 @@ let err = ErrorException("llvmcall only supports intrinsic calls")
@test_throws err (@eval ccall("llvm.floor.f64", llvmcall, Float64, (Float64, Float64...,), 0.0)) === 0.0
@test_throws err (@eval ccall("llvm.floor", llvmcall, Float64, (Float64, Float64...,), 0.0)) === 0.0
end

@testset "JLJIT API" begin
function JLJITGetJuliaOJIT()
ccall(:JLJITGetJuliaOJIT, Ptr{Cvoid}, ())
end
function JLJITGetTripleString(JIT)
ccall(:JLJITGetTripleString, Cstring, (Ptr{Cvoid},), JIT)
end
jit = JLJITGetJuliaOJIT()
str = JLJITGetTripleString(jit)
jl_str = unsafe_string(str)
@test length(jl_str) > 4
end

0 comments on commit fe67d67

Please sign in to comment.