2020-11-06 17:09:30 +01:00
|
|
|
|
/*
|
|
|
|
|
* Copyright © Microsoft Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-02-18 21:19:24 -06:00
|
|
|
|
#ifndef MESA_CLC_HELPERS_H
|
|
|
|
|
#define MESA_CLC_HELPERS_H
|
2020-11-06 17:09:30 +01:00
|
|
|
|
|
|
|
|
|
#include "nir_types.h"
|
|
|
|
|
|
2021-02-18 21:19:24 -06:00
|
|
|
|
#include "clc.h"
|
2020-11-06 17:09:30 +01:00
|
|
|
|
#include "util/u_string.h"
|
|
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2021-02-18 21:19:24 -06:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-10-13 11:18:37 +10:00
|
|
|
|
void
|
|
|
|
|
clc_initialize_llvm(void);
|
|
|
|
|
|
2021-04-19 06:54:13 -07:00
|
|
|
|
bool
|
|
|
|
|
clc_spirv_get_kernels_info(const struct clc_binary *spvbin,
|
|
|
|
|
const struct clc_kernel_info **kernels,
|
|
|
|
|
unsigned *num_kernels,
|
2021-04-19 07:09:58 -07:00
|
|
|
|
const struct clc_parsed_spec_constant **spec_constants,
|
|
|
|
|
unsigned *num_spec_constants,
|
2021-04-19 06:54:13 -07:00
|
|
|
|
const struct clc_logger *logger);
|
2020-11-06 17:09:30 +01:00
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
clc_free_kernels_info(const struct clc_kernel_info *kernels,
|
|
|
|
|
unsigned num_kernels);
|
|
|
|
|
|
2021-04-19 06:58:56 -07:00
|
|
|
|
int
|
|
|
|
|
clc_c_to_spir(const struct clc_compile_args *args,
|
|
|
|
|
const struct clc_logger *logger,
|
|
|
|
|
struct clc_binary *out_spir);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
clc_spir_to_spirv(const struct clc_binary *in_spir,
|
|
|
|
|
const struct clc_logger *logger,
|
|
|
|
|
struct clc_binary *out_spirv);
|
|
|
|
|
|
2020-11-06 17:09:30 +01:00
|
|
|
|
int
|
2021-04-19 06:54:13 -07:00
|
|
|
|
clc_c_to_spirv(const struct clc_compile_args *args,
|
|
|
|
|
const struct clc_logger *logger,
|
|
|
|
|
struct clc_binary *out_spirv);
|
2020-11-06 17:09:30 +01:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
clc_link_spirv_binaries(const struct clc_linker_args *args,
|
2021-04-19 06:54:13 -07:00
|
|
|
|
const struct clc_logger *logger,
|
|
|
|
|
struct clc_binary *out_spirv);
|
2020-11-06 17:09:30 +01:00
|
|
|
|
|
2021-04-19 07:14:24 -07:00
|
|
|
|
int
|
|
|
|
|
clc_spirv_specialize(const struct clc_binary *in_spirv,
|
|
|
|
|
const struct clc_parsed_spirv *parsed_data,
|
|
|
|
|
const struct clc_spirv_specialization_consts *consts,
|
|
|
|
|
struct clc_binary *out_spirv);
|
|
|
|
|
|
2020-11-06 17:09:30 +01:00
|
|
|
|
void
|
2021-04-19 06:54:13 -07:00
|
|
|
|
clc_dump_spirv(const struct clc_binary *spvbin, FILE *f);
|
2020-11-06 17:09:30 +01:00
|
|
|
|
|
2021-04-19 06:58:56 -07:00
|
|
|
|
void
|
|
|
|
|
clc_free_spir_binary(struct clc_binary *spir);
|
|
|
|
|
|
2020-11-06 17:09:30 +01:00
|
|
|
|
void
|
2021-04-19 06:54:13 -07:00
|
|
|
|
clc_free_spirv_binary(struct clc_binary *spvbin);
|
2020-11-06 17:09:30 +01:00
|
|
|
|
|
|
|
|
|
#define clc_log(logger, level, fmt, ...) do { \
|
|
|
|
|
if (!logger || !logger->level) break; \
|
2021-04-09 14:58:19 +03:00
|
|
|
|
char *_msg = NULL; \
|
|
|
|
|
asprintf(&_msg, fmt, ##__VA_ARGS__); \
|
|
|
|
|
assert(_msg); \
|
|
|
|
|
logger->level(logger->priv, _msg); \
|
|
|
|
|
free(_msg); \
|
2020-11-06 17:09:30 +01:00
|
|
|
|
} while (0)
|
|
|
|
|
|
2021-01-28 08:37:12 -08:00
|
|
|
|
#define clc_error(logger, fmt, ...) clc_log(logger, error, fmt, ##__VA_ARGS__)
|
|
|
|
|
#define clc_warning(logger, fmt, ...) clc_log(logger, warning, fmt, ##__VA_ARGS__)
|
2020-11-06 17:09:30 +01:00
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-02-18 21:19:24 -06:00
|
|
|
|
#endif /* MESA_CLC_HELPERS_H */
|