1 /* 2 * Copyright (c) 2014 Advanced Micro Devices, Inc. 3 * 4 * Copyright (c) 2017 Michal Babej / Tampere University of Technology 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights 9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 * copies of the Software, and to permit persons to whom the Software is 11 * furnished to do so, subject to the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be included in 14 * all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 * THE SOFTWARE. 23 */ 24 25 #ifndef __VTABLES_H__ 26 #define __VTABLES_H__ 27 28 #define VTABLE_SPACE static constant 29 30 #define VTABLE_MANGLE(NAME) __pocl_v_##NAME 31 32 #define DECLARE_VTABLE(TYPE,NAME,LENGTH) \ 33 VTABLE_SPACE TYPE NAME [ LENGTH ] 34 35 #define SS(x) x 36 #define SGFY(x, y) x ## y 37 38 #define VTABLE_FUNCTION_DECL(TYPE, NAME) \ 39 _CL_OVERLOADABLE TYPE VTABLE_MANGLE(NAME)(uint idx); \ 40 _CL_OVERLOADABLE SGFY(TYPE, 2) VTABLE_MANGLE(NAME)(uint2 idx); \ 41 _CL_OVERLOADABLE SGFY(TYPE, 3) VTABLE_MANGLE(NAME)(uint3 idx); \ 42 _CL_OVERLOADABLE SGFY(TYPE, 4) VTABLE_MANGLE(NAME)(uint4 idx); \ 43 _CL_OVERLOADABLE SGFY(TYPE, 8) VTABLE_MANGLE(NAME)(uint8 idx); \ 44 _CL_OVERLOADABLE SGFY(TYPE, 16) VTABLE_MANGLE(NAME)(uint16 idx); 45 46 #define USE_VTABLE(NAME, IDX) \ 47 VTABLE_MANGLE(NAME)(IDX) 48 49 50 51 52 53 54 VTABLE_FUNCTION_DECL(v4uint, pibits_tbl); 55 56 VTABLE_FUNCTION_DECL(float, log_inv_tbl); 57 VTABLE_FUNCTION_DECL(float, exp_tbl); 58 59 VTABLE_FUNCTION_DECL(v2float, loge_tbl); 60 VTABLE_FUNCTION_DECL(v2float, log2_tbl); 61 VTABLE_FUNCTION_DECL(v2float, sinhcosh_tbl); 62 VTABLE_FUNCTION_DECL(v2float, cbrt_tbl); 63 VTABLE_FUNCTION_DECL(v2float, exp_tbl_ep); 64 65 66 67 68 #ifdef cl_khr_fp64 69 70 VTABLE_FUNCTION_DECL(double, cbrt_inv_tbl); 71 72 VTABLE_FUNCTION_DECL(v2double, ln_tbl); 73 VTABLE_FUNCTION_DECL(v2double, atan_jby256_tbl); 74 VTABLE_FUNCTION_DECL(v2double, two_to_jby64_ep_tbl); 75 VTABLE_FUNCTION_DECL(v2double, sinh_tbl); 76 VTABLE_FUNCTION_DECL(v2double, cosh_tbl); 77 VTABLE_FUNCTION_DECL(v2double, cbrt_dbl_tbl); 78 VTABLE_FUNCTION_DECL(v2double, cbrt_rem_tbl); 79 80 #endif 81 82 83 84 85 #endif // __VTABLES_H__ 86