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 // -*-C++-*- 00037 // ==================================================================== 00038 // ==================================================================== 00039 // 00040 // Module: array_lower.cxx 00041 // $Revision$ 00042 // $Date$ 00043 // $Author$ 00044 // $Source$ 00045 // 00046 // Revision history: 00047 // dd-mmm-95 - Original Version 00048 // 00049 // Description: 00050 // 00051 // Lower all accesses to reshaped array variables. 00052 // 00053 // 00054 // Implementation Notes: 00055 // 00056 // During array lowering we need to generate divfloor, divceil and 00057 // modulus operations. Since all arrays always start at 0, the array 00058 // index functions are always positive. Also, the number of processors 00059 // and the block sizes are always positive. We use this information to 00060 // perform the following optimizations: 00061 // 00062 // divfloor(a,b) ==> a / b 00063 // divceil(a,b) ==> (a + b - 1) / b 00064 // mod(a,b) ==> rem(a,b) 00065 // 00066 // We can use either mod or rem for the modulus operation since they have 00067 // the same value when both operands are the same sign. 00068 // Since the global optimizer can optimize div and rem operations 00069 // on the same operands and only perform a single divide for both, we 00070 // generate rem operations. 00071 // 00072 // ==================================================================== 00073 // ==================================================================== 00074 // 00075 // TODO: 00076 // 00077 // o Try to form valid array expressions out of invalid ones by de-linearizing 00078 // o Can turn I/O statements IO_ITEMs of kind IOL_ARRAY into implied dos 00079 // 00080 // ==================================================================== 00081 00082 #ifdef USE_PCH 00083 #include "lno_pch.h" 00084 #endif // USE_PCH 00085 #pragma hdrstop 00086 00087 static const char *source_file = __FILE__; 00088 00089 #ifdef _KEEP_RCS_ID 00090 static char *rcs_id = "$Source$ $Revision$"; 00091 #endif /* _KEEP_RCS_ID */ 00092 00093 #include <sys/types.h> 00094 #include <ctype.h> 00095 #include <limits.h> 00096 #include <alloca.h> 00097 00098 #include "pu_info.h" 00099 #include "opt_du.h" 00100 #include "wn.h" 00101 #include "lego.h" 00102 #include "array_lower.h" 00103 #include "al_loop.h" 00104 00105 /* ======================================================================== 00106 Public Function Declarations 00107 ======================================================================== */ 00108 00109 extern void Lower_Array_Accesses(WN* func_nd); 00110 00111 /* ======================================================================== 00112 Public Function Implementations 00113 ======================================================================== */ 00114 00115 void 00116 Lower_Array_Accesses(WN *func_nd) 00117 { 00118 if (WN_operator(func_nd) != OPR_FUNC_ENTRY) { 00119 DevWarn ("Lower_Array_Accesses called with non-func node (opcode=%d)\n", 00120 WN_opcode(func_nd)); 00121 } 00122 00123 ARRAY_LOWER_LOOP *root_node = 00124 CXX_NEW(ARRAY_LOWER_LOOP(NULL, func_nd, -1), LEGO_pool); 00125 00126 root_node->Build_Loop(WN_func_body(func_nd)); 00127 root_node->Process_Loop(); 00128 00129 CXX_DELETE(root_node, LEGO_pool); 00130 }
1.5.6