1*61046927SAndroid Build Coastguard Worker /* 2*61046927SAndroid Build Coastguard Worker * Copyright © Microsoft Corporation 3*61046927SAndroid Build Coastguard Worker * 4*61046927SAndroid Build Coastguard Worker * Permission is hereby granted, free of charge, to any person obtaining a 5*61046927SAndroid Build Coastguard Worker * copy of this software and associated documentation files (the "Software"), 6*61046927SAndroid Build Coastguard Worker * to deal in the Software without restriction, including without limitation 7*61046927SAndroid Build Coastguard Worker * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8*61046927SAndroid Build Coastguard Worker * and/or sell copies of the Software, and to permit persons to whom the 9*61046927SAndroid Build Coastguard Worker * Software is furnished to do so, subject to the following conditions: 10*61046927SAndroid Build Coastguard Worker * 11*61046927SAndroid Build Coastguard Worker * The above copyright notice and this permission notice (including the next 12*61046927SAndroid Build Coastguard Worker * paragraph) shall be included in all copies or substantial portions of the 13*61046927SAndroid Build Coastguard Worker * Software. 14*61046927SAndroid Build Coastguard Worker * 15*61046927SAndroid Build Coastguard Worker * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16*61046927SAndroid Build Coastguard Worker * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17*61046927SAndroid Build Coastguard Worker * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18*61046927SAndroid Build Coastguard Worker * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19*61046927SAndroid Build Coastguard Worker * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20*61046927SAndroid Build Coastguard Worker * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21*61046927SAndroid Build Coastguard Worker * IN THE SOFTWARE. 22*61046927SAndroid Build Coastguard Worker */ 23*61046927SAndroid Build Coastguard Worker 24*61046927SAndroid Build Coastguard Worker #ifndef DXIL_FUNCTION_H 25*61046927SAndroid Build Coastguard Worker #define DXIL_FUNCTION_H 26*61046927SAndroid Build Coastguard Worker 27*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_INT64 'l' 28*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_INT32 'i' 29*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_INT16 'h' 30*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_INT8 'c' 31*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_BOOL 'b' 32*61046927SAndroid Build Coastguard Worker 33*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_FLOAT64 'g' 34*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_FLOAT32 'f' 35*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_FLOAT16 'e' 36*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_HANDLE '@' 37*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_POINTER '*' 38*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_VOID 'v' 39*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_FROM_OVERLOAD 'O' 40*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_RESRET 'R' 41*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_CBUF_RET 'B' 42*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_DIM 'D' 43*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_SPLIT_DOUBLE 'G' 44*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_SAMPLE_POS 'S' 45*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_RES_BIND '#' 46*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_RES_PROPS 'P' 47*61046927SAndroid Build Coastguard Worker #define DXIL_FUNC_PARAM_FOURI32 'F' 48*61046927SAndroid Build Coastguard Worker 49*61046927SAndroid Build Coastguard Worker #include "dxil_module.h" 50*61046927SAndroid Build Coastguard Worker #include "util/rb_tree.h" 51*61046927SAndroid Build Coastguard Worker 52*61046927SAndroid Build Coastguard Worker const char *dxil_overload_suffix( enum overload_type overload); 53*61046927SAndroid Build Coastguard Worker 54*61046927SAndroid Build Coastguard Worker const struct dxil_type * 55*61046927SAndroid Build Coastguard Worker dxil_get_overload_type(struct dxil_module *mod, enum overload_type overload); 56*61046927SAndroid Build Coastguard Worker 57*61046927SAndroid Build Coastguard Worker /* These functions implement a generic method for declaring functions 58*61046927SAndroid Build Coastguard Worker * The input parameters types are given as a string using the characters 59*61046927SAndroid Build Coastguard Worker * given above as identifyer for the types. Only scalars and pointers to 60*61046927SAndroid Build Coastguard Worker * scalars are implemented at this point. 61*61046927SAndroid Build Coastguard Worker * 62*61046927SAndroid Build Coastguard Worker * Examples: 63*61046927SAndroid Build Coastguard Worker * 64*61046927SAndroid Build Coastguard Worker * Call: dxil_alloc_func(mod, "storeData.f32", "v", "icf"); 65*61046927SAndroid Build Coastguard Worker * Result function: void storeData.f32(int32, int8, float32) 66*61046927SAndroid Build Coastguard Worker * 67*61046927SAndroid Build Coastguard Worker * Call: dxil_alloc_func(mod, "storeData.f32", "e", "*icf"); 68*61046927SAndroid Build Coastguard Worker * Result function: float16 storeData.f32(int32 *, int8, float32) 69*61046927SAndroid Build Coastguard Worker * 70*61046927SAndroid Build Coastguard Worker * Call: dxil_alloc_func(mod, "storeData.f32", "*h", "b*f"); 71*61046927SAndroid Build Coastguard Worker * Result function: float16 storeData.f32(bool *, float32 *) 72*61046927SAndroid Build Coastguard Worker * 73*61046927SAndroid Build Coastguard Worker */ 74*61046927SAndroid Build Coastguard Worker 75*61046927SAndroid Build Coastguard Worker const struct dxil_func * 76*61046927SAndroid Build Coastguard Worker dxil_alloc_func(struct dxil_module *mod, const char *name, enum overload_type overload, 77*61046927SAndroid Build Coastguard Worker const char *retval_type_descr, const char *param_descr, enum dxil_attr_kind attr); 78*61046927SAndroid Build Coastguard Worker 79*61046927SAndroid Build Coastguard Worker /* For specifically constructed return types one can also create the return type 80*61046927SAndroid Build Coastguard Worker * seperately and pass it as paramaer 81*61046927SAndroid Build Coastguard Worker */ 82*61046927SAndroid Build Coastguard Worker const struct dxil_func * 83*61046927SAndroid Build Coastguard Worker dxil_alloc_func_with_rettype(struct dxil_module *mod, const char *name, enum overload_type overload, 84*61046927SAndroid Build Coastguard Worker const struct dxil_type *retval_type, const char *param_descr, 85*61046927SAndroid Build Coastguard Worker enum dxil_attr_kind attr); 86*61046927SAndroid Build Coastguard Worker 87*61046927SAndroid Build Coastguard Worker /* This call should be the usual entry point to allocate a new function type. 88*61046927SAndroid Build Coastguard Worker * 'name' must either be in the list of predefined functions, or a function 89*61046927SAndroid Build Coastguard Worker * with 'name' and 'overload' must already be allocated by using one of the above 90*61046927SAndroid Build Coastguard Worker * function calls. The allocated functions are searched for by using an rb_tree, so 91*61046927SAndroid Build Coastguard Worker * the search complexity should be O(log(n)). 92*61046927SAndroid Build Coastguard Worker */ 93*61046927SAndroid Build Coastguard Worker const struct dxil_func * 94*61046927SAndroid Build Coastguard Worker dxil_get_function(struct dxil_module *mod, const char *name, 95*61046927SAndroid Build Coastguard Worker enum overload_type overload); 96*61046927SAndroid Build Coastguard Worker 97*61046927SAndroid Build Coastguard Worker #endif // DXIL_FUNCTION_H 98