00001 /* A few TImode functions needed for TFmode emulated arithmetic. 00002 Copyright 2002, 2003 Free Software Foundation, Inc. 00003 Contributed by Alexandre Oliva <aoliva@redhat.com> 00004 00005 This file is part of GCC. 00006 00007 GCC is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 2, or (at your option) 00010 any later version. 00011 00012 GCC is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with GCC; see the file COPYING. If not, write to 00019 the Free Software Foundation, 59 Temple Place - Suite 330, 00020 Boston, MA 02111-1307, USA. */ 00021 00022 00023 #include "tconfig.h" 00024 #include "coretypes.h" 00025 #include "tm.h" 00026 00027 #if _MIPS_SIM == _ABIN32 || _MIPS_SIM == _ABI64 00028 00029 typedef int TItype __attribute__ ((mode (TI))); 00030 typedef int DItype __attribute__ ((mode (DI))); 00031 typedef int SItype __attribute__ ((mode (SI))); 00032 00033 typedef unsigned int UDItype __attribute__ ((mode (DI))); 00034 00035 typedef union 00036 { 00037 struct TIstruct { 00038 #if LIBGCC2_WORDS_BIG_ENDIAN 00039 DItype high, low; 00040 #else 00041 DItype low, high; 00042 #endif 00043 } s; 00044 TItype ll; 00045 } TIunion; 00046 00047 TItype __negti2 (TItype); 00048 TItype __ashlti3 (TItype, int); 00049 #if 0 00050 TItype __ashrti3 (TItype, int); 00051 #endif 00052 TItype __lshrti3 (TItype, int); 00053 00054 TItype 00055 __negti2 (TItype u) 00056 { 00057 TIunion w; 00058 TIunion uu; 00059 00060 uu.ll = u; 00061 00062 w.s.low = -uu.s.low; 00063 w.s.high = -uu.s.high - ((UDItype) w.s.low > 0); 00064 00065 return w.ll; 00066 } 00067 00068 TItype 00069 __ashlti3 (TItype u, int b) 00070 { 00071 TIunion w; 00072 int bm; 00073 TIunion uu; 00074 00075 if (b == 0) 00076 return u; 00077 00078 uu.ll = u; 00079 00080 bm = (sizeof (DItype) * BITS_PER_UNIT) - b; 00081 if (bm <= 0) 00082 { 00083 w.s.low = 0; 00084 w.s.high = (UDItype) uu.s.low << -bm; 00085 } 00086 else 00087 { 00088 UDItype carries = (UDItype) uu.s.low >> bm; 00089 00090 w.s.low = (UDItype) uu.s.low << b; 00091 w.s.high = ((UDItype) uu.s.high << b) | carries; 00092 } 00093 00094 return w.ll; 00095 } 00096 00097 #if 0 00098 TItype 00099 __ashrti3 (TItype u, int b) 00100 { 00101 TIunion w; 00102 int bm; 00103 TIunion uu; 00104 00105 if (b == 0) 00106 return u; 00107 00108 uu.ll = u; 00109 00110 bm = (sizeof (DItype) * BITS_PER_UNIT) - b; 00111 if (bm <= 0) 00112 { 00113 /* w.s.high = 1..1 or 0..0 */ 00114 w.s.high = uu.s.high >> (sizeof (DItype) * BITS_PER_UNIT - 1); 00115 w.s.low = uu.s.high >> -bm; 00116 } 00117 else 00118 { 00119 UDItype carries = (UDItype) uu.s.high << bm; 00120 00121 w.s.high = uu.s.high >> b; 00122 w.s.low = ((UDItype) uu.s.low >> b) | carries; 00123 } 00124 00125 return w.ll; 00126 } 00127 #endif 00128 00129 TItype 00130 __lshrti3 (TItype u, int b) 00131 { 00132 TIunion w; 00133 int bm; 00134 TIunion uu; 00135 00136 if (b == 0) 00137 return u; 00138 00139 uu.ll = u; 00140 00141 bm = (sizeof (DItype) * BITS_PER_UNIT) - b; 00142 if (bm <= 0) 00143 { 00144 w.s.high = 0; 00145 w.s.low = (UDItype) uu.s.high >> -bm; 00146 } 00147 else 00148 { 00149 UDItype carries = (UDItype) uu.s.high << bm; 00150 00151 w.s.high = (UDItype) uu.s.high >> b; 00152 w.s.low = ((UDItype) uu.s.low >> b) | carries; 00153 } 00154 00155 return w.ll; 00156 } 00157 00158 #endif /* N32 or N64 */
1.5.6