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 #include <stdarg.h>
00061 #include "defs.h"
00062 #include "errors.h"
00063 #include "mempool.h"
00064 #include "wn.h"
00065 #include "opcode.h"
00066 #include "w2op.h"
00067 #include "cgir.h"
00068 #include "tn_map.h"
00069 #include "register.h"
00070 #include "op_list.h"
00071 #include "cg_loop.h"
00072 #include "config.h"
00073 #include "config_targ_opt.h"
00074 #include "cg.h"
00075 #include "tracing.h"
00076 #include "timing.h"
00077 #include "cgexp.h"
00078 #include "cgtarget.h"
00079
00080 #include "cio.h"
00081 #include "cio_rwtran.h"
00082 #include "cg_cflow.h"
00083 #include "resource.h"
00084 #include "cg_db_op.h"
00085 #include "cg_flags.h"
00086 #include "gtn_universe.h"
00087 #include "gtn_set.h"
00088 #include "bb_set.h"
00089 #include "dominate.h"
00090 #include "wn.h"
00091 #include "wn_map.h"
00092 #include "whirl2ops.h"
00093 #include "gra_live.h"
00094 #include "reg_live.h"
00095 #include "cflow.h"
00096 #include "findloops.h"
00097 #include "cg_loop.h"
00098 #include "cg_loop_scc.h"
00099 #include "cg_loop_mii.h"
00100 #include "cg_loop_recur.h"
00101 #include "findloops.h"
00102 #include "freq.h"
00103 #include "cg_sched_est.h"
00104 #include "label_util.h"
00105 #include "cg_swp.h"
00106 #include "cgprep.h"
00107 #include "cg_region.h"
00108
00109
00110 void CGPREP_Init_Op(OP * )
00111
00112
00113
00114
00115 {
00116
00117 }
00118
00119
00120 TN *CGPREP_Dup_TN(TN *old_tn)
00121
00122
00123
00124
00125 {
00126 if (TN_is_dedicated(old_tn)) return old_tn;
00127
00128 TN *new_tn = Dup_TN_Even_If_Dedicated(old_tn);
00129 if (TN_is_dedicated(old_tn)) {
00130 Set_TN_is_dedicated(new_tn);
00131 Set_TN_register_and_class(new_tn, TN_register_and_class(old_tn));
00132 }
00133 return new_tn;
00134 }
00135
00136
00137 static BOOL use_crosses_def(OP *op, UINT8 opnd)
00138
00139
00140
00141
00142
00143
00144
00145 {
00146 if (CG_DEP_Graph_Is_Cyclic(OP_bb(op))) {
00147 ARC *arc;
00148 if (OP_omega(op, opnd) > 1) return TRUE;
00149 if (arc = ARC_LIST_Find_First(OP_preds(op), CG_DEP_REGIN, opnd)) {
00150 OP *def = ARC_pred(arc);
00151 ARC_LIST *uses = ARC_LIST_Find(OP_succs(def), CG_DEP_REGIN, DONT_CARE);
00152 while (uses) {
00153 ARC *use = ARC_LIST_first(uses);
00154 UINT8 om = ARC_omega(use);
00155 if (om > 1 || om == 1 && OP_Precedes(def, ARC_succ(use)))
00156 return TRUE;
00157 uses = ARC_LIST_Find(ARC_LIST_rest(uses), CG_DEP_REGIN, DONT_CARE);
00158 }
00159 }
00160 }
00161 return FALSE;
00162 }
00163
00164 INT16 CGPREP_Same_Res_Opnd(OP *op)
00165
00166
00167
00168
00169 {
00170 TN *res = OP_result(op,0);
00171
00172 Is_True(OP_same_res(op), ("op not same-res OP"));
00173 Is_True(OP_results(op) == 1,
00174 ("OP_same_res OP has %d operands", OP_results(op)));
00175
00176
00177
00178
00179 if (OP_select(op)) {
00180 if (TNs_Are_Equivalent(res, OP_opnd(op,1)) && !use_crosses_def(op, 1))
00181 return 1;
00182 if (TNs_Are_Equivalent(res, OP_opnd(op,2)) && !use_crosses_def(op, 2))
00183 return 2;
00184 return -1;
00185 } else if (OP_unalign_ld(op)) {
00186 UINT8 which = OP_opnds(op)-1;
00187 if (!TN_is_zero_reg(OP_opnd(op, which)) &&
00188 TNs_Are_Equivalent(res, OP_opnd(op, which)))
00189 return which;
00190 }
00191
00192 return -1;
00193 }
00194
00195 void CGPREP_Copy_TN(TN *dest, TN *src, OP *point, UINT8 omega, BOOL before)
00196
00197
00198
00199
00200 {
00201 OPS ops = OPS_EMPTY;
00202 OP *op;
00203
00204 Exp_COPY(dest,src,&ops);
00205
00206 FOR_ALL_OPS_OPs(&ops, op) {
00207 CGPREP_Init_Op(op);
00208 if (omega > 0 || Is_CG_LOOP_Op(point)) {
00209 UINT8 opnd;
00210 CG_LOOP_Init_Op(op);
00211 for (opnd=0; opnd < OP_opnds(op); opnd++) {
00212 if (OP_opnd(op,opnd) == src)
00213 Set_OP_omega(op, opnd, omega);
00214 }
00215 }
00216 }
00217
00218 BB_Insert_Ops(OP_bb(point), point, &ops, before);
00219 }
00220
00221
00222 void CGPREP_Copy_TN_Into_BB(TN *dest, TN *src, BB *bb, OP *point, UINT8 omega,
00223 BOOL before)
00224
00225
00226
00227
00228 {
00229 OPS ops = OPS_EMPTY;
00230 OP *op;
00231
00232 FmtAssert(bb || point, ("called with BB *bb == NULL and OP *point == NULL"));
00233
00234 Exp_COPY(dest,src,&ops);
00235
00236 FOR_ALL_OPS_OPs(&ops, op) {
00237 CGPREP_Init_Op(op);
00238 if (omega > 0 || point && Is_CG_LOOP_Op(point) ||
00239 bb && BB_first_op(bb) && Is_CG_LOOP_Op(BB_first_op(bb))) {
00240 UINT8 opnd;
00241 CG_LOOP_Init_Op(op);
00242 for (opnd=0; opnd < OP_opnds(op); opnd++) {
00243 if (OP_opnd(op,opnd) == src)
00244 Set_OP_omega(op, opnd, omega);
00245 }
00246 }
00247 }
00248
00249 BB_Insert_Ops(bb, point, &ops, before);
00250 }
00251