diff --git a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp index 537eac66f4..e7329678a6 100644 --- a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp +++ b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp @@ -2899,6 +2899,43 @@ void myLogFunc(const char * msg, size_t size) printf("%s\n", msg); } +#define CONDITIONAL_ASSIGN(A, B) A = (A) ? (A) : (B) +acl_error ACL_API_ENTRY +if_aclSetupLoaderObject(aclCompiler *cl) { + /* setup the loader objects here now that we have parsed the + * options and know the target. */ + CONDITIONAL_ASSIGN(cl->cgAPI.init, &CodegenInit); + CONDITIONAL_ASSIGN(cl->cgAPI.fini, &CodegenFini); + CONDITIONAL_ASSIGN(cl->cgAPI.codegen, &CodegenPhase); + CONDITIONAL_ASSIGN(cl->linkAPI.init, &LinkInit); + CONDITIONAL_ASSIGN(cl->linkAPI.fini, &LinkFini); + CONDITIONAL_ASSIGN(cl->linkAPI.link, &OCLLinkPhase); + CONDITIONAL_ASSIGN(cl->linkAPI.toLLVMIR, &OCLLinkToLLVMIR); + CONDITIONAL_ASSIGN(cl->linkAPI.toSPIR, &OCLLinkToSPIR); + + CONDITIONAL_ASSIGN(cl->feAPI.init, &OCLInit); + CONDITIONAL_ASSIGN(cl->feAPI.fini, &OCLFini); +#if !defined(LEGACY_COMPLIB) + CONDITIONAL_ASSIGN(cl->feAPI.toIR, &OCLFEToSPIR); +#else + CONDITIONAL_ASSIGN(cl->feAPI.toIR, &OCLFEToLLVMIR); +#endif + + CONDITIONAL_ASSIGN(cl->feAPI.toModule, &OCLFEToModule); + CONDITIONAL_ASSIGN(cl->feAPI.toISA, &OCLFEToISA); + CONDITIONAL_ASSIGN(cl->optAPI.init, &OptInit); + CONDITIONAL_ASSIGN(cl->optAPI.fini, &OptFini); + CONDITIONAL_ASSIGN(cl->optAPI.optimize, &OptOptimize); + CONDITIONAL_ASSIGN(cl->beAPI.init, &BEInit); + CONDITIONAL_ASSIGN(cl->beAPI.fini, &BEFini); + CONDITIONAL_ASSIGN(cl->beAPI.finalize, &BEAsmPhase); + CONDITIONAL_ASSIGN(cl->beAPI.assemble, &BEAssemble); + CONDITIONAL_ASSIGN(cl->beAPI.disassemble, &BEDisassemble); + return ACL_SUCCESS; +} + +#undef CONDITIONAL_ASSIGN + extern "C" { bool aclRenderscriptCompile( char * srcFile, @@ -2972,4 +3009,5 @@ bool aclRenderscriptCompile( *outBuf = buffer; return true; } + } diff --git a/rocclr/compiler/lib/backends/common/v0_8/if_acl.h b/rocclr/compiler/lib/backends/common/v0_8/if_acl.h index 135e3c1e73..7250f550d8 100644 --- a/rocclr/compiler/lib/backends/common/v0_8/if_acl.h +++ b/rocclr/compiler/lib/backends/common/v0_8/if_acl.h @@ -126,4 +126,7 @@ if_aclDbgRemoveArgument(aclCompiler *cl, const char* kernel, const char* name) ACL_API_0_8; +acl_error ACL_API_ENTRY +if_aclSetupLoaderObject(aclCompiler *cl) ACL_API_0_8; + #endif // _IF_ACL_0_8_H_ diff --git a/rocclr/compiler/lib/include/v0_8/aclFunctors.h b/rocclr/compiler/lib/include/v0_8/aclFunctors.h index 43a19a91a5..2aeba9dc63 100644 --- a/rocclr/compiler/lib/include/v0_8/aclFunctors.h +++ b/rocclr/compiler/lib/include/v0_8/aclFunctors.h @@ -173,6 +173,9 @@ typedef acl_error const void *isa_code, size_t isa_size) ACL_API_0_8; +typedef acl_error +(ACL_API_ENTRY *SetupLoaderObject_0_8)(aclCompiler *cl) ACL_API_0_8; + typedef void* (*AllocFunc_0_8)(size_t size) ACL_API_0_8; diff --git a/rocclr/compiler/lib/include/v0_8/aclStructs.h b/rocclr/compiler/lib/include/v0_8/aclStructs.h index eea1797f30..db2da24753 100644 --- a/rocclr/compiler/lib/include/v0_8/aclStructs.h +++ b/rocclr/compiler/lib/include/v0_8/aclStructs.h @@ -209,6 +209,7 @@ typedef struct _acl_cl_loader_rec_0_8 { QueryInfo getInfo; AddDbgArg addDbg; RemoveDbgArg removeDbg; + SetupLoaderObject setupLoaderObject; } aclCLLoader_0_8; //! Structure that holds the required functions diff --git a/rocclr/compiler/lib/include/v0_8/aclTypes.h b/rocclr/compiler/lib/include/v0_8/aclTypes.h index cba640591b..0a0061e9ff 100644 --- a/rocclr/compiler/lib/include/v0_8/aclTypes.h +++ b/rocclr/compiler/lib/include/v0_8/aclTypes.h @@ -66,6 +66,7 @@ typedef Compile_0_8 Compile; typedef Link_0_8 Link; typedef AddDbgArg_0_8 AddDbgArg; typedef RemoveDbgArg_0_8 RemoveDbgArg; +typedef SetupLoaderObject_0_8 SetupLoaderObject; typedef CompLog_0_8 CompLog; typedef RetrieveType_0_8 RetrieveType; typedef SetType_0_8 SetType;