xref: /libCEED/backends/sycl/ocloc_api.h (revision bd882c8a454763a096666645dc9a6229d5263694)
1*bd882c8aSJames Wright //===------- ocloc_api.h --------------------------------------------------===//
2*bd882c8aSJames Wright //
3*bd882c8aSJames Wright // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*bd882c8aSJames Wright // See https://llvm.org/LICENSE.txt for license information.
5*bd882c8aSJames Wright // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*bd882c8aSJames Wright //
7*bd882c8aSJames Wright //===----------------------------------------------------------------------===//
8*bd882c8aSJames Wright 
9*bd882c8aSJames Wright // This file is copied from
10*bd882c8aSJames Wright // https://github.com/intel/compute-runtime/blob/master/shared/offline_compiler/source/ocloc_api.h
11*bd882c8aSJames Wright 
12*bd882c8aSJames Wright #include <cstdint>
13*bd882c8aSJames Wright 
14*bd882c8aSJames Wright #ifndef OCLOC_MAKE_VERSION
15*bd882c8aSJames Wright /// Generates ocloc API versions
16*bd882c8aSJames Wright #define OCLOC_MAKE_VERSION(_major, _minor) ((_major << 16) | (_minor & 0x0000ffff))
17*bd882c8aSJames Wright #endif  // OCLOC_MAKE_VERSION
18*bd882c8aSJames Wright 
19*bd882c8aSJames Wright typedef enum _ocloc_version_t {
20*bd882c8aSJames Wright   OCLOC_VERSION_1_0          = OCLOC_MAKE_VERSION(1, 0),  ///< version 1.0
21*bd882c8aSJames Wright   OCLOC_VERSION_CURRENT      = OCLOC_MAKE_VERSION(1, 0),  ///< latest known version
22*bd882c8aSJames Wright   OCLOC_VERSION_FORCE_UINT32 = 0x7fffffff
23*bd882c8aSJames Wright } ocloc_version_t;
24*bd882c8aSJames Wright 
25*bd882c8aSJames Wright #ifdef _WIN32
26*bd882c8aSJames Wright #define SIGNATURE __declspec(dllexport) int __cdecl
27*bd882c8aSJames Wright #else
28*bd882c8aSJames Wright #define SIGNATURE int
29*bd882c8aSJames Wright #endif
30*bd882c8aSJames Wright 
31*bd882c8aSJames Wright extern "C" {
32*bd882c8aSJames Wright /// Invokes ocloc API using C interface. Supported commands match
33*bd882c8aSJames Wright /// the functionality of ocloc executable (check ocloc's "help"
34*bd882c8aSJames Wright /// for reference : shared/offline_compiler/source/ocloc_api.cpp)
35*bd882c8aSJames Wright /// at https://github.com/intel/compute-runtime.
36*bd882c8aSJames Wright ///
37*bd882c8aSJames Wright /// NumArgs and argv params represent the command line.
38*bd882c8aSJames Wright /// Remaining params represent I/O.
39*bd882c8aSJames Wright /// Output params should be freed using oclocFreeOutput() when
40*bd882c8aSJames Wright /// no longer needed.
41*bd882c8aSJames Wright /// List and names of outputs match outputs of ocloc executable.
42*bd882c8aSJames Wright ///
43*bd882c8aSJames Wright /// \param NumArgs is the number of arguments to pass to ocloc.
44*bd882c8aSJames Wright ///
45*bd882c8aSJames Wright /// \param Argv is an array of arguments to be passed to ocloc.
46*bd882c8aSJames Wright ///
47*bd882c8aSJames Wright /// \param NumSources is the number of in-memory representations
48*bd882c8aSJames Wright /// of source files to be passed to ocloc.
49*bd882c8aSJames Wright ///
50*bd882c8aSJames Wright /// \param DataSources is an array of in-memory representations
51*bd882c8aSJames Wright /// of source files to be passed to ocloc.
52*bd882c8aSJames Wright ///
53*bd882c8aSJames Wright /// \param LenSources is an array of sizes of in-memory representations
54*bd882c8aSJames Wright /// of source files passed to ocloc as DataSources.
55*bd882c8aSJames Wright ///
56*bd882c8aSJames Wright /// \param NameSources is an array of names of in-memory representations
57*bd882c8aSJames Wright /// of source files passed to ocloc as DataSources.
58*bd882c8aSJames Wright ///
59*bd882c8aSJames Wright /// \param NumInputHeaders is the number of in-memory representations
60*bd882c8aSJames Wright /// of header files to be passed to ocloc.
61*bd882c8aSJames Wright ///
62*bd882c8aSJames Wright /// \param DataInputHeaders is an array of in-memory representations
63*bd882c8aSJames Wright /// of header files to be passed to ocloc.
64*bd882c8aSJames Wright ///
65*bd882c8aSJames Wright /// \param LenInputHeaders is an array of sizes of in-memory representations
66*bd882c8aSJames Wright /// of header files passed to ocloc as DataInputHeaders.
67*bd882c8aSJames Wright ///
68*bd882c8aSJames Wright /// \param NameInputHeaders is an array of names of in-memory representations
69*bd882c8aSJames Wright /// of header files passed to ocloc as DataInputHeaders.
70*bd882c8aSJames Wright ///
71*bd882c8aSJames Wright /// \param NumOutputs returns the number of outputs.
72*bd882c8aSJames Wright ///
73*bd882c8aSJames Wright /// \param DataOutputs returns an array of in-memory representations
74*bd882c8aSJames Wright /// of output files.
75*bd882c8aSJames Wright ///
76*bd882c8aSJames Wright /// \param LenOutputs returns an array of sizes of in-memory representations
77*bd882c8aSJames Wright /// of output files.
78*bd882c8aSJames Wright ///
79*bd882c8aSJames Wright /// \param NameOutputs returns an array of names of in-memory representations
80*bd882c8aSJames Wright /// of output files. Special name stdout.log describes output that contains
81*bd882c8aSJames Wright /// messages generated by ocloc (e.g. compiler errors/warnings).
82*bd882c8aSJames Wright ///
83*bd882c8aSJames Wright /// \returns 0 on succes. Returns non-0 in case of failure.
84*bd882c8aSJames Wright SIGNATURE oclocInvoke(uint32_t NumArgs, const char *Argv[], uint32_t NumSources, const uint8_t **DataSources, const uint64_t *LenSources,
85*bd882c8aSJames Wright                       const char **NameSources, uint32_t NumInputHeaders, const uint8_t **DataInputHeaders, const uint64_t *LenInputHeaders,
86*bd882c8aSJames Wright                       const char **NameInputHeaders, uint32_t *NumOutputs, uint8_t ***DataOutputs, uint64_t **LenOutputs, char ***NameOutputs);
87*bd882c8aSJames Wright 
88*bd882c8aSJames Wright /// Frees results of oclocInvoke
89*bd882c8aSJames Wright ///
90*bd882c8aSJames Wright /// \param NumOutputs is number of outputs as returned by oclocInvoke().
91*bd882c8aSJames Wright ///
92*bd882c8aSJames Wright /// \param DataOutputs is array of outputs as returned by oclocInvoke().
93*bd882c8aSJames Wright ///
94*bd882c8aSJames Wright /// \param LenOutputs is array of sizes of outputs as returned by oclocInvoke().
95*bd882c8aSJames Wright ///
96*bd882c8aSJames Wright /// \param NameOutputs is array of names of outputs as returned by oclocInvoke()
97*bd882c8aSJames Wright ///
98*bd882c8aSJames Wright /// \returns 0 on succes. Returns non-0 in case of failure.
99*bd882c8aSJames Wright SIGNATURE oclocFreeOutput(uint32_t *NumOutputs, uint8_t ***DataOutputs, uint64_t **LenOutputs, char ***NameOutputs);
100*bd882c8aSJames Wright 
101*bd882c8aSJames Wright /// Returns the current version of ocloc.
102*bd882c8aSJames Wright SIGNATURE oclocVersion();
103*bd882c8aSJames Wright }
104