17ec681f3Smrg/* 27ec681f3Smrg * Copyright © Microsoft Corporation 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 217ec681f3Smrg * IN THE SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef DXIL_FUNCTION_H 257ec681f3Smrg#define DXIL_FUNCTION_H 267ec681f3Smrg 277ec681f3Smrg#define DXIL_FUNC_PARAM_INT64 'l' 287ec681f3Smrg#define DXIL_FUNC_PARAM_INT32 'i' 297ec681f3Smrg#define DXIL_FUNC_PARAM_INT16 'h' 307ec681f3Smrg#define DXIL_FUNC_PARAM_INT8 'c' 317ec681f3Smrg#define DXIL_FUNC_PARAM_BOOL 'b' 327ec681f3Smrg 337ec681f3Smrg#define DXIL_FUNC_PARAM_FLOAT64 'g' 347ec681f3Smrg#define DXIL_FUNC_PARAM_FLOAT32 'f' 357ec681f3Smrg#define DXIL_FUNC_PARAM_FLOAT16 'e' 367ec681f3Smrg#define DXIL_FUNC_PARAM_HANDLE '@' 377ec681f3Smrg#define DXIL_FUNC_PARAM_POINTER '*' 387ec681f3Smrg#define DXIL_FUNC_PARAM_VOID 'v' 397ec681f3Smrg#define DXIL_FUNC_PARAM_FROM_OVERLOAD 'O' 407ec681f3Smrg#define DXIL_FUNC_PARAM_RESRET 'R' 417ec681f3Smrg#define DXIL_FUNC_PARAM_CBUF_RET 'B' 427ec681f3Smrg#define DXIL_FUNC_PARAM_DIM 'D' 437ec681f3Smrg#define DXIL_FUNC_PARAM_SPLIT_DOUBLE 'G' 447ec681f3Smrg 457ec681f3Smrg#include "dxil_module.h" 467ec681f3Smrg#include "util/rb_tree.h" 477ec681f3Smrg 487ec681f3Smrgconst char *dxil_overload_suffix( enum overload_type overload); 497ec681f3Smrg 507ec681f3Smrgconst struct dxil_type * 517ec681f3Smrgdxil_get_overload_type(struct dxil_module *mod, enum overload_type overload); 527ec681f3Smrg 537ec681f3Smrg/* These functions implement a generic method for declaring functions 547ec681f3Smrg * The input parameters types are given as a string using the characters 557ec681f3Smrg * given above as identifyer for the types. Only scalars and pointers to 567ec681f3Smrg * scalars are implemented at this point. 577ec681f3Smrg * 587ec681f3Smrg * Examples: 597ec681f3Smrg * 607ec681f3Smrg * Call: dxil_alloc_func(mod, "storeData.f32", "v", "icf"); 617ec681f3Smrg * Result function: void storeData.f32(int32, int8, float32) 627ec681f3Smrg * 637ec681f3Smrg * Call: dxil_alloc_func(mod, "storeData.f32", "e", "*icf"); 647ec681f3Smrg * Result function: float16 storeData.f32(int32 *, int8, float32) 657ec681f3Smrg * 667ec681f3Smrg * Call: dxil_alloc_func(mod, "storeData.f32", "*h", "b*f"); 677ec681f3Smrg * Result function: float16 storeData.f32(bool *, float32 *) 687ec681f3Smrg * 697ec681f3Smrg */ 707ec681f3Smrg 717ec681f3Smrgconst struct dxil_func * 727ec681f3Smrgdxil_alloc_func(struct dxil_module *mod, const char *name, enum overload_type overload, 737ec681f3Smrg const char *retval_type_descr, const char *param_descr, enum dxil_attr_kind attr); 747ec681f3Smrg 757ec681f3Smrg/* For specifically constructed return types one can also create the return type 767ec681f3Smrg * seperately and pass it as paramaer 777ec681f3Smrg */ 787ec681f3Smrgconst struct dxil_func * 797ec681f3Smrgdxil_alloc_func_with_rettype(struct dxil_module *mod, const char *name, enum overload_type overload, 807ec681f3Smrg const struct dxil_type *retval_type, const char *param_descr, 817ec681f3Smrg enum dxil_attr_kind attr); 827ec681f3Smrg 837ec681f3Smrg/* This call should be the usual entry point to allocate a new function type. 847ec681f3Smrg * 'name' must either be in the list of predefined functions, or a function 857ec681f3Smrg * with 'name' and 'overload' must already be allocated by using one of the above 867ec681f3Smrg * function calls. The allocated functions are searched for by using an rb_tree, so 877ec681f3Smrg * the search complexity should be O(log(n)). 887ec681f3Smrg */ 897ec681f3Smrgconst struct dxil_func * 907ec681f3Smrgdxil_get_function(struct dxil_module *mod, const char *name, 917ec681f3Smrg enum overload_type overload); 927ec681f3Smrg 937ec681f3Smrg#endif // DXIL_FUNCTION_H 94