//===------- ocloc_api.h --------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // This file is copied from // https://github.com/intel/compute-runtime/blob/master/shared/offline_compiler/source/ocloc_api.h #include #ifndef OCLOC_MAKE_VERSION /// Generates ocloc API versions #define OCLOC_MAKE_VERSION(_major, _minor) ((_major << 16) | (_minor & 0x0000ffff)) #endif // OCLOC_MAKE_VERSION typedef enum _ocloc_version_t { OCLOC_VERSION_1_0 = OCLOC_MAKE_VERSION(1, 0), ///< version 1.0 OCLOC_VERSION_CURRENT = OCLOC_MAKE_VERSION(1, 0), ///< latest known version OCLOC_VERSION_FORCE_UINT32 = 0x7fffffff } ocloc_version_t; #ifdef _WIN32 #define SIGNATURE __declspec(dllexport) int __cdecl #else #define SIGNATURE int #endif extern "C" { /// Invokes ocloc API using C interface. Supported commands match /// the functionality of ocloc executable (check ocloc's "help" /// for reference : shared/offline_compiler/source/ocloc_api.cpp) /// at https://github.com/intel/compute-runtime. /// /// NumArgs and argv params represent the command line. /// Remaining params represent I/O. /// Output params should be freed using oclocFreeOutput() when /// no longer needed. /// List and names of outputs match outputs of ocloc executable. /// /// \param NumArgs is the number of arguments to pass to ocloc. /// /// \param Argv is an array of arguments to be passed to ocloc. /// /// \param NumSources is the number of in-memory representations /// of source files to be passed to ocloc. /// /// \param DataSources is an array of in-memory representations /// of source files to be passed to ocloc. /// /// \param LenSources is an array of sizes of in-memory representations /// of source files passed to ocloc as DataSources. /// /// \param NameSources is an array of names of in-memory representations /// of source files passed to ocloc as DataSources. /// /// \param NumInputHeaders is the number of in-memory representations /// of header files to be passed to ocloc. /// /// \param DataInputHeaders is an array of in-memory representations /// of header files to be passed to ocloc. /// /// \param LenInputHeaders is an array of sizes of in-memory representations /// of header files passed to ocloc as DataInputHeaders. /// /// \param NameInputHeaders is an array of names of in-memory representations /// of header files passed to ocloc as DataInputHeaders. /// /// \param NumOutputs returns the number of outputs. /// /// \param DataOutputs returns an array of in-memory representations /// of output files. /// /// \param LenOutputs returns an array of sizes of in-memory representations /// of output files. /// /// \param NameOutputs returns an array of names of in-memory representations /// of output files. Special name stdout.log describes output that contains /// messages generated by ocloc (e.g. compiler errors/warnings). /// /// \returns 0 on succes. Returns non-0 in case of failure. SIGNATURE oclocInvoke(uint32_t NumArgs, const char *Argv[], uint32_t NumSources, const uint8_t **DataSources, const uint64_t *LenSources, const char **NameSources, uint32_t NumInputHeaders, const uint8_t **DataInputHeaders, const uint64_t *LenInputHeaders, const char **NameInputHeaders, uint32_t *NumOutputs, uint8_t ***DataOutputs, uint64_t **LenOutputs, char ***NameOutputs); /// Frees results of oclocInvoke /// /// \param NumOutputs is number of outputs as returned by oclocInvoke(). /// /// \param DataOutputs is array of outputs as returned by oclocInvoke(). /// /// \param LenOutputs is array of sizes of outputs as returned by oclocInvoke(). /// /// \param NameOutputs is array of names of outputs as returned by oclocInvoke() /// /// \returns 0 on succes. Returns non-0 in case of failure. SIGNATURE oclocFreeOutput(uint32_t *NumOutputs, uint8_t ***DataOutputs, uint64_t **LenOutputs, char ***NameOutputs); /// Returns the current version of ocloc. SIGNATURE oclocVersion(); }