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 #ifdef USE_PCH 00037 #include "lno_pch.h" 00038 #endif // USE_PCH 00039 #pragma hdrstop 00040 00041 #include "name.h" 00042 #include "ff_utils.h" 00043 #include "access_vector.h" 00044 #include "lnoutils.h" 00045 00046 static BOOL operator<(const SYMBOL& symb1, const SYMBOL& symb2) { 00047 00048 if (symb2.St() == NULL) return(FALSE); 00049 if (symb1.St() == NULL) return(TRUE); 00050 if (symb1.ST_Base() < symb2.ST_Base()) return(TRUE); 00051 else if (symb1.ST_Base() > symb2.ST_Base()) return(FALSE); 00052 else if (symb1.ST_Offset() < symb2.ST_Offset()) return(TRUE); 00053 else if (symb1.ST_Offset() > symb2.ST_Offset()) return(FALSE); 00054 else if (symb1.WN_Offset() < symb2.WN_Offset()) return(TRUE); 00055 else return(FALSE); 00056 00057 } 00058 00059 static BOOL operator<(const ACCESS_VECTOR& a1, const ACCESS_VECTOR& a2) 00060 { 00061 // TODO, support non linear symbols when they're implemented 00062 // note that the answer is true for both a1<a2 and a2<a1 if 00063 // both a1 and a2 are Too_Messy or having Non_Lin_Symb 00064 if (a1.Too_Messy || a1.Non_Lin_Symb) 00065 return TRUE; 00066 if (a2.Too_Messy || a2.Non_Lin_Symb) 00067 return FALSE; 00068 00069 if (a2.Too_Messy || a2.Non_Lin_Symb) { 00070 return FALSE; 00071 } 00072 00073 if (a1.Const_Offset < a2.Const_Offset) { 00074 return TRUE; 00075 } else if (a2.Const_Offset < a1.Const_Offset) { 00076 return FALSE; 00077 } 00078 if (a1.Nest_Depth() != a2.Nest_Depth()) { 00079 return (a1.Nest_Depth() < a2.Nest_Depth()); 00080 } 00081 for (INT i=0; i<a1.Nest_Depth(); i++) { 00082 if (a1.Loop_Coeff(i) < a2.Loop_Coeff(i)) { 00083 return TRUE; 00084 } else if (a2.Loop_Coeff(i) < a1.Loop_Coeff(i)) { 00085 return FALSE; 00086 } 00087 } 00088 00089 if (a1.Lin_Symb==NULL && a2.Lin_Symb==NULL) 00090 return FALSE; 00091 00092 INTSYMB_ITER iter1(a1.Lin_Symb); 00093 INTSYMB_ITER iter2(a2.Lin_Symb); 00094 INTSYMB_NODE *node1,*node2; 00095 for (node1=iter1.First(),node2 = iter2.First(); 00096 !iter1.Is_Empty() && !iter2.Is_Empty(); 00097 node1=iter1.Next(),node2=iter2.Next()) { 00098 if (node1->Symbol<node2->Symbol) { 00099 return TRUE; 00100 } else if (node1->Symbol<node2->Symbol) { 00101 return FALSE; 00102 } 00103 if (node1->Coeff < node2->Coeff) { 00104 return TRUE; 00105 } else if (node2->Coeff < node1->Coeff) { 00106 return FALSE; 00107 } 00108 } 00109 if (!iter2.Is_Empty()) return TRUE; 00110 else return FALSE; 00111 } 00112 00113 static BOOL operator<(const ACCESS_ARRAY& a1, const ACCESS_ARRAY& a2) 00114 { 00115 if (a1.Too_Messy) { 00116 if (a2.Too_Messy) { 00117 return (&a1 < &a2); 00118 } else { 00119 return TRUE; 00120 } 00121 } 00122 if (a2.Too_Messy) { 00123 return FALSE; 00124 } 00125 if (a1.Num_Vec() != a2.Num_Vec()) { 00126 return (a1.Num_Vec() < a2.Num_Vec()); 00127 } 00128 for (INT i=0; i<a1.Num_Vec(); i++) { 00129 if (*(a1.Dim(i))< *(a2.Dim(i))) { 00130 return TRUE; 00131 } else if (*(a2.Dim(i))< *(a1.Dim(i))) { 00132 return FALSE; 00133 } 00134 } 00135 return FALSE; 00136 } 00137 00138 BOOL NAME2BIT::operator <(const NAME2BIT &name2bit) const { 00139 00140 if (_symbol<name2bit._symbol) return(TRUE); 00141 else if (name2bit._symbol<_symbol) return(FALSE); 00142 00143 // now symbols are equivalent, check the access_arrays 00144 if (name2bit._access_array == NULL) return(FALSE); 00145 else if (_access_array == NULL) return(TRUE); 00146 else if ( *_access_array == *name2bit._access_array) return(FALSE); 00147 else if ( *_access_array < *name2bit._access_array) return(TRUE); 00148 else return(FALSE); 00149 } 00150 00151 BOOL NAME2BIT::operator ==(const NAME2BIT &name2bit) const { 00152 if (_symbol != name2bit._symbol) 00153 return(FALSE); 00154 else if (_access_array==NULL && name2bit._access_array==NULL) 00155 return(TRUE); 00156 else if (_access_array!=NULL && name2bit._access_array!=NULL) 00157 return(*_access_array == *name2bit._access_array); 00158 else return (FALSE); 00159 } 00160
1.5.6