Path: blob/21.2-virgl/src/microsoft/compiler/dxil_function.h
4564 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 DXIL_FUNCTION_H24#define DXIL_FUNCTION_H2526#define DXIL_FUNC_PARAM_INT64 'l'27#define DXIL_FUNC_PARAM_INT32 'i'28#define DXIL_FUNC_PARAM_INT16 'h'29#define DXIL_FUNC_PARAM_INT8 'c'30#define DXIL_FUNC_PARAM_BOOL 'b'3132#define DXIL_FUNC_PARAM_FLOAT64 'g'33#define DXIL_FUNC_PARAM_FLOAT32 'f'34#define DXIL_FUNC_PARAM_FLOAT16 'e'35#define DXIL_FUNC_PARAM_HANDLE '@'36#define DXIL_FUNC_PARAM_POINTER '*'37#define DXIL_FUNC_PARAM_VOID 'v'38#define DXIL_FUNC_PARAM_FROM_OVERLOAD 'O'39#define DXIL_FUNC_PARAM_RESRET 'R'40#define DXIL_FUNC_PARAM_CBUF_RET 'B'41#define DXIL_FUNC_PARAM_DIM 'D'42#define DXIL_FUNC_PARAM_SPLIT_DOUBLE 'G'4344#include "dxil_module.h"45#include "util/rb_tree.h"4647const char *dxil_overload_suffix( enum overload_type overload);4849const struct dxil_type *50dxil_get_overload_type(struct dxil_module *mod, enum overload_type overload);5152/* These functions implement a generic method for declaring functions53* The input parameters types are given as a string using the characters54* given above as identifyer for the types. Only scalars and pointers to55* scalars are implemented at this point.56*57* Examples:58*59* Call: dxil_alloc_func(mod, "storeData.f32", "v", "icf");60* Result function: void storeData.f32(int32, int8, float32)61*62* Call: dxil_alloc_func(mod, "storeData.f32", "e", "*icf");63* Result function: float16 storeData.f32(int32 *, int8, float32)64*65* Call: dxil_alloc_func(mod, "storeData.f32", "*h", "b*f");66* Result function: float16 storeData.f32(bool *, float32 *)67*68*/6970const struct dxil_func *71dxil_alloc_func(struct dxil_module *mod, const char *name, enum overload_type overload,72const char *retval_type_descr, const char *param_descr, enum dxil_attr_kind attr);7374/* For specifically constructed return types one can also create the return type75* seperately and pass it as paramaer76*/77const struct dxil_func *78dxil_alloc_func_with_rettype(struct dxil_module *mod, const char *name, enum overload_type overload,79const struct dxil_type *retval_type, const char *param_descr,80enum dxil_attr_kind attr);8182/* This call should be the usual entry point to allocate a new function type.83* 'name' must either be in the list of predefined functions, or a function84* with 'name' and 'overload' must already be allocated by using one of the above85* function calls. The allocated functions are searched for by using an rb_tree, so86* the search complexity should be O(log(n)).87*/88const struct dxil_func *89dxil_get_function(struct dxil_module *mod, const char *name,90enum overload_type overload);9192#endif // DXIL_FUNCTION_H939495