1/* Library functions. 2 Copyright (C) 2000 Free Software Foundation, Inc. 3 Contributed by Red Hat, Inc. 4 5 This file is part of GNU CC. 6 7 GNU CC 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, or (at your option) 10 any later version. 11 12 GNU CC 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 GNU CC; see the file COPYING. If not, write to 19 the Free Software Foundation, 59 Temple Place - Suite 330, 20 Boston, MA 02111-1307, USA. */ 21 22#include <frv-asm.h> 23 24 25#ifdef L_cmpll 26/* icc0 = __cmpll (long long a, long long b) */ 27 28 .file "_cmpll.s" 29 .globl EXT(__cmpll) 30 .type EXT(__cmpll),@function 31 .text 32 .p2align 4 33EXT(__cmpll): 34 cmp gr8, gr10, icc0 35 ckeq icc0, cc4 36 P(ccmp) gr9, gr11, cc4, 1 37 ret 38.Lend: 39 .size EXT(__cmpll),.Lend-EXT(__cmpll) 40#endif /* L_cmpll */ 41 42#ifdef L_cmpf 43/* icc0 = __cmpf (float a, float b) */ 44/* Note, because this function returns the result in ICC0, it means it can't 45 handle NaNs. */ 46 47 .file "_cmpf.s" 48 .globl EXT(__cmpf) 49 .type EXT(__cmpf),@function 50 .text 51 .p2align 4 52EXT(__cmpf): 53#ifdef __FRV_HARD_FLOAT__ /* floating point instructions available */ 54 movgf gr8, fr0 55 P(movgf) gr9, fr1 56 setlos #1, gr8 57 fcmps fr0, fr1, fcc0 58 P(fcklt) fcc0, cc0 59 fckeq fcc0, cc1 60 csub gr0, gr8, gr8, cc0, 1 61 cmov gr0, gr8, cc1, 1 62 cmpi gr8, 0, icc0 63 ret 64#else /* no floating point instructions available */ 65 movsg lr, gr4 66 addi sp, #-16, sp 67 sti gr4, @(sp, 8) 68 st fp, @(sp, gr0) 69 mov sp, fp 70 call EXT(__cmpsf2) 71 cmpi gr8, #0, icc0 72 ldi @(sp, 8), gr4 73 movgs gr4, lr 74 ld @(sp,gr0), fp 75 addi sp, #16, sp 76 ret 77#endif 78.Lend: 79 .size EXT(__cmpf),.Lend-EXT(__cmpf) 80#endif 81 82#ifdef L_cmpd 83/* icc0 = __cmpd (double a, double b) */ 84/* Note, because this function returns the result in ICC0, it means it can't 85 handle NaNs. */ 86 87 .file "_cmpd.s" 88 .globl EXT(__cmpd) 89 .type EXT(__cmpd),@function 90 .text 91 .p2align 4 92EXT(__cmpd): 93 movsg lr, gr4 94 addi sp, #-16, sp 95 sti gr4, @(sp, 8) 96 st fp, @(sp, gr0) 97 mov sp, fp 98 call EXT(__cmpdf2) 99 cmpi gr8, #0, icc0 100 ldi @(sp, 8), gr4 101 movgs gr4, lr 102 ld @(sp,gr0), fp 103 addi sp, #16, sp 104 ret 105.Lend: 106 .size EXT(__cmpd),.Lend-EXT(__cmpd) 107#endif 108 109#ifdef L_addll 110/* gr8,gr9 = __addll (long long a, long long b) */ 111/* Note, gcc will never call this function, but it is present in case an 112 ABI program calls it. */ 113 114 .file "_addll.s" 115 .globl EXT(__addll) 116 .type EXT(__addll),@function 117 .text 118 .p2align 119EXT(__addll): 120 addcc gr9, gr11, gr9, icc0 121 addx gr8, gr10, gr8, icc0 122 ret 123.Lend: 124 .size EXT(__addll),.Lend-EXT(__addll) 125#endif 126 127#ifdef L_subll 128/* gr8,gr9 = __subll (long long a, long long b) */ 129/* Note, gcc will never call this function, but it is present in case an 130 ABI program calls it. */ 131 132 .file "_subll.s" 133 .globl EXT(__subll) 134 .type EXT(__subll),@function 135 .text 136 .p2align 4 137EXT(__subll): 138 subcc gr9, gr11, gr9, icc0 139 subx gr8, gr10, gr8, icc0 140 ret 141.Lend: 142 .size EXT(__subll),.Lend-EXT(__subll) 143#endif 144 145#ifdef L_andll 146/* gr8,gr9 = __andll (long long a, long long b) */ 147/* Note, gcc will never call this function, but it is present in case an 148 ABI program calls it. */ 149 150 .file "_andll.s" 151 .globl EXT(__andll) 152 .type EXT(__andll),@function 153 .text 154 .p2align 4 155EXT(__andll): 156 P(and) gr9, gr11, gr9 157 P2(and) gr8, gr10, gr8 158 ret 159.Lend: 160 .size EXT(__andll),.Lend-EXT(__andll) 161#endif 162 163#ifdef L_orll 164/* gr8,gr9 = __orll (long long a, long long b) */ 165/* Note, gcc will never call this function, but it is present in case an 166 ABI program calls it. */ 167 168 .file "_orll.s" 169 .globl EXT(__orll) 170 .type EXT(__orll),@function 171 .text 172 .p2align 4 173EXT(__orll): 174 P(or) gr9, gr11, gr9 175 P2(or) gr8, gr10, gr8 176 ret 177.Lend: 178 .size EXT(__orll),.Lend-EXT(__orll) 179#endif 180 181#ifdef L_xorll 182/* gr8,gr9 = __xorll (long long a, long long b) */ 183/* Note, gcc will never call this function, but it is present in case an 184 ABI program calls it. */ 185 186 .file "_xorll.s" 187 .globl EXT(__xorll) 188 .type EXT(__xorll),@function 189 .text 190 .p2align 4 191EXT(__xorll): 192 P(xor) gr9, gr11, gr9 193 P2(xor) gr8, gr10, gr8 194 ret 195.Lend: 196 .size EXT(__xorll),.Lend-EXT(__xorll) 197#endif 198 199#ifdef L_notll 200/* gr8,gr9 = __notll (long long a) */ 201/* Note, gcc will never call this function, but it is present in case an 202 ABI program calls it. */ 203 204 .file "_notll.s" 205 .globl EXT(__notll) 206 .type EXT(__notll),@function 207 .text 208 .p2align 4 209EXT(__notll): 210 P(not) gr9, gr9 211 P2(not) gr8, gr8 212 ret 213.Lend: 214 .size EXT(__notll),.Lend-EXT(__notll) 215#endif 216 217#ifdef L_cmov 218/* (void) __cmov (char *dest, const char *src, size_t len) */ 219/* 220 * void __cmov (char *dest, const char *src, size_t len) 221 * { 222 * size_t i; 223 * 224 * if (dest < src || dest > src+len) 225 * { 226 * for (i = 0; i < len; i++) 227 * dest[i] = src[i]; 228 * } 229 * else 230 * { 231 * while (len-- > 0) 232 * dest[len] = src[len]; 233 * } 234 * } 235 */ 236 237 .file "_cmov.s" 238 .globl EXT(__cmov) 239 .type EXT(__cmov),@function 240 .text 241 .p2align 4 242EXT(__cmov): 243 P(cmp) gr8, gr9, icc0 244 add gr9, gr10, gr4 245 P(cmp) gr8, gr4, icc1 246 bc icc0, 0, .Lfwd 247 bls icc1, 0, .Lback 248.Lfwd: 249 /* move bytes in a forward direction */ 250 P(setlos) #0, gr5 251 cmp gr0, gr10, icc0 252 P(subi) gr9, #1, gr9 253 P2(subi) gr8, #1, gr8 254 bnc icc0, 0, .Lret 255.Lfloop: 256 /* forward byte move loop */ 257 addi gr5, #1, gr5 258 P(ldsb) @(gr9, gr5), gr4 259 cmp gr5, gr10, icc0 260 P(stb) gr4, @(gr8, gr5) 261 bc icc0, 0, .Lfloop 262 ret 263.Lbloop: 264 /* backward byte move loop body */ 265 ldsb @(gr9,gr10),gr4 266 stb gr4,@(gr8,gr10) 267.Lback: 268 P(cmpi) gr10, #0, icc0 269 addi gr10, #-1, gr10 270 bne icc0, 0, .Lbloop 271.Lret: 272 ret 273.Lend: 274 .size EXT(__cmov),.Lend-EXT(__cmov) 275#endif 276