Path: blob/21.2-virgl/src/microsoft/clc/clc_helpers.h
4560 views
/*1* Copyright © Microsoft Corporation2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef CLC_TO_NIR_H24#define CLC_TO_NIR_H2526#ifdef __cplusplus27extern "C" {28#endif2930#include "nir_types.h"3132#include "clc_compiler.h"33#include "util/u_string.h"3435#include <assert.h>36#include <stddef.h>37#include <stdio.h>38#include <stdint.h>3940const struct clc_kernel_info *41clc_spirv_get_kernels_info(const struct spirv_binary *spvbin,42unsigned *num_kernels);4344void45clc_free_kernels_info(const struct clc_kernel_info *kernels,46unsigned num_kernels);4748int49clc_to_spirv(const struct clc_compile_args *args,50struct spirv_binary *spvbin,51const struct clc_logger *logger);5253int54clc_link_spirv_binaries(const struct clc_linker_args *args,55struct spirv_binary *dst_bin,56const struct clc_logger *logger);5758void59clc_dump_spirv(const struct spirv_binary *spvbin, FILE *f);6061void62clc_free_spirv_binary(struct spirv_binary *spvbin);6364#define clc_log(logger, level, fmt, ...) do { \65if (!logger || !logger->level) break; \66char *_msg = NULL; \67asprintf(&_msg, fmt, ##__VA_ARGS__); \68assert(_msg); \69logger->level(logger->priv, _msg); \70free(_msg); \71} while (0)7273#define clc_error(logger, fmt, ...) clc_log(logger, error, fmt, ##__VA_ARGS__)74#define clc_warning(logger, fmt, ...) clc_log(logger, warning, fmt, ##__VA_ARGS__)7576#ifdef __cplusplus77}78#endif7980#endif818283