00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00105 #ifndef RED_RCS_ID
00106 #define RED_RCS_ID
00107 #ifdef _KEEP_RCS_ID
00108 static char *reduc_rcs_id = "$Source$ $Revision$";
00109 #endif
00110 #endif
00111
00112 #ifndef wn_INCLUDED
00113 #include "wn.h"
00114 #endif
00115 #ifndef cxx_memory_INCLUDED
00116 #include "cxx_memory.h"
00117 #endif
00118 #ifndef opcode_INCLUDED
00119 #include "opcode.h"
00120 #endif
00121 #ifndef reduction_INCLUDED
00122 #include "reduction.h"
00123 #endif
00124
00125 #ifndef REDUC_DECLARE
00126 #define REDUC_DECLARE
00127
00128 extern OPERATOR REDUCTION_TYPE_to_OPERATOR(REDUCTION_TYPE red_type);
00129
00130 class REDUCTION_MANAGER {
00131 WN_MAP _map;
00132 MEM_POOL *_pool;
00133 class ARRAY_DIRECTED_GRAPH16 *_dep_graph;
00134 BOOL _build_scalar;
00135 BOOL _build_array;
00136 public:
00137 REDUCTION_MANAGER(MEM_POOL *pool) {
00138 _dep_graph = NULL;
00139 _pool = pool;
00140 _map = WN_MAP32_Create(_pool);
00141 FmtAssert(_map != -1,("Ran out of mappings in REDUCTION_MANAGER"));
00142 }
00143 ~REDUCTION_MANAGER() {
00144 WN_MAP_Delete(_map);
00145 }
00146
00147 REDUCTION_TYPE Which_Reduction(WN *wn) {
00148 return (REDUCTION_TYPE) WN_MAP32_Get(_map,wn);
00149 };
00150 void Build(WN *wn, BOOL build_scalar, BOOL build_array,
00151 class ARRAY_DIRECTED_GRAPH16 *dep_graph=0);
00152 void Erase(WN *wn);
00153 void Erase_Node(WN *wn);
00154 void Unroll_Update(WN **bodies, UINT u);
00155 void Unroll_Update_Rec(WN **bodies, UINT u);
00156 void Add_Reduction(WN* wn, REDUCTION_TYPE red_type) {
00157 WN_MAP32_Set(_map, wn, red_type);
00158 };
00159 private:
00160 BOOL Opcode_Match(OPCODE op1, OPCODE op2) {
00161 if (op1 == op2) return TRUE;
00162 if (OPCODE_rtype(op1) != OPCODE_rtype(op2)) return FALSE;
00163 if (OPCODE_desc(op1) != OPCODE_desc(op2)) return FALSE;
00164 OPERATOR opr1 = OPCODE_operator(op1);
00165 OPERATOR opr2 = OPCODE_operator(op2);
00166 if ((opr1 == OPR_ADD) && (opr2 == OPR_SUB)) return TRUE;
00167 if ((opr2 == OPR_ADD) && (opr1 == OPR_SUB)) return TRUE;
00168 return FALSE;
00169 }
00170 void Build(WN *wn);
00171 void Check_Store(WN *store);
00172 BOOL Match(WN *store, WN *value) const;
00173 BOOL Equiv(WN *wn1, WN *wn2) const;
00174 BOOL Self_Dependent_Store(WN *store) const;
00175 BOOL Unmapped_Vertices(WN *wn) const;
00176 BOOL Is_Descendent_Of_Store_Address(WN *store,WN *wn) const;
00177 WN *Find_Match(WN *store,OPCODE rhs_opcode, WN *rhs);
00178 };
00179
00180
00181
00182 #endif // REDUC_DECLARE
00183