1 /* 2 * Header file for wrappers around MSA instructions assembler invocations 3 * 4 * Copyright (C) 2018 Wave Computing, Inc. 5 * Copyright (C) 2018 Aleksandar Markovic <amarkovic@wavecomp.com> 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 * 20 */ 21 22 #ifndef WRAPPERS_MSA_H 23 #define WRAPPERS_MSA_H 24 25 26 #define DO_MSA__WD__WS(suffix, mnemonic) \ 27 static inline void do_msa_##suffix(void *input, void *output) \ 28 { \ 29 __asm__ volatile ( \ 30 "move $t0, %0\n\t" \ 31 "ld.d $w11, 0($t0)\n\t" \ 32 #mnemonic " $w10, $w11\n\t" \ 33 "move $t0, %1\n\t" \ 34 "st.d $w10, 0($t0)\n\t" \ 35 : \ 36 : "r" (input), "r" (output) \ 37 : "t0", "memory" \ 38 ); \ 39 } 40 41 DO_MSA__WD__WS(NLOC_B, nloc.b) 42 DO_MSA__WD__WS(NLOC_H, nloc.h) 43 DO_MSA__WD__WS(NLOC_W, nloc.w) 44 DO_MSA__WD__WS(NLOC_D, nloc.d) 45 46 DO_MSA__WD__WS(NLZC_B, nlzc.b) 47 DO_MSA__WD__WS(NLZC_H, nlzc.h) 48 DO_MSA__WD__WS(NLZC_W, nlzc.w) 49 DO_MSA__WD__WS(NLZC_D, nlzc.d) 50 51 DO_MSA__WD__WS(PCNT_B, pcnt.b) 52 DO_MSA__WD__WS(PCNT_H, pcnt.h) 53 DO_MSA__WD__WS(PCNT_W, pcnt.w) 54 DO_MSA__WD__WS(PCNT_D, pcnt.d) 55 56 57 #define DO_MSA__WD__WS_WT(suffix, mnemonic) \ 58 static inline void do_msa_##suffix(void *input1, void *input2, \ 59 void *output) \ 60 { \ 61 __asm__ volatile ( \ 62 "move $t0, %0\n\t" \ 63 "ld.d $w11, 0($t0)\n\t" \ 64 "move $t0, %1\n\t" \ 65 "ld.d $w12, 0($t0)\n\t" \ 66 #mnemonic " $w10, $w11, $w12\n\t" \ 67 "move $t0, %2\n\t" \ 68 "st.d $w10, 0($t0)\n\t" \ 69 : \ 70 : "r" (input1), "r" (input2), "r" (output) \ 71 : "t0", "memory" \ 72 ); \ 73 } 74 75 DO_MSA__WD__WS_WT(ILVEV_B, ilvev.b) 76 DO_MSA__WD__WS_WT(ILVEV_H, ilvev.h) 77 DO_MSA__WD__WS_WT(ILVEV_W, ilvev.w) 78 DO_MSA__WD__WS_WT(ILVEV_D, ilvev.d) 79 80 DO_MSA__WD__WS_WT(ILVOD_B, ilvod.b) 81 DO_MSA__WD__WS_WT(ILVOD_H, ilvod.h) 82 DO_MSA__WD__WS_WT(ILVOD_W, ilvod.w) 83 DO_MSA__WD__WS_WT(ILVOD_D, ilvod.d) 84 85 DO_MSA__WD__WS_WT(ILVL_B, ilvl.b) 86 DO_MSA__WD__WS_WT(ILVL_H, ilvl.h) 87 DO_MSA__WD__WS_WT(ILVL_W, ilvl.w) 88 DO_MSA__WD__WS_WT(ILVL_D, ilvl.d) 89 90 DO_MSA__WD__WS_WT(ILVR_B, ilvr.b) 91 DO_MSA__WD__WS_WT(ILVR_H, ilvr.h) 92 DO_MSA__WD__WS_WT(ILVR_W, ilvr.w) 93 DO_MSA__WD__WS_WT(ILVR_D, ilvr.d) 94 95 DO_MSA__WD__WS_WT(AND_V, and.v) 96 DO_MSA__WD__WS_WT(NOR_V, nor.v) 97 DO_MSA__WD__WS_WT(OR_V, or.v) 98 DO_MSA__WD__WS_WT(XOR_V, xor.v) 99 100 DO_MSA__WD__WS_WT(CEQ_B, ceq.b) 101 DO_MSA__WD__WS_WT(CEQ_H, ceq.h) 102 DO_MSA__WD__WS_WT(CEQ_W, ceq.w) 103 DO_MSA__WD__WS_WT(CEQ_D, ceq.d) 104 105 DO_MSA__WD__WS_WT(CLE_S_B, cle_s.b) 106 DO_MSA__WD__WS_WT(CLE_S_H, cle_s.h) 107 DO_MSA__WD__WS_WT(CLE_S_W, cle_s.w) 108 DO_MSA__WD__WS_WT(CLE_S_D, cle_s.d) 109 110 DO_MSA__WD__WS_WT(CLE_U_B, cle_u.b) 111 DO_MSA__WD__WS_WT(CLE_U_H, cle_u.h) 112 DO_MSA__WD__WS_WT(CLE_U_W, cle_u.w) 113 DO_MSA__WD__WS_WT(CLE_U_D, cle_u.d) 114 115 DO_MSA__WD__WS_WT(CLT_S_B, clt_s.b) 116 DO_MSA__WD__WS_WT(CLT_S_H, clt_s.h) 117 DO_MSA__WD__WS_WT(CLT_S_W, clt_s.w) 118 DO_MSA__WD__WS_WT(CLT_S_D, clt_s.d) 119 120 DO_MSA__WD__WS_WT(CLT_U_B, clt_u.b) 121 DO_MSA__WD__WS_WT(CLT_U_H, clt_u.h) 122 DO_MSA__WD__WS_WT(CLT_U_W, clt_u.w) 123 DO_MSA__WD__WS_WT(CLT_U_D, clt_u.d) 124 125 126 #endif 127