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