00001
00002
00003
00004 #include "config.h"
00005 #include "system.h"
00006 #include "insn-config.h"
00007 #include "rtl.h"
00008 #include "tm_p.h"
00009 #include "regs.h"
00010 #include "output.h"
00011 #include "real.h"
00012 #include "recog.h"
00013 #include "except.h"
00014
00015 #include "function.h"
00016
00017 #ifdef HAVE_peephole
00018 extern rtx peep_operand[];
00019
00020 #define operands peep_operand
00021
00022 rtx
00023 peephole (ins1)
00024 rtx ins1;
00025 {
00026 rtx insn ATTRIBUTE_UNUSED, x ATTRIBUTE_UNUSED, pat ATTRIBUTE_UNUSED;
00027
00028 if (NEXT_INSN (ins1)
00029 && GET_CODE (NEXT_INSN (ins1)) == BARRIER)
00030 return 0;
00031
00032 insn = ins1;
00033 pat = PATTERN (insn);
00034 x = pat;
00035 if (GET_CODE (x) != SET) goto L529;
00036 x = XEXP (pat, 0);
00037 operands[0] = x;
00038 if (! register_operand (x, SImode)) goto L529;
00039 x = XEXP (pat, 1);
00040 operands[1] = x;
00041 if (! register_operand (x, SImode)) goto L529;
00042 do { insn = NEXT_INSN (insn);
00043 if (insn == 0) goto L529; }
00044 while (GET_CODE (insn) == NOTE
00045 || (GET_CODE (insn) == INSN
00046 && (GET_CODE (PATTERN (insn)) == USE
00047 || GET_CODE (PATTERN (insn)) == CLOBBER)));
00048 if (GET_CODE (insn) == CODE_LABEL
00049 || GET_CODE (insn) == BARRIER)
00050 goto L529;
00051 pat = PATTERN (insn);
00052 x = pat;
00053 if (GET_CODE (x) != SET) goto L529;
00054 x = XEXP (pat, 0);
00055 if (GET_CODE (x) != PC) goto L529;
00056 x = XEXP (pat, 1);
00057 if (GET_CODE (x) != IF_THEN_ELSE) goto L529;
00058 x = XEXP (XEXP (pat, 1), 0);
00059 operands[2] = x;
00060 if (! equality_op (x, SImode)) goto L529;
00061 x = XEXP (XEXP (XEXP (pat, 1), 0), 0);
00062 if (!rtx_equal_p (operands[0], x)) goto L529;
00063 x = XEXP (XEXP (XEXP (pat, 1), 0), 1);
00064 if (GET_CODE (x) != CONST_INT) goto L529;
00065 if (XWINT (x, 0) != 0) goto L529;
00066 x = XEXP (XEXP (pat, 1), 1);
00067 operands[3] = x;
00068 if (! pc_or_label_operand (x, VOIDmode)) goto L529;
00069 x = XEXP (XEXP (pat, 1), 2);
00070 operands[4] = x;
00071 if (! pc_or_label_operand (x, VOIDmode)) goto L529;
00072 if (! (TARGET_MIPS16
00073 && GET_CODE (operands[0]) == REG
00074 && REGNO (operands[0]) == 24
00075 && dead_or_set_p (insn, operands[0])
00076 && GET_CODE (operands[1]) == REG
00077 && M16_REG_P (REGNO (operands[1])))) goto L529;
00078 PATTERN (ins1) = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (5, operands));
00079 INSN_CODE (ins1) = 529;
00080 delete_for_peephole (NEXT_INSN (ins1), insn);
00081 return NEXT_INSN (insn);
00082 L529:
00083
00084 insn = ins1;
00085 pat = PATTERN (insn);
00086 x = pat;
00087 if (GET_CODE (x) != SET) goto L530;
00088 x = XEXP (pat, 0);
00089 operands[0] = x;
00090 if (! register_operand (x, DImode)) goto L530;
00091 x = XEXP (pat, 1);
00092 operands[1] = x;
00093 if (! register_operand (x, DImode)) goto L530;
00094 do { insn = NEXT_INSN (insn);
00095 if (insn == 0) goto L530; }
00096 while (GET_CODE (insn) == NOTE
00097 || (GET_CODE (insn) == INSN
00098 && (GET_CODE (PATTERN (insn)) == USE
00099 || GET_CODE (PATTERN (insn)) == CLOBBER)));
00100 if (GET_CODE (insn) == CODE_LABEL
00101 || GET_CODE (insn) == BARRIER)
00102 goto L530;
00103 pat = PATTERN (insn);
00104 x = pat;
00105 if (GET_CODE (x) != SET) goto L530;
00106 x = XEXP (pat, 0);
00107 if (GET_CODE (x) != PC) goto L530;
00108 x = XEXP (pat, 1);
00109 if (GET_CODE (x) != IF_THEN_ELSE) goto L530;
00110 x = XEXP (XEXP (pat, 1), 0);
00111 operands[2] = x;
00112 if (! equality_op (x, DImode)) goto L530;
00113 x = XEXP (XEXP (XEXP (pat, 1), 0), 0);
00114 if (!rtx_equal_p (operands[0], x)) goto L530;
00115 x = XEXP (XEXP (XEXP (pat, 1), 0), 1);
00116 if (GET_CODE (x) != CONST_INT) goto L530;
00117 if (XWINT (x, 0) != 0) goto L530;
00118 x = XEXP (XEXP (pat, 1), 1);
00119 operands[3] = x;
00120 if (! pc_or_label_operand (x, VOIDmode)) goto L530;
00121 x = XEXP (XEXP (pat, 1), 2);
00122 operands[4] = x;
00123 if (! pc_or_label_operand (x, VOIDmode)) goto L530;
00124 if (! (TARGET_MIPS16 && TARGET_64BIT
00125 && GET_CODE (operands[0]) == REG
00126 && REGNO (operands[0]) == 24
00127 && dead_or_set_p (insn, operands[0])
00128 && GET_CODE (operands[1]) == REG
00129 && M16_REG_P (REGNO (operands[1])))) goto L530;
00130 PATTERN (ins1) = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (5, operands));
00131 INSN_CODE (ins1) = 530;
00132 delete_for_peephole (NEXT_INSN (ins1), insn);
00133 return NEXT_INSN (insn);
00134 L530:
00135
00136 insn = ins1;
00137 pat = PATTERN (insn);
00138 x = pat;
00139 if (GET_CODE (x) != SET) goto L531;
00140 x = XEXP (pat, 0);
00141 operands[0] = x;
00142 if (! register_operand (x, SImode)) goto L531;
00143 x = XEXP (pat, 1);
00144 operands[1] = x;
00145 if (! register_operand (x, SImode)) goto L531;
00146 do { insn = NEXT_INSN (insn);
00147 if (insn == 0) goto L531; }
00148 while (GET_CODE (insn) == NOTE
00149 || (GET_CODE (insn) == INSN
00150 && (GET_CODE (PATTERN (insn)) == USE
00151 || GET_CODE (PATTERN (insn)) == CLOBBER)));
00152 if (GET_CODE (insn) == CODE_LABEL
00153 || GET_CODE (insn) == BARRIER)
00154 goto L531;
00155 pat = PATTERN (insn);
00156 x = pat;
00157 if (GET_CODE (x) != SET) goto L531;
00158 x = XEXP (pat, 0);
00159 if (GET_CODE (x) != PC) goto L531;
00160 x = XEXP (pat, 1);
00161 if (GET_CODE (x) != IF_THEN_ELSE) goto L531;
00162 x = XEXP (XEXP (pat, 1), 0);
00163 operands[2] = x;
00164 if (! equality_op (x, SImode)) goto L531;
00165 x = XEXP (XEXP (XEXP (pat, 1), 0), 0);
00166 if (!rtx_equal_p (operands[0], x)) goto L531;
00167 x = XEXP (XEXP (XEXP (pat, 1), 0), 1);
00168 if (GET_CODE (x) != CONST_INT) goto L531;
00169 if (XWINT (x, 0) != 0) goto L531;
00170 x = XEXP (XEXP (pat, 1), 1);
00171 operands[3] = x;
00172 if (! pc_or_label_operand (x, VOIDmode)) goto L531;
00173 x = XEXP (XEXP (pat, 1), 2);
00174 operands[4] = x;
00175 if (! pc_or_label_operand (x, VOIDmode)) goto L531;
00176 if (! (TARGET_MIPS16
00177 && GET_CODE (operands[1]) == REG
00178 && REGNO (operands[1]) == 24
00179 && GET_CODE (operands[0]) == REG
00180 && M16_REG_P (REGNO (operands[0]))
00181 && dead_or_set_p (insn, operands[0]))) goto L531;
00182 PATTERN (ins1) = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (5, operands));
00183 INSN_CODE (ins1) = 531;
00184 delete_for_peephole (NEXT_INSN (ins1), insn);
00185 return NEXT_INSN (insn);
00186 L531:
00187
00188 insn = ins1;
00189 pat = PATTERN (insn);
00190 x = pat;
00191 if (GET_CODE (x) != SET) goto L532;
00192 x = XEXP (pat, 0);
00193 operands[0] = x;
00194 if (! register_operand (x, DImode)) goto L532;
00195 x = XEXP (pat, 1);
00196 operands[1] = x;
00197 if (! register_operand (x, DImode)) goto L532;
00198 do { insn = NEXT_INSN (insn);
00199 if (insn == 0) goto L532; }
00200 while (GET_CODE (insn) == NOTE
00201 || (GET_CODE (insn) == INSN
00202 && (GET_CODE (PATTERN (insn)) == USE
00203 || GET_CODE (PATTERN (insn)) == CLOBBER)));
00204 if (GET_CODE (insn) == CODE_LABEL
00205 || GET_CODE (insn) == BARRIER)
00206 goto L532;
00207 pat = PATTERN (insn);
00208 x = pat;
00209 if (GET_CODE (x) != SET) goto L532;
00210 x = XEXP (pat, 0);
00211 if (GET_CODE (x) != PC) goto L532;
00212 x = XEXP (pat, 1);
00213 if (GET_CODE (x) != IF_THEN_ELSE) goto L532;
00214 x = XEXP (XEXP (pat, 1), 0);
00215 operands[2] = x;
00216 if (! equality_op (x, DImode)) goto L532;
00217 x = XEXP (XEXP (XEXP (pat, 1), 0), 0);
00218 if (!rtx_equal_p (operands[0], x)) goto L532;
00219 x = XEXP (XEXP (XEXP (pat, 1), 0), 1);
00220 if (GET_CODE (x) != CONST_INT) goto L532;
00221 if (XWINT (x, 0) != 0) goto L532;
00222 x = XEXP (XEXP (pat, 1), 1);
00223 operands[3] = x;
00224 if (! pc_or_label_operand (x, VOIDmode)) goto L532;
00225 x = XEXP (XEXP (pat, 1), 2);
00226 operands[4] = x;
00227 if (! pc_or_label_operand (x, VOIDmode)) goto L532;
00228 if (! (TARGET_MIPS16 && TARGET_64BIT
00229 && GET_CODE (operands[1]) == REG
00230 && REGNO (operands[1]) == 24
00231 && GET_CODE (operands[0]) == REG
00232 && M16_REG_P (REGNO (operands[0]))
00233 && dead_or_set_p (insn, operands[0]))) goto L532;
00234 PATTERN (ins1) = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (5, operands));
00235 INSN_CODE (ins1) = 532;
00236 delete_for_peephole (NEXT_INSN (ins1), insn);
00237 return NEXT_INSN (insn);
00238 L532:
00239
00240 return 0;
00241 }
00242
00243 rtx peep_operand[5];
00244 #endif