00001 /* 00002 * Copyright 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2 of the GNU General Public License as 00011 published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with this program; if not, write the Free Software Foundation, Inc., 59 00026 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00027 00028 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00029 Mountain View, CA 94043, or: 00030 00031 http://www.sgi.com 00032 00033 For further information regarding this notice, see: 00034 00035 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00036 00037 */ 00038 00039 00040 #define __STDC_LIMIT_MACROS 00041 #include <stdint.h> 00042 #include <stdio.h> 00043 #include "soe.h" 00044 #include "wn.h" 00045 00046 #define F90_LOWER_INTERNAL 00047 #include "pu_info.h" 00048 #include "f90_lower.h" 00049 #include "ipa_lno_util.h" 00050 00051 // Needed to make MAT package work 00052 00053 template <> MEM_POOL* MAT<mINT32>::_default_pool = NULL; 00054 00055 00056 //---------------------------------------------------------------------------------- 00057 // 00058 // DIR_FLAG F90_Lower_Analyze_Triplet (INT64 l, INT64 s1, INT64 s2, INT64 e, BOOL e_present, MEM_POOL *mp) 00059 // 00060 // l - difference of lower bounds (LHS - RHS) 00061 // s1,s2 - strides for LHS and RHS respectively 00062 // e - extent of triplets 00063 // e_present - TRUE if E is present 00064 // mp - MEM_POOL to use as the working pool 00065 // 00066 // Solves the system: 00067 // l + s1 n1 = s2 n2 00068 // n1 >= 0, n2 >= 0 00069 // n1 < e, n2 < e (if e is known) 00070 // 00071 // To see if there are any solutions for n1, n2. 00072 // If there are no solutions, the triplets are DIR_DONTCARE 00073 // If there is solution, we add the constraints 00074 // n1 <= n2 and return DIR_POSITIVE if this causes it do be inconsisttent 00075 // n1 >= n2 and return DIR_NEGATIVE if this causes it do be inconsisttent 00076 // else return DIR_NEGATIVE 00077 // 00078 00079 DIR_FLAG F90_Lower_Analyze_Triplet (INT64 l, INT64 s1in, INT64 s2in, INT64 e, BOOL e_present, 00080 MEM_POOL *mp) 00081 { 00082 INT32 s1,s2; 00083 INT32 row[2]; 00084 SYSTEM_OF_EQUATIONS s(1,1,2,mp); 00085 00086 // make sure the s1 and s2 fit in 32 bits 00087 00088 s1 = s1in; 00089 s2 = s2in; 00090 if (s1 != s1in || s2 != s2in) return (DIR_UNKNOWN); 00091 00092 /* Enter the equality condition */ 00093 row[0] = s1; 00094 row[1] = -s2; 00095 s.Add_Eq(row,-l); 00096 00097 /* Enter the basic constraints */ 00098 row[0] = -1; 00099 row[1] = 0; 00100 s.Add_Le(row,0); 00101 row[0] = 0; 00102 row[1] = -1; 00103 s.Add_Le(row,0); 00104 00105 if (e_present) { 00106 /* Add constraints on E */ 00107 row[0] = 1; 00108 row[1] = 0; 00109 s.Add_Le(row,e-1); 00110 row[0] = 0; 00111 row[1] = 1; 00112 s.Add_Le(row,e-1); 00113 } 00114 00115 if (!s.Is_Consistent()) { 00116 // System is independent 00117 return (DIR_DONTCARE); 00118 } 00119 00120 /* Add constraint n1 <= n2 */ 00121 row[0] = 1; 00122 row[1] = -1; 00123 s.Add_Le(row,0); 00124 if (!s.Is_Consistent()) { 00125 return (DIR_POSITIVE); 00126 } 00127 00128 // replace constraint with one running in the other direction 00129 00130 s.Remove_Last_Le(); 00131 /* Add constraint n2 <= n1 */ 00132 row[0] = -1; 00133 row[1] = 1; 00134 s.Add_Le(row,0); 00135 00136 if (!s.Is_Consistent()) { 00137 return (DIR_NEGATIVE); 00138 } 00139 00140 // Unfortunately we have to give up 00141 return (DIR_UNKNOWN); 00142 }
1.5.6