1/*********************************************************************/ 2/* Copyright 2009, 2010 The University of Texas at Austin. */ 3/* All rights reserved. */ 4/* */ 5/* Redistribution and use in source and binary forms, with or */ 6/* without modification, are permitted provided that the following */ 7/* conditions are met: */ 8/* */ 9/* 1. Redistributions of source code must retain the above */ 10/* copyright notice, this list of conditions and the following */ 11/* disclaimer. */ 12/* */ 13/* 2. Redistributions in binary form must reproduce the above */ 14/* copyright notice, this list of conditions and the following */ 15/* disclaimer in the documentation and/or other materials */ 16/* provided with the distribution. */ 17/* */ 18/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */ 19/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */ 20/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ 21/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */ 22/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */ 23/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */ 24/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */ 25/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */ 26/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */ 27/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ 28/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */ 29/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */ 30/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */ 31/* POSSIBILITY OF SUCH DAMAGE. */ 32/* */ 33/* The views and conclusions contained in the software and */ 34/* documentation are those of the authors and should not be */ 35/* interpreted as representing official policies, either expressed */ 36/* or implied, of The University of Texas at Austin. */ 37/*********************************************************************/ 38 39#define ASSEMBLER 40#include "common.h" 41 42#define N $4 43#define X $5 44#define INCX $6 45 46#define I $2 47#define TEMP $3 48 49#define a1 $f4 50#define a2 $f5 51#define a3 $f6 52#define a4 $f7 53#define a5 $f8 54#define a6 $f9 55#define a7 $f10 56#define a8 $f11 57 58#define t1 $f12 59#define t2 $f13 60#define t3 $f14 61#define t4 $f15 62 63#define s1 $f0 64#define s2 $f1 65#define s3 $f2 66#define s4 $f3 67 68 PROLOGUE 69 70#ifdef F_INTERFACE 71 LDINT N, 0(N) 72 LDINT INCX, 0(INCX) 73#endif 74 75 blez N, .L999 76 MTC $0, s1 77 78 blez INCX, .L999 79 dsll INCX, INCX, BASE_SHIFT 80 81 LD a1, 0 * SIZE(X) 82 daddiu N, N, -1 83 84 daddu X, X, INCX 85 FABS s1, a1 86 87 blez N, .L999 88 FABS s2, a1 89 90 FABS s3, a1 91 dsra I, N, 3 92 93 blez I, .L15 94 FABS s4, a1 95 96 LD a1, 0 * SIZE(X) 97 daddu X, X, INCX 98 LD a2, 0 * SIZE(X) 99 daddu X, X, INCX 100 LD a3, 0 * SIZE(X) 101 daddu X, X, INCX 102 LD a4, 0 * SIZE(X) 103 daddu X, X, INCX 104 LD a5, 0 * SIZE(X) 105 daddu X, X, INCX 106 LD a6, 0 * SIZE(X) 107 daddu X, X, INCX 108 LD a7, 0 * SIZE(X) 109 daddu X, X, INCX 110 LD a8, 0 * SIZE(X) 111 daddiu I, I, -1 112 113 blez I, .L13 114 daddu X, X, INCX 115 .align 3 116 117.L12: 118 FABS t1, a1 119 LD a1, 0 * SIZE(X) 120 FABS t2, a2 121 daddu X, X, INCX 122 123 FABS t3, a3 124 LD a2, 0 * SIZE(X) 125 FABS t4, a4 126 daddu X, X, INCX 127 128 CMPLT $fcc0, t1, s1 129 LD a3, 0 * SIZE(X) 130 CMPLT $fcc1, t2, s2 131 daddu X, X, INCX 132 133 CMPLT $fcc2, t3, s3 134 LD a4, 0 * SIZE(X) 135 CMPLT $fcc3, t4, s4 136 daddu X, X, INCX 137 138 CMOVT s1, t1, $fcc0 139 CMOVT s2, t2, $fcc1 140 CMOVT s3, t3, $fcc2 141 CMOVT s4, t4, $fcc3 142 143 FABS t1, a5 144 LD a5, 0 * SIZE(X) 145 FABS t2, a6 146 daddu X, X, INCX 147 148 FABS t3, a7 149 LD a6, 0 * SIZE(X) 150 FABS t4, a8 151 daddu X, X, INCX 152 153 CMPLT $fcc0, t1, s1 154 LD a7, 0 * SIZE(X) 155 CMPLT $fcc1, t2, s2 156 daddu X, X, INCX 157 158 CMPLT $fcc2, t3, s3 159 LD a8, 0 * SIZE(X) 160 CMPLT $fcc3, t4, s4 161 daddu X, X, INCX 162 163 CMOVT s1, t1, $fcc0 164 daddiu I, I, -1 165 166 CMOVT s2, t2, $fcc1 167 CMOVT s3, t3, $fcc2 168 169 bgtz I, .L12 170 CMOVT s4, t4, $fcc3 171 .align 3 172 173.L13: 174 FABS t1, a1 175 FABS t2, a2 176 FABS t3, a3 177 FABS t4, a4 178 179 CMPLT $fcc0, t1, s1 180 CMPLT $fcc1, t2, s2 181 CMPLT $fcc2, t3, s3 182 CMPLT $fcc3, t4, s4 183 184 CMOVT s1, t1, $fcc0 185 CMOVT s2, t2, $fcc1 186 CMOVT s3, t3, $fcc2 187 CMOVT s4, t4, $fcc3 188 189 FABS t1, a5 190 FABS t2, a6 191 FABS t3, a7 192 FABS t4, a8 193 194 CMPLT $fcc0, t1, s1 195 CMPLT $fcc1, t2, s2 196 CMPLT $fcc2, t3, s3 197 CMPLT $fcc3, t4, s4 198 199 CMOVT s1, t1, $fcc0 200 CMOVT s2, t2, $fcc1 201 CMOVT s3, t3, $fcc2 202 CMOVT s4, t4, $fcc3 203 .align 3 204 205.L15: 206 andi I, N, 7 207 208 blez I, .L998 209 NOP 210 .align 3 211 212.L16: 213 LD a1, 0 * SIZE(X) 214 daddiu I, I, -1 215 216 FABS t1, a1 217 218 CMPLT $fcc0, t1, s1 219 220 CMOVT s1, t1, $fcc0 221 222 bgtz I, .L16 223 daddu X, X, INCX 224 .align 3 225 226.L998: 227 CMPLT $fcc0, s2, s1 228 CMPLT $fcc1, s4, s3 229 230 CMOVT s1, s2, $fcc0 231 CMOVT s3, s4, $fcc1 232 233 CMPLT $fcc0, s3, s1 234 CMOVT s1, s3, $fcc0 235 .align 3 236 237.L999: 238 j $31 239 NOP 240 241 EPILOGUE 242