1 /*- 2 * Copyright (c) 2012-2017 Ilya Kaliman 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND 15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 */ 26 27 #ifndef LIBEFP_INT_SHIFT_H 28 #define LIBEFP_INT_SHIFT_H 29 30 static const size_t shift_ss_x[] = { 0 }; 31 static const size_t shift_ss_y[] = { 0 }; 32 static const size_t shift_ss_z[] = { 0 }; 33 34 static const size_t shift_sl_x[] = { 0, 1, 0, 0 }; 35 static const size_t shift_sl_y[] = { 0, 0, 1, 0 }; 36 static const size_t shift_sl_z[] = { 0, 0, 0, 1 }; 37 38 static const size_t shift_sp_x[] = { 1, 0, 0 }; 39 static const size_t shift_sp_y[] = { 0, 1, 0 }; 40 static const size_t shift_sp_z[] = { 0, 0, 1 }; 41 42 static const size_t shift_sd_x[] = { 2, 0, 0, 1, 1, 0 }; 43 static const size_t shift_sd_y[] = { 0, 2, 0, 1, 0, 1 }; 44 static const size_t shift_sd_z[] = { 0, 0, 2, 0, 1, 1 }; 45 46 static const size_t shift_sf_x[] = { 3, 0, 0, 2, 2, 1, 0, 1, 0, 1 }; 47 static const size_t shift_sf_y[] = { 0, 3, 0, 1, 0, 2, 2, 0, 1, 1 }; 48 static const size_t shift_sf_z[] = { 0, 0, 3, 0, 1, 0, 1, 2, 2, 1 }; 49 50 static const size_t shift_ls_x[] = { 0, 5, 0, 0 }; 51 static const size_t shift_ls_y[] = { 0, 0, 5, 0 }; 52 static const size_t shift_ls_z[] = { 0, 0, 0, 5 }; 53 54 static const size_t shift_ll_x[] = { 0, 1, 0, 0, 5, 6, 5, 5, 0, 1, 0, 0, 0, 1, 0, 0 }; 55 static const size_t shift_ll_y[] = { 0, 0, 1, 0, 0, 0, 1, 0, 5, 5, 6, 5, 0, 0, 1, 0 }; 56 static const size_t shift_ll_z[] = { 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 5, 5, 5, 6 }; 57 58 static const size_t shift_lp_x[] = { 1, 0, 0, 6, 5, 5, 1, 0, 0, 1, 0, 0 }; 59 static const size_t shift_lp_y[] = { 0, 1, 0, 0, 1, 0, 5, 6, 5, 0, 1, 0 }; 60 static const size_t shift_lp_z[] = { 0, 0, 1, 0, 0, 1, 0, 0, 1, 5, 5, 6 }; 61 62 static const size_t shift_ld_x[] = { 2, 0, 0, 1, 1, 0, 7, 5, 5, 6, 6, 5, 2, 0, 0, 1, 1, 0, 2, 0, 0, 1, 1, 0 }; 63 static const size_t shift_ld_y[] = { 0, 2, 0, 1, 0, 1, 0, 2, 0, 1, 0, 1, 5, 7, 5, 6, 5, 6, 0, 2, 0, 1, 0, 1 }; 64 static const size_t shift_ld_z[] = { 0, 0, 2, 0, 1, 1, 0, 0, 2, 0, 1, 1, 0, 0, 2, 0, 1, 1, 5, 5, 7, 5, 6, 6 }; 65 66 static const size_t shift_lf_x[] = { 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 8, 5, 5, 7, 7, 6, 5, 6, 5, 6, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1 }; 67 static const size_t shift_lf_y[] = { 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 5, 8, 5, 6, 5, 7, 7, 5, 6, 6, 0, 3, 0, 1, 0, 2, 2, 0, 1, 1 }; 68 static const size_t shift_lf_z[] = { 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 5, 5, 8, 5, 6, 5, 6, 7, 7, 6 }; 69 70 static const size_t shift_ps_x[] = { 5, 0, 0 }; 71 static const size_t shift_ps_y[] = { 0, 5, 0 }; 72 static const size_t shift_ps_z[] = { 0, 0, 5 }; 73 74 static const size_t shift_pl_x[] = { 5, 6, 5, 5, 0, 1, 0, 0, 0, 1, 0, 0 }; 75 static const size_t shift_pl_y[] = { 0, 0, 1, 0, 5, 5, 6, 5, 0, 0, 1, 0 }; 76 static const size_t shift_pl_z[] = { 0, 0, 0, 1, 0, 0, 0, 1, 5, 5, 5, 6 }; 77 78 static const size_t shift_pp_x[] = { 6, 5, 5, 1, 0, 0, 1, 0, 0 }; 79 static const size_t shift_pp_y[] = { 0, 1, 0, 5, 6, 5, 0, 1, 0 }; 80 static const size_t shift_pp_z[] = { 0, 0, 1, 0, 0, 1, 5, 5, 6 }; 81 82 static const size_t shift_pd_x[] = { 7, 5, 5, 6, 6, 5, 2, 0, 0, 1, 1, 0, 2, 0, 0, 1, 1, 0 }; 83 static const size_t shift_pd_y[] = { 0, 2, 0, 1, 0, 1, 5, 7, 5, 6, 5, 6, 0, 2, 0, 1, 0, 1 }; 84 static const size_t shift_pd_z[] = { 0, 0, 2, 0, 1, 1, 0, 0, 2, 0, 1, 1, 5, 5, 7, 5, 6, 6 }; 85 86 static const size_t shift_pf_x[] = { 8, 5, 5, 7, 7, 6, 5, 6, 5, 6, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1 }; 87 static const size_t shift_pf_y[] = { 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 5, 8, 5, 6, 5, 7, 7, 5, 6, 6, 0, 3, 0, 1, 0, 2, 2, 0, 1, 1 }; 88 static const size_t shift_pf_z[] = { 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 5, 5, 8, 5, 6, 5, 6, 7, 7, 6 }; 89 90 static const size_t shift_ds_x[] = { 10, 0, 0, 5, 5, 0 }; 91 static const size_t shift_ds_y[] = { 0, 10, 0, 5, 0, 5 }; 92 static const size_t shift_ds_z[] = { 0, 0, 10, 0, 5, 5 }; 93 94 static const size_t shift_dl_x[] = { 10, 11, 10, 10, 0, 1, 0, 0, 0, 1, 0, 0, 5, 6, 5, 5, 5, 6, 5, 5, 0, 1, 0, 0 }; 95 static const size_t shift_dl_y[] = { 0, 0, 1, 0, 10, 10, 11, 10, 0, 0, 1, 0, 5, 5, 6, 5, 0, 0, 1, 0, 5, 5, 6, 5 }; 96 static const size_t shift_dl_z[] = { 0, 0, 0, 1, 0, 0, 0, 1, 10, 10, 10, 11, 0, 0, 0, 1, 5, 5, 5, 6, 5, 5, 5, 6 }; 97 98 static const size_t shift_dp_x[] = { 11, 10, 10, 1, 0, 0, 1, 0, 0, 6, 5, 5, 6, 5, 5, 1, 0, 0 }; 99 static const size_t shift_dp_y[] = { 0, 1, 0, 10, 11, 10, 0, 1, 0, 5, 6, 5, 0, 1, 0, 5, 6, 5 }; 100 static const size_t shift_dp_z[] = { 0, 0, 1, 0, 0, 1, 10, 10, 11, 0, 0, 1, 5, 5, 6, 5, 5, 6 }; 101 102 static const size_t shift_dd_x[] = { 12, 10, 10, 11, 11, 10, 2, 0, 0, 1, 1, 0, 2, 0, 0, 1, 1, 0, 7, 5, 5, 6, 6, 5, 7, 5, 5, 6, 6, 5, 2, 0, 0, 1, 1, 0 }; 103 static const size_t shift_dd_y[] = { 0, 2, 0, 1, 0, 1, 10, 12, 10, 11, 10, 11, 0, 2, 0, 1, 0, 1, 5, 7, 5, 6, 5, 6, 0, 2, 0, 1, 0, 1, 5, 7, 5, 6, 5, 6 }; 104 static const size_t shift_dd_z[] = { 0, 0, 2, 0, 1, 1, 0, 0, 2, 0, 1, 1, 10, 10, 12, 10, 11, 11, 0, 0, 2, 0, 1, 1, 5, 5, 7, 5, 6, 6, 5, 5, 7, 5, 6, 6 }; 105 106 static const size_t shift_df_x[] = { 13, 10, 10, 12, 12, 11, 10, 11, 10, 11, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 8, 5, 5, 7, 7, 6, 5, 6, 5, 6, 8, 5, 5, 7, 7, 6, 5, 6, 5, 6, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1 }; 107 static const size_t shift_df_y[] = { 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 10, 13, 10, 11, 10, 12, 12, 10, 11, 11, 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 5, 8, 5, 6, 5, 7, 7, 5, 6, 6, 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 5, 8, 5, 6, 5, 7, 7, 5, 6, 6 }; 108 static const size_t shift_df_z[] = { 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 10, 10, 13, 10, 11, 10, 11, 12, 12, 11, 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 5, 5, 8, 5, 6, 5, 6, 7, 7, 6, 5, 5, 8, 5, 6, 5, 6, 7, 7, 6 }; 109 110 static const size_t shift_fs_x[] = { 5, 0, 0, 10, 10, 5, 0, 5, 0, 5 }; 111 static const size_t shift_fs_y[] = { 0, 15, 0, 5, 0, 10, 10, 0, 5, 5 }; 112 static const size_t shift_fs_z[] = { 0, 0, 15, 0, 5, 0, 5, 10, 10, 5 }; 113 114 static const size_t shift_fl_x[] = { 5, 6, 5, 5, 0, 1, 0, 0, 0, 1, 0, 0, 10, 11, 10, 10, 10, 11, 10, 10, 5, 6, 5, 5, 0, 1, 0, 0, 5, 6, 5, 5, 0, 1, 0, 0, 5, 6, 5, 5 }; 115 static const size_t shift_fl_y[] = { 0, 0, 1, 0, 15, 15, 16, 15, 0, 0, 1, 0, 5, 5, 6, 5, 0, 0, 1, 0, 10, 10, 11, 10, 10, 10, 11, 10, 0, 0, 1, 0, 5, 5, 6, 5, 5, 5, 6, 5 }; 116 static const size_t shift_fl_z[] = { 0, 0, 0, 1, 0, 0, 0, 1, 15, 15, 15, 16, 0, 0, 0, 1, 5, 5, 5, 6, 0, 0, 0, 1, 5, 5, 5, 6, 10, 10, 10, 11, 10, 10, 10, 11, 5, 5, 5, 6 }; 117 118 static const size_t shift_fp_x[] = { 6, 5, 5, 1, 0, 0, 1, 0, 0, 11, 10, 10, 11, 10, 10, 6, 5, 5, 1, 0, 0, 6, 5, 5, 1, 0, 0, 6, 5, 5 }; 119 static const size_t shift_fp_y[] = { 0, 1, 0, 15, 16, 15, 0, 1, 0, 5, 6, 5, 0, 1, 0, 10, 11, 10, 10, 11, 10, 0, 1, 0, 5, 6, 5, 5, 6, 5 }; 120 static const size_t shift_fp_z[] = { 0, 0, 1, 0, 0, 1, 15, 15, 16, 0, 0, 1, 5, 5, 6, 0, 0, 1, 5, 5, 6, 10, 10, 11, 10, 10, 11, 5, 5, 6 }; 121 122 static const size_t shift_fd_x[] = { 7, 5, 5, 6, 6, 5, 2, 0, 0, 1, 1, 0, 2, 0, 0, 1, 1, 0, 12, 10, 10, 11, 11, 10, 12, 10, 10, 11, 11, 10, 7, 5, 5, 6, 6, 5, 2, 0, 0, 1, 1, 0, 7, 5, 5, 6, 6, 5, 2, 0, 0, 1, 1, 0, 7, 5, 5, 6, 6, 5 }; 123 static const size_t shift_fd_y[] = { 0, 2, 0, 1, 0, 1, 15, 17, 15, 16, 15, 16, 0, 2, 0, 1, 0, 1, 5, 7, 5, 6, 5, 6, 0, 2, 0, 1, 0, 1, 10, 12, 10, 11, 10, 11, 10, 12, 10, 11, 10, 11, 0, 2, 0, 1, 0, 1, 5, 7, 5, 6, 5, 6, 5, 7, 5, 6, 5, 6 }; 124 static const size_t shift_fd_z[] = { 0, 0, 2, 0, 1, 1, 0, 0, 2, 0, 1, 1, 15, 15, 17, 15, 16, 16, 0, 0, 2, 0, 1, 1, 5, 5, 7, 5, 6, 6, 0, 0, 2, 0, 1, 1, 5, 5, 7, 5, 6, 6, 10, 10, 12, 10, 11, 11, 10, 10, 12, 10, 11, 11, 5, 5, 7, 5, 6, 6 }; 125 126 static const size_t shift_ff_x[] = { 8, 5, 5, 7, 7, 6, 5, 6, 5, 6, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 13, 10, 10, 12, 12, 11, 10, 11, 10, 11, 13, 10, 10, 12, 12, 11, 10, 11, 10, 11, 8, 5, 5, 7, 7, 6, 5, 6, 5, 6, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 8, 5, 5, 7, 7, 6, 5, 6, 5, 6, 3, 0, 0, 2, 2, 1, 0, 1, 0, 1, 8, 5, 5, 7, 7, 6, 5, 6, 5, 6 }; 127 static const size_t shift_ff_y[] = { 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 15, 18, 15, 16, 15, 17, 17, 15, 16, 16, 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 5, 8, 5, 6, 5, 7, 7, 5, 6, 6, 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 10, 13, 10, 11, 10, 12, 12, 10, 11, 11, 10, 13, 10, 11, 10, 12, 12, 10, 11, 11, 0, 3, 0, 1, 0, 2, 2, 0, 1, 1, 5, 8, 5, 6, 5, 7, 7, 5, 6, 6, 5, 8, 5, 6, 5, 7, 7, 5, 6, 6 }; 128 static const size_t shift_ff_z[] = { 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 15, 15, 18, 15, 16, 15, 16, 17, 17, 16, 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 5, 5, 8, 5, 6, 5, 6, 7, 7, 6, 0, 0, 3, 0, 1, 0, 1, 2, 2, 1, 5, 5, 8, 5, 6, 5, 6, 7, 7, 6, 10, 10, 13, 10, 11, 10, 11, 12, 12, 11, 10, 10, 13, 10, 11, 10, 11, 12, 12, 11, 5, 5, 8, 5, 6, 5, 6, 7, 7, 6 }; 129 130 static const size_t *shift_table_x[] = { shift_ss_x, 131 shift_sl_x, 132 shift_sp_x, 133 shift_sd_x, 134 shift_sf_x, 135 shift_ls_x, 136 shift_ll_x, 137 shift_lp_x, 138 shift_ld_x, 139 shift_lf_x, 140 shift_ps_x, 141 shift_pl_x, 142 shift_pp_x, 143 shift_pd_x, 144 shift_pf_x, 145 shift_ds_x, 146 shift_dl_x, 147 shift_dp_x, 148 shift_dd_x, 149 shift_df_x, 150 shift_fs_x, 151 shift_fl_x, 152 shift_fp_x, 153 shift_fd_x, 154 shift_ff_x }; 155 156 static const size_t *shift_table_y[] = { shift_ss_y, 157 shift_sl_y, 158 shift_sp_y, 159 shift_sd_y, 160 shift_sf_y, 161 shift_ls_y, 162 shift_ll_y, 163 shift_lp_y, 164 shift_ld_y, 165 shift_lf_y, 166 shift_ps_y, 167 shift_pl_y, 168 shift_pp_y, 169 shift_pd_y, 170 shift_pf_y, 171 shift_ds_y, 172 shift_dl_y, 173 shift_dp_y, 174 shift_dd_y, 175 shift_df_y, 176 shift_fs_y, 177 shift_fl_y, 178 shift_fp_y, 179 shift_fd_y, 180 shift_ff_y }; 181 182 static const size_t *shift_table_z[] = { shift_ss_z, 183 shift_sl_z, 184 shift_sp_z, 185 shift_sd_z, 186 shift_sf_z, 187 shift_ls_z, 188 shift_ll_z, 189 shift_lp_z, 190 shift_ld_z, 191 shift_lf_z, 192 shift_ps_z, 193 shift_pl_z, 194 shift_pp_z, 195 shift_pd_z, 196 shift_pf_z, 197 shift_ds_z, 198 shift_dl_z, 199 shift_dp_z, 200 shift_dd_z, 201 shift_df_z, 202 shift_fs_z, 203 shift_fl_z, 204 shift_fp_z, 205 shift_fd_z, 206 shift_ff_z }; 207 208 #endif /* LIBEFP_INT_SHIFT_H */ 209