00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 /* ==================================================================== 00037 * ==================================================================== 00038 * 00039 * Module: variants.cxx 00040 * $Revision: 1.2 $ 00041 * $Date: 02/11/07 23:41:28-00:00 $ 00042 * $Author: fchow@keyresearch.com $ 00043 * $Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/SCCS/s.variants.cxx $ 00044 * 00045 * Description: 00046 * 00047 * Functions related to OP variant field contents. 00048 * 00049 * ==================================================================== 00050 * ==================================================================== 00051 */ 00052 00053 #ifdef _KEEP_RCS_ID 00054 static const char rcs_id[] = "$Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/SCCS/s.variants.cxx $ $Revision: 1.2 $"; 00055 #endif /* _KEEP_RCS_ID */ 00056 00057 #include "defs.h" 00058 #include "config.h" 00059 #include "glob.h" 00060 #include "erglob.h" 00061 #include "erbe.h" 00062 #include "tracing.h" 00063 00064 #include "variants.h" 00065 00066 /* ==================================================================== 00067 * 00068 * Negate_BR_Variant 00069 * 00070 * See interface description. 00071 * 00072 * ==================================================================== 00073 */ 00074 VARIANT 00075 Negate_BR_Variant(VARIANT variant) 00076 { 00077 BOOL is_false = V_false_br(variant); 00078 00079 switch (V_br_condition(variant)) { 00080 case V_BR_NONE: break; 00081 00082 case V_BR_I8EQ0: variant = V_BR_I8NE0; break; 00083 case V_BR_I8NE0: variant = V_BR_I8EQ0; break; 00084 case V_BR_I8GT0: variant = V_BR_I8LE0; break; 00085 case V_BR_I8GE0: variant = V_BR_I8LT0; break; 00086 case V_BR_I8LT0: variant = V_BR_I8GE0; break; 00087 case V_BR_I8LE0: variant = V_BR_I8GT0; break; 00088 00089 case V_BR_I8EQ: variant = V_BR_I8NE; break; 00090 case V_BR_I8NE: variant = V_BR_I8EQ; break; 00091 case V_BR_I8GT: variant = V_BR_I8LE; break; 00092 case V_BR_I8GE: variant = V_BR_I8LT; break; 00093 case V_BR_I8LT: variant = V_BR_I8GE; break; 00094 case V_BR_I8LE: variant = V_BR_I8GT; break; 00095 00096 case V_BR_U8EQ0: variant = V_BR_U8NE0; break; 00097 case V_BR_U8NE0: variant = V_BR_U8EQ0; break; 00098 case V_BR_U8GT0: variant = V_BR_U8LE0; break; 00099 case V_BR_U8GE0: variant = V_BR_U8LT0; break; 00100 case V_BR_U8LT0: variant = V_BR_U8GE0; break; 00101 case V_BR_U8LE0: variant = V_BR_U8GT0; break; 00102 00103 case V_BR_U8EQ: variant = V_BR_U8NE; break; 00104 case V_BR_U8NE: variant = V_BR_U8EQ; break; 00105 case V_BR_U8GT: variant = V_BR_U8LE; break; 00106 case V_BR_U8GE: variant = V_BR_U8LT; break; 00107 case V_BR_U8LT: variant = V_BR_U8GE; break; 00108 case V_BR_U8LE: variant = V_BR_U8GT; break; 00109 00110 case V_BR_I4EQ: variant = V_BR_I4NE; break; 00111 case V_BR_I4NE: variant = V_BR_I4EQ; break; 00112 case V_BR_I4GT: variant = V_BR_I4LE; break; 00113 case V_BR_I4GE: variant = V_BR_I4LT; break; 00114 case V_BR_I4LT: variant = V_BR_I4GE; break; 00115 case V_BR_I4LE: variant = V_BR_I4GT; break; 00116 00117 case V_BR_U4EQ: variant = V_BR_U4NE; break; 00118 case V_BR_U4NE: variant = V_BR_U4EQ; break; 00119 case V_BR_U4GT: variant = V_BR_U4LE; break; 00120 case V_BR_U4GE: variant = V_BR_U4LT; break; 00121 case V_BR_U4LT: variant = V_BR_U4GE; break; 00122 case V_BR_U4LE: variant = V_BR_U4GT; break; 00123 00124 case V_BR_F_FALSE: variant = V_BR_F_TRUE; break; 00125 case V_BR_F_TRUE: variant = V_BR_F_FALSE; break; 00126 00127 case V_BR_PEQ: variant = V_BR_PNE; break; 00128 case V_BR_PNE: variant = V_BR_PEQ; break; 00129 00130 case V_BR_FEQ: 00131 case V_BR_FNE: 00132 case V_BR_FGT: 00133 case V_BR_FGE: 00134 case V_BR_FLT: 00135 case V_BR_FLE: 00136 00137 case V_BR_DEQ: 00138 case V_BR_DNE: 00139 case V_BR_DGT: 00140 case V_BR_DGE: 00141 case V_BR_DLT: 00142 case V_BR_DLE: 00143 00144 #ifdef TARG_IA64 00145 case V_BR_XEQ: 00146 case V_BR_XNE: 00147 case V_BR_XGT: 00148 case V_BR_XGE: 00149 case V_BR_XLT: 00150 case V_BR_XLE: 00151 #endif 00152 00153 case V_BR_QEQ: 00154 case V_BR_QNE: 00155 case V_BR_QGT: 00156 case V_BR_QGE: 00157 case V_BR_QLT: 00158 case V_BR_QLE: 00159 case V_BR_FOR: 00160 case V_BR_DOR: 00161 case V_BR_DUO: 00162 case V_BR_FUO: 00163 // changing the variant will effect the comparison if NaNs are 00164 // involved, so just flip the sense. 00165 is_false = !is_false; 00166 break; 00167 00168 case V_BR_P_TRUE: 00169 case V_BR_CLOOP: 00170 case V_BR_CTOP: 00171 case V_BR_CEXIT: 00172 case V_BR_WTOP: 00173 case V_BR_WEXIT: 00174 // no inverse condition -- invert the sense 00175 is_false = !is_false; 00176 break; 00177 00178 case V_BR_ALWAYS: variant = V_BR_NEVER; break; 00179 case V_BR_NEVER: variant = V_BR_ALWAYS; break; 00180 00181 default: 00182 #pragma mips_frequency_hint NEVER 00183 FmtAssert(FALSE, ("unexpected variant %lld", variant)); 00184 /*NOTREACHED*/ 00185 } 00186 00187 // set the sense. 00188 if (is_false) { 00189 Set_V_false_br(variant); 00190 } else { 00191 Set_V_true_br(variant); 00192 } 00193 00194 return variant; 00195 } 00196 00197 00198 /* ==================================================================== 00199 * 00200 * Invert_BR_Variant 00201 * 00202 * See interface description. 00203 * 00204 * ==================================================================== 00205 */ 00206 VARIANT 00207 Invert_BR_Variant(VARIANT variant) 00208 { 00209 BOOL is_false = V_false_br(variant); 00210 00211 switch (V_br_condition(variant)) { 00212 case V_BR_NONE: break; 00213 00214 case V_BR_I8EQ: variant = V_BR_I8EQ; break; 00215 case V_BR_I8NE: variant = V_BR_I8NE; break; 00216 case V_BR_I8GT: variant = V_BR_I8LT; break; 00217 case V_BR_I8GE: variant = V_BR_I8LE; break; 00218 case V_BR_I8LT: variant = V_BR_I8GT; break; 00219 case V_BR_I8LE: variant = V_BR_I8GE; break; 00220 00221 case V_BR_U8EQ: variant = V_BR_U8EQ; break; 00222 case V_BR_U8NE: variant = V_BR_U8NE; break; 00223 case V_BR_U8GT: variant = V_BR_U8LT; break; 00224 case V_BR_U8GE: variant = V_BR_U8LE; break; 00225 case V_BR_U8LT: variant = V_BR_U8GT; break; 00226 case V_BR_U8LE: variant = V_BR_U8GE; break; 00227 00228 case V_BR_FEQ: variant = V_BR_FEQ; break; 00229 case V_BR_FNE: variant = V_BR_FNE; break; 00230 case V_BR_FGT: variant = V_BR_FLT; break; 00231 case V_BR_FGE: variant = V_BR_FLE; break; 00232 case V_BR_FLT: variant = V_BR_FGT; break; 00233 case V_BR_FLE: variant = V_BR_FGE; break; 00234 00235 case V_BR_DEQ: variant = V_BR_DEQ; break; 00236 case V_BR_DNE: variant = V_BR_DNE; break; 00237 case V_BR_DGT: variant = V_BR_DLT; break; 00238 case V_BR_DGE: variant = V_BR_DLE; break; 00239 case V_BR_DLT: variant = V_BR_DGT; break; 00240 case V_BR_DLE: variant = V_BR_DGE; break; 00241 00242 #ifdef TARG_IA64 00243 case V_BR_XEQ: variant = V_BR_XEQ; break; 00244 case V_BR_XNE: variant = V_BR_XNE; break; 00245 case V_BR_XGT: variant = V_BR_XLT; break; 00246 case V_BR_XGE: variant = V_BR_XLE; break; 00247 case V_BR_XLT: variant = V_BR_XGT; break; 00248 case V_BR_XLE: variant = V_BR_XGE; break; 00249 #endif 00250 00251 case V_BR_QEQ: variant = V_BR_QEQ; break; 00252 case V_BR_QNE: variant = V_BR_QNE; break; 00253 case V_BR_QGT: variant = V_BR_QLT; break; 00254 case V_BR_QGE: variant = V_BR_QLE; break; 00255 case V_BR_QLT: variant = V_BR_QGT; break; 00256 case V_BR_QLE: variant = V_BR_QGE; break; 00257 00258 case V_BR_I4EQ: variant = V_BR_I4EQ; break; 00259 case V_BR_I4NE: variant = V_BR_I4NE; break; 00260 case V_BR_I4GT: variant = V_BR_I4LT; break; 00261 case V_BR_I4GE: variant = V_BR_I4LE; break; 00262 case V_BR_I4LT: variant = V_BR_I4GT; break; 00263 case V_BR_I4LE: variant = V_BR_I4GE; break; 00264 00265 case V_BR_U4EQ: variant = V_BR_U4EQ; break; 00266 case V_BR_U4NE: variant = V_BR_U4NE; break; 00267 case V_BR_U4GT: variant = V_BR_U4LT; break; 00268 case V_BR_U4GE: variant = V_BR_U4LE; break; 00269 case V_BR_U4LT: variant = V_BR_U4GT; break; 00270 case V_BR_U4LE: variant = V_BR_U4GE; break; 00271 00272 case V_BR_PEQ: variant = V_BR_PEQ; break; 00273 case V_BR_PNE: variant = V_BR_PNE; break; 00274 00275 case V_BR_I8EQ0: 00276 case V_BR_I8NE0: 00277 case V_BR_I8GT0: 00278 case V_BR_I8GE0: 00279 case V_BR_I8LT0: 00280 case V_BR_I8LE0: 00281 case V_BR_U8EQ0: 00282 case V_BR_U8NE0: 00283 case V_BR_U8GT0: 00284 case V_BR_U8GE0: 00285 case V_BR_U8LT0: 00286 case V_BR_U8LE0: 00287 case V_BR_F_FALSE: 00288 case V_BR_F_TRUE: 00289 case V_BR_P_TRUE: 00290 // these branches only have one operand, so swapping operands 00291 // makes no sense. 00292 break; 00293 00294 case V_BR_ALWAYS: 00295 case V_BR_NEVER: 00296 case V_BR_CLOOP: 00297 case V_BR_CTOP: 00298 case V_BR_CEXIT: 00299 case V_BR_WTOP: 00300 case V_BR_WEXIT: 00301 // these branches effectively have no operands, so swapping 00302 // operands makes no sense. 00303 break; 00304 00305 default: 00306 #pragma mips_frequency_hint NEVER 00307 FmtAssert(FALSE, ("unexpected variant %lld", variant)); 00308 /*NOTREACHED*/ 00309 } 00310 00311 // set the sense. 00312 if (is_false) { 00313 Set_V_false_br(variant); 00314 } else { 00315 Set_V_true_br(variant); 00316 } 00317 00318 return variant; 00319 } 00320 00321 00322 /* ==================================================================== 00323 * 00324 * BR_Variant_Name 00325 * 00326 * See interface description. 00327 * 00328 * ==================================================================== 00329 */ 00330 const char * 00331 BR_Variant_Name(VARIANT variant) 00332 { 00333 BOOL is_false = V_false_br(variant); 00334 switch (variant & V_BR_MASK) { 00335 case V_BR_NONE: return is_false ? "!NONE" : "NONE"; 00336 00337 case V_BR_I8EQ0: return is_false ? "!I8EQ0" : "I8EQ0"; 00338 case V_BR_I8NE0: return is_false ? "!I8NE0" : "I8NE0"; 00339 case V_BR_I8GT0: return is_false ? "!I8GT0" : "I8GT0"; 00340 case V_BR_I8GE0: return is_false ? "!I8GE0" : "I8GE0"; 00341 case V_BR_I8LT0: return is_false ? "!I8LT0" : "I8LT0"; 00342 case V_BR_I8LE0: return is_false ? "!I8LE0" : "I8LE0"; 00343 00344 case V_BR_I8EQ: return is_false ? "!I8EQ" : "I8EQ"; 00345 case V_BR_I8NE: return is_false ? "!I8NE" : "I8NE"; 00346 case V_BR_I8GT: return is_false ? "!I8GT" : "I8GT"; 00347 case V_BR_I8GE: return is_false ? "!I8GE" : "I8GE"; 00348 case V_BR_I8LT: return is_false ? "!I8LT" : "I8LT"; 00349 case V_BR_I8LE: return is_false ? "!I8LE" : "I8LE"; 00350 00351 case V_BR_U8EQ0: return is_false ? "!U8EQ0" : "U8EQ0"; 00352 case V_BR_U8NE0: return is_false ? "!U8NE0" : "U8NE0"; 00353 case V_BR_U8GT0: return is_false ? "!U8GT0" : "U8GT0"; 00354 case V_BR_U8GE0: return is_false ? "!U8GE0" : "U8GE0"; 00355 case V_BR_U8LT0: return is_false ? "!U8LT0" : "U8LT0"; 00356 case V_BR_U8LE0: return is_false ? "!U8LE0" : "U8LE0"; 00357 00358 case V_BR_U8EQ: return is_false ? "!U8EQ" : "U8EQ"; 00359 case V_BR_U8NE: return is_false ? "!U8NE" : "U8NE"; 00360 case V_BR_U8GT: return is_false ? "!U8GT" : "U8GT"; 00361 case V_BR_U8GE: return is_false ? "!U8GE" : "U8GE"; 00362 case V_BR_U8LT: return is_false ? "!U8LT" : "U8LT"; 00363 case V_BR_U8LE: return is_false ? "!U8LE" : "U8LE"; 00364 00365 case V_BR_FEQ: return is_false ? "!FEQ" : "FEQ"; 00366 case V_BR_FNE: return is_false ? "!FNE" : "FNE"; 00367 case V_BR_FGT: return is_false ? "!FGT" : "FGT"; 00368 case V_BR_FGE: return is_false ? "!FGE" : "FGE"; 00369 case V_BR_FLT: return is_false ? "!FLT" : "FLT"; 00370 case V_BR_FLE: return is_false ? "!FLE" : "FLE"; 00371 00372 case V_BR_DEQ: return is_false ? "!DEQ" : "DEQ"; 00373 case V_BR_DNE: return is_false ? "!DNE" : "DNE"; 00374 case V_BR_DGT: return is_false ? "!DGT" : "DGT"; 00375 case V_BR_DGE: return is_false ? "!DGE" : "DGE"; 00376 case V_BR_DLT: return is_false ? "!DLT" : "DLT"; 00377 case V_BR_DLE: return is_false ? "!DLE" : "DLE"; 00378 00379 #ifdef TARG_IA64 00380 case V_BR_XEQ: return is_false ? "!XEQ" : "XEQ"; 00381 case V_BR_XNE: return is_false ? "!XNE" : "XNE"; 00382 case V_BR_XGT: return is_false ? "!XGT" : "XGT"; 00383 case V_BR_XGE: return is_false ? "!XGE" : "XGE"; 00384 case V_BR_XLT: return is_false ? "!XLT" : "XLT"; 00385 case V_BR_XLE: return is_false ? "!XLE" : "XLE"; 00386 #endif 00387 00388 case V_BR_QEQ: return is_false ? "!QEQ" : "QEQ"; 00389 case V_BR_QNE: return is_false ? "!QNE" : "QNE"; 00390 case V_BR_QGT: return is_false ? "!QGT" : "QGT"; 00391 case V_BR_QGE: return is_false ? "!QGE" : "QGE"; 00392 case V_BR_QLT: return is_false ? "!QLT" : "QLT"; 00393 case V_BR_QLE: return is_false ? "!QLE" : "QLE"; 00394 00395 case V_BR_I4EQ: return is_false ? "!I4EQ" : "I4EQ"; 00396 case V_BR_I4NE: return is_false ? "!I4NE" : "I4NE"; 00397 case V_BR_I4GT: return is_false ? "!I4GT" : "I4GT"; 00398 case V_BR_I4GE: return is_false ? "!I4GE" : "I4GE"; 00399 case V_BR_I4LT: return is_false ? "!I4LT" : "I4LT"; 00400 case V_BR_I4LE: return is_false ? "!I4LE" : "I4LE"; 00401 00402 case V_BR_U4EQ: return is_false ? "!U4EQ" : "U4EQ"; 00403 case V_BR_U4NE: return is_false ? "!U4NE" : "U4NE"; 00404 case V_BR_U4GT: return is_false ? "!U4GT" : "U4GT"; 00405 case V_BR_U4GE: return is_false ? "!U4GE" : "U4GE"; 00406 case V_BR_U4LT: return is_false ? "!U4LT" : "U4LT"; 00407 case V_BR_U4LE: return is_false ? "!U4LE" : "U4LE"; 00408 00409 case V_BR_F_FALSE: return is_false ? "!F_FALSE" : "F_FALSE"; 00410 case V_BR_F_TRUE: return is_false ? "!F_TRUE" : "F_TRUE"; 00411 00412 case V_BR_P_TRUE: return is_false ? "!P_TRUE" : "P_TRUE"; 00413 case V_BR_PEQ: return is_false ? "!PEQ" : "PEQ"; 00414 case V_BR_PNE: return is_false ? "!PNE" : "PNE"; 00415 00416 case V_BR_CLOOP: return is_false ? "!CLOOP" : "CLOOP"; 00417 case V_BR_CTOP: return is_false ? "!CTOP" : "CTOP"; 00418 case V_BR_CEXIT: return is_false ? "!CEXIT" : "CEXIT"; 00419 case V_BR_WTOP: return is_false ? "!WTOP" : "WTOP"; 00420 case V_BR_WEXIT: return is_false ? "!WEXIT" : "WEXIT"; 00421 00422 case V_BR_ALWAYS: return is_false ? "!ALWAYS" : "ALWAYS"; 00423 case V_BR_NEVER: return is_false ? "!NEVER" : "NEVER"; 00424 } 00425 00426 return "--UNKNOWN--"; 00427 }
1.5.6