1 1.1 matt /*- 2 1.1 matt * Copyright (c) 2013 The NetBSD Foundation, Inc. 3 1.1 matt * All rights reserved. 4 1.1 matt * 5 1.1 matt * This code is derived from software contributed to The NetBSD Foundation 6 1.1 matt * by Matt Thomas of 3am Software Foundry. 7 1.1 matt * 8 1.1 matt * Redistribution and use in source and binary forms, with or without 9 1.1 matt * modification, are permitted provided that the following conditions 10 1.1 matt * are met: 11 1.1 matt * 1. Redistributions of source code must retain the above copyright 12 1.1 matt * notice, this list of conditions and the following disclaimer. 13 1.1 matt * 2. Redistributions in binary form must reproduce the above copyright 14 1.1 matt * notice, this list of conditions and the following disclaimer in the 15 1.1 matt * documentation and/or other materials provided with the distribution. 16 1.1 matt * 17 1.1 matt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18 1.1 matt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 1.1 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 1.1 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 1.1 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 1.1 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 1.1 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 1.1 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 1.1 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 1.1 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 1.1 matt * POSSIBILITY OF SUCH DAMAGE. 28 1.1 matt */ 29 1.1 matt 30 1.1 matt #include <mips/asm.h> 31 1.1 matt 32 1.1 matt RCSID("$NetBSD: fpdf.S,v 1.1 2016/07/14 01:59:18 matt Exp $") 33 1.1 matt 34 1.1 matt /* 35 1.1 matt * This file provides softfloat compatible routines which use FP instructions 36 1.1 matt * to do the actual work. This should give near hard-float performance while 37 1.1 matt * being compatible with soft-float code. 38 1.1 matt * 39 1.1 matt * This file implements the double precision floating point routines. 40 1.1 matt */ 41 1.1 matt 42 1.1 matt #ifdef MIPS3 43 1.1 matt #define COP1_SYNC nop 44 1.1 matt #else 45 1.1 matt #define COP1_SYNC 46 1.1 matt #endif 47 1.1 matt 48 1.1 matt LEAF_NOPROFILE(__adddf3) 49 1.1 matt dmtc1 a0, $f12 50 1.1 matt dmtc1 a1, $f14 51 1.1 matt COP1_SYNC 52 1.1 matt add.d $f0, $f12, $f14 53 1.1 matt dmfc1 v0, $f0 54 1.1 matt jr ra 55 1.1 matt END(__adddf3) 56 1.1 matt 57 1.1 matt LEAF_NOPROFILE(__subdf3) 58 1.1 matt dmtc1 a0, $f12 59 1.1 matt dmtc1 a1, $f14 60 1.1 matt COP1_SYNC 61 1.1 matt sub.d $f0, $f12, $f14 62 1.1 matt dmfc1 v0, $f0 63 1.1 matt jr ra 64 1.1 matt END(__subdf3) 65 1.1 matt 66 1.1 matt LEAF_NOPROFILE(__muldf3) 67 1.1 matt dmtc1 a0, $f12 68 1.1 matt dmtc1 a1, $f14 69 1.1 matt COP1_SYNC 70 1.1 matt mul.d $f0, $f12, $f14 71 1.1 matt dmfc1 v0, $f0 72 1.1 matt jr ra 73 1.1 matt END(__muldf3) 74 1.1 matt 75 1.1 matt LEAF_NOPROFILE(__divdf3) 76 1.1 matt dmtc1 a0, $f12 77 1.1 matt dmtc1 a1, $f14 78 1.1 matt COP1_SYNC 79 1.1 matt div.d $f0, $f12, $f14 80 1.1 matt dmfc1 v0, $f0 81 1.1 matt jr ra 82 1.1 matt END(__divdf3) 83 1.1 matt 84 1.1 matt LEAF_NOPROFILE(__negdf2) 85 1.1 matt dmtc1 a0, $f12 86 1.1 matt COP1_SYNC 87 1.1 matt neg.d $f0, $f12 88 1.1 matt dmfc1 v0, $f0 89 1.1 matt jr ra 90 1.1 matt END(__negdf2) 91 1.1 matt 92 1.1 matt LEAF_NOPROFILE(__extendsfdf2) 93 1.1 matt dmtc1 a0, $f12 94 1.1 matt COP1_SYNC 95 1.1 matt cvt.d.s $f0, $f12 96 1.1 matt dmfc1 v0, $f0 97 1.1 matt jr ra 98 1.1 matt END(__extendsfdf2) 99 1.1 matt 100 1.1 matt LEAF_NOPROFILE(__fixdfdi) 101 1.1 matt dmtc1 a0, $f12 102 1.1 matt COP1_SYNC 103 1.1 matt trunc.l.d $f0, $f12 104 1.1 matt dmfc1 v0, $f0 105 1.1 matt jr ra 106 1.1 matt END(__fixdfdi) 107 1.1 matt 108 1.1 matt LEAF_NOPROFILE(__fixdfsi) 109 1.1 matt dmtc1 a0, $f12 110 1.1 matt COP1_SYNC 111 1.1 matt trunc.w.d $f0, $f12 112 1.1 matt mfc1 v0, $f0 113 1.1 matt jr ra 114 1.1 matt END(__fixdfsi) 115 1.1 matt 116 1.1 matt LEAF_NOPROFILE(__fixunsdfdi) 117 1.1 matt lui t0, 0x43e0 # 9223372036854775808.0 118 1.1 matt dsll t0, t0, 32 119 1.1 matt mtc1 t0, $f0 120 1.1 matt mtc1 a0, $f12 121 1.1 matt COP1_SYNC 122 1.1 matt sub.d $f0, $f12, $f0 # convert to signed 123 1.1 matt trunc.l.d $f0, $f0 124 1.1 matt dmfc1 v0, $f0 125 1.1 matt li v1, 1 126 1.1 matt dsll v1, v1, 63 127 1.1 matt add v0, v0, v1 # convert to unsigned 128 1.1 matt jr ra 129 1.1 matt END(__fixunsdfdi) 130 1.1 matt 131 1.1 matt LEAF_NOPROFILE(__fixunsdfsi) 132 1.1 matt lui t0, 0x41e0 # 2147483648.0 133 1.1 matt dsll t0, t0, 32 134 1.1 matt mtc1 t0, $f0 135 1.1 matt mtc1 a0, $f12 136 1.1 matt COP1_SYNC 137 1.1 matt sub.d $f0, $f12, $f0 # convert to signed 138 1.1 matt trunc.w.d $f0, $f0 139 1.1 matt lui v1, 0x8000 # 0xffffffff80000000 140 1.1 matt mfc1 v0, $f0 141 1.1 matt add v0, v0, v1 # convert to unsigned 142 1.1 matt jr ra 143 1.1 matt END(__fixunsdfsi) 144 1.1 matt 145 1.1 matt LEAF_NOPROFILE(__floatdidf) 146 1.1 matt dmtc1 a0, $f12 147 1.1 matt COP1_SYNC 148 1.1 matt cvt.d.l $f0, $f12 149 1.1 matt dmfc1 v0, $f0 150 1.1 matt jr ra 151 1.1 matt END(__floatdidf) 152 1.1 matt 153 1.1 matt LEAF_NOPROFILE(__floatsidf) 154 1.1 matt mtc1 a0, $f12 155 1.1 matt COP1_SYNC 156 1.1 matt cvt.d.w $f0, $f12 157 1.1 matt dmfc1 v0, $f0 158 1.1 matt jr ra 159 1.1 matt END(__floatsidf) 160 1.1 matt 161 1.1 matt LEAF_NOPROFILE(__floatundidf) 162 1.1 matt li t0, 1 163 1.1 matt dsll t0, t0, 63 164 1.1 matt dsub a0, a0, t0 165 1.1 matt dmtc1 a0, $f12 166 1.1 matt dmtc1 t0, $f14 167 1.1 matt COP1_SYNC 168 1.1 matt cvt.d.l $f0, $f12 169 1.1 matt cvt.d.l $f2, $f14 170 1.1 matt add.d $f0, $f0, $f2 171 1.1 matt dmfc1 v0, $f0 172 1.1 matt jr ra 173 1.1 matt END(__floatundidf) 174 1.1 matt 175 1.1 matt LEAF_NOPROFILE(__floatunsidf) 176 1.1 matt sll a0, a0, 0 177 1.1 matt dmtc1 a0, $f12 178 1.1 matt COP1_SYNC 179 1.1 matt cvt.d.l $f0, $f12 180 1.1 matt dmfc1 v0, $f0 181 1.1 matt jr ra 182 1.1 matt END(__floatunsidf) 183 1.1 matt 184 1.1 matt STRONG_ALIAS(__eqdf2, __nedf2) 185 1.1 matt LEAF_NOPROFILE(__nedf2) 186 1.1 matt .set push 187 1.1 matt .set noreorder 188 1.1 matt dmtc1 a0, $f12 189 1.1 matt dmtc1 a1, $f14 190 1.1 matt COP1_SYNC 191 1.1 matt c.eq.d $f12, $f14 192 1.1 matt bc1f 2f 193 1.1 matt li v0, 1 194 1.1 matt move v0, zero 195 1.1 matt 2: jr ra 196 1.1 matt nop 197 1.1 matt .set pop 198 1.1 matt END(__nedf2) 199 1.1 matt 200 1.1 matt STRONG_ALIAS(__gedf2, __ltdf2) 201 1.1 matt LEAF_NOPROFILE(__ltdf2) 202 1.1 matt .set push 203 1.1 matt .set noreorder 204 1.1 matt dmtc1 a0, $f12 205 1.1 matt dmtc1 a1, $f14 206 1.1 matt COP1_SYNC 207 1.1 matt c.olt.d $f12, $f14 208 1.1 matt bc1t 2f 209 1.1 matt li v0, -1 210 1.1 matt move v0, zero 211 1.1 matt 2: jr ra 212 1.1 matt nop 213 1.1 matt .set pop 214 1.1 matt END(__ltdf2) 215 1.1 matt 216 1.1 matt STRONG_ALIAS(__gtdf2, __ledf2) 217 1.1 matt LEAF_NOPROFILE(__ledf2) 218 1.1 matt .set push 219 1.1 matt .set noreorder 220 1.1 matt dmtc1 a0, $f12 221 1.1 matt dmtc1 a1, $f14 222 1.1 matt COP1_SYNC 223 1.1 matt c.ole.d $f12, $f14 224 1.1 matt bc1f 2f 225 1.1 matt li v0, 1 226 1.1 matt move v0, zero 227 1.1 matt 2: jr ra 228 1.1 matt nop 229 1.1 matt .set pop 230 1.1 matt END(__ledf2) 231 1.1 matt 232 1.1 matt LEAF_NOPROFILE(__unorddf2) 233 1.1 matt .set push 234 1.1 matt .set noreorder 235 1.1 matt dmtc1 a0, $f12 236 1.1 matt dmtc1 a1, $f14 237 1.1 matt COP1_SYNC 238 1.1 matt c.un.d $f12, $f14 239 1.1 matt bc1t 2f 240 1.1 matt li v0, 1 241 1.1 matt move v0, zero 242 1.1 matt 2: jr ra 243 1.1 matt nop 244 1.1 matt .set pop 245 1.1 matt END(__unorddf2) 246