hppa.pat.m

Go to the documentation of this file.
00001 /*==============================================
00002  * FILE:      hppa.pat.m
00003  * OVERVIEW:  Generated file; do not edit
00004  *==============================================*/
00005 
00006 #include "global.h"
00007 #include "decoder.h"
00008 #include "hppa.pat.h"
00009 #include "ss.h"
00010 #include "csr.h"
00011 
00012 #define VAR true
00013 #define VAL false
00014 int InstructionPatterns::R0 = 0;
00015 int InstructionPatterns::RP = 2;
00016 int InstructionPatterns::SP = 30;
00017 int InstructionPatterns::R31 = 31;
00018 bool InstructionPatterns::BL$c_br_nnull(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR) {
00019     ADDRESS nextPC;
00020     match  lc to
00021     | BL(_a, _b, _c) =>
00022         if (!c_br_nnull(_a)) return false;
00023         if (!a_isVAR && (int)_b != a) return false; else a = _b;
00024         if (!b_isVAR && (int)_c != b) return false; else b = _c;
00025         lc = nextPC;
00026         return true;
00027     else
00028         return false;
00029     endmatch
00030 }
00031 bool InstructionPatterns::BL$c_br_null(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR) {
00032     ADDRESS nextPC;
00033     match  lc to
00034     | BL(_a, _b, _c) =>
00035         if (!c_br_null(_a)) return false;
00036         if (!a_isVAR && (int)_b != a) return false; else a = _b;
00037         if (!b_isVAR && (int)_c != b) return false; else b = _c;
00038         lc = nextPC;
00039         return true;
00040     else
00041         return false;
00042     endmatch
00043 }
00044 bool InstructionPatterns::BV$c_br_nnull(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR) {
00045     ADDRESS nextPC;
00046     match  lc to
00047     | BV(_a, _b, _c) =>
00048         if (!c_br_nnull(_a)) return false;
00049         if (!a_isVAR && (int)_b != a) return false; else a = _b;
00050         if (!b_isVAR && (int)_c != b) return false; else b = _c;
00051         lc = nextPC;
00052         return true;
00053     else
00054         return false;
00055     endmatch
00056 }
00057 bool InstructionPatterns::BV$c_br_null(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR) {
00058     ADDRESS nextPC;
00059     match  lc to
00060     | BV(_a, _b, _c) =>
00061         if (!c_br_null(_a)) return false;
00062         if (!a_isVAR && (int)_b != a) return false; else a = _b;
00063         if (!b_isVAR && (int)_c != b) return false; else b = _c;
00064         lc = nextPC;
00065         return true;
00066     else
00067         return false;
00068     endmatch
00069 }
00070 bool InstructionPatterns::FSTDS$s_addr_im_r$c_s_addr_ma(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR, int& d, bool d_isVAR) {
00071     ADDRESS nextPC;
00072     match  lc to
00073     | FSTDS(_a, _b, _c, _d, _e) =>
00074         if (!c_s_addr_ma(_a)) return false;
00075         if (!a_isVAR && (int)_b != a) return false; else a = _b;
00076         if (!s_addr_im_r$c_s_addr_ma(_c, b, b_isVAR)) return false;
00077         if (!c_isVAR && (int)_d != c) return false; else c = _d;
00078         if (!d_isVAR && (int)_e != d) return false; else d = _e;
00079         lc = nextPC;
00080         return true;
00081     else
00082         return false;
00083     endmatch
00084 }
00085 bool InstructionPatterns::LDO(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR) {
00086     ADDRESS nextPC;
00087     match  lc to
00088     | LDO(_a, _b, _c) =>
00089         if (!a_isVAR && (int)_a != a) return false; else a = _a;
00090         if (!b_isVAR && (int)_b != b) return false; else b = _b;
00091         if (!c_isVAR && (int)_c != c) return false; else c = _c;
00092         lc = nextPC;
00093         return true;
00094     else
00095         return false;
00096     endmatch
00097 }
00098 bool InstructionPatterns::LDW$l_addr_16_old$c_l_addr_none(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR, int& d, bool d_isVAR) {
00099     ADDRESS nextPC;
00100     match  lc to
00101     | LDW(_a, _b, _c, _d, _e) =>
00102         if (!c_l_addr_none(_a)) return false;
00103         if (!l_addr_16_old$c_l_addr_none(_b, a, a_isVAR)) return false;
00104         if (!b_isVAR && (int)_c != b) return false; else b = _c;
00105         if (!c_isVAR && (int)_d != c) return false; else c = _d;
00106         if (!d_isVAR && (int)_e != d) return false; else d = _e;
00107         lc = nextPC;
00108         return true;
00109     else
00110         return false;
00111     endmatch
00112 }
00113 bool InstructionPatterns::LDWM$l_addr_16_old$c_l_addr_none(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR, int& d, bool d_isVAR) {
00114     ADDRESS nextPC;
00115     match  lc to
00116     | LDWM(_a, _b, _c, _d, _e) =>
00117         if (!c_l_addr_none(_a)) return false;
00118         if (!l_addr_16_old$c_l_addr_none(_b, a, a_isVAR)) return false;
00119         if (!b_isVAR && (int)_c != b) return false; else b = _c;
00120         if (!c_isVAR && (int)_d != c) return false; else c = _d;
00121         if (!d_isVAR && (int)_e != d) return false; else d = _e;
00122         lc = nextPC;
00123         return true;
00124     else
00125         return false;
00126     endmatch
00127 }
00128 bool InstructionPatterns::LDWS$s_addr_im_r$c_s_addr_mb(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR, int& d, bool d_isVAR) {
00129     ADDRESS nextPC;
00130     match  lc to
00131     | LDWS(_a, _b, _c, _d, _e) =>
00132         if (!c_s_addr_mb(_a)) return false;
00133         if (!s_addr_im_r$c_s_addr_mb(_b, a, a_isVAR)) return false;
00134         if (!b_isVAR && (int)_c != b) return false; else b = _c;
00135         if (!c_isVAR && (int)_d != c) return false; else c = _d;
00136         if (!d_isVAR && (int)_e != d) return false; else d = _e;
00137         lc = nextPC;
00138         return true;
00139     else
00140         return false;
00141     endmatch
00142 }
00143 bool InstructionPatterns::LDWS$s_addr_im_r$c_s_addr_notm(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR, int& d, bool d_isVAR) {
00144     ADDRESS nextPC;
00145     match  lc to
00146     | LDWS(_a, _b, _c, _d, _e) =>
00147         if (!c_s_addr_notm(_a)) return false;
00148         if (!s_addr_im_r$c_s_addr_notm(_b, a, a_isVAR)) return false;
00149         if (!b_isVAR && (int)_c != b) return false; else b = _c;
00150         if (!c_isVAR && (int)_d != c) return false; else c = _d;
00151         if (!d_isVAR && (int)_e != d) return false; else d = _e;
00152         lc = nextPC;
00153         return true;
00154     else
00155         return false;
00156     endmatch
00157 }
00158 bool InstructionPatterns::OR$c_arith_w$c_c_nonneg(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR, int& d, bool d_isVAR) {
00159     ADDRESS nextPC;
00160     match  lc to
00161     | OR(_a, _b, _c, _d) =>
00162         if (!c_arith_w$c_c_nonneg(_a, a, a_isVAR)) return false;
00163         if (!b_isVAR && (int)_b != b) return false; else b = _b;
00164         if (!c_isVAR && (int)_c != c) return false; else c = _c;
00165         if (!d_isVAR && (int)_d != d) return false; else d = _d;
00166         lc = nextPC;
00167         return true;
00168     else
00169         return false;
00170     endmatch
00171 }
00172 bool InstructionPatterns::STW$l_addr_16_old$c_l_addr_none(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR, int& d, bool d_isVAR) {
00173     ADDRESS nextPC;
00174     match  lc to
00175     | STW(_a, _b, _c, _d, _e) =>
00176         if (!c_l_addr_none(_a)) return false;
00177         if (!a_isVAR && (int)_b != a) return false; else a = _b;
00178         if (!l_addr_16_old$c_l_addr_none(_c, b, b_isVAR)) return false;
00179         if (!c_isVAR && (int)_d != c) return false; else c = _d;
00180         if (!d_isVAR && (int)_e != d) return false; else d = _e;
00181         lc = nextPC;
00182         return true;
00183     else
00184         return false;
00185     endmatch
00186 }
00187 bool InstructionPatterns::STWM$l_addr_16_old$c_l_addr_none(ADDRESS& lc, int& a, bool a_isVAR, int& b, bool b_isVAR, int& c, bool c_isVAR, int& d, bool d_isVAR) {
00188     ADDRESS nextPC;
00189     match  lc to
00190     | STWM(_a, _b, _c, _d, _e) =>
00191         if (!c_l_addr_none(_a)) return false;
00192         if (!a_isVAR && (int)_b != a) return false; else a = _b;
00193         if (!l_addr_16_old$c_l_addr_none(_c, b, b_isVAR)) return false;
00194         if (!c_isVAR && (int)_d != c) return false; else c = _d;
00195         if (!d_isVAR && (int)_e != d) return false; else d = _e;
00196         lc = nextPC;
00197         return true;
00198     else
00199         return false;
00200     endmatch
00201 }
00202 bool InstructionPatterns::c_arith_w$c_c_nonneg(ADDRESS& lc, int& a, bool a_isVAR) {
00203     match lc to
00204     | c_arith_w(_a, _b) =>
00205         if (!a_isVAR && (int)_a != a) return false; else a = _a;
00206         if (!c_c_nonneg(_b)) return false;
00207         return true;
00208     else
00209         return false;
00210     endmatch
00211 }
00212 bool InstructionPatterns::c_br_nnull(ADDRESS& lc) {
00213     match lc to
00214     | c_br_nnull() =>
00215         return true;
00216     else
00217         return false;
00218     endmatch
00219 }
00220 bool InstructionPatterns::c_br_null(ADDRESS& lc) {
00221     match lc to
00222     | c_br_null() =>
00223         return true;
00224     else
00225         return false;
00226     endmatch
00227 }
00228 bool InstructionPatterns::c_c_nonneg(ADDRESS& lc) {
00229     match lc to
00230     | c_c_nonneg() =>
00231         return true;
00232     else
00233         return false;
00234     endmatch
00235 }
00236 bool InstructionPatterns::c_l_addr_none(ADDRESS& lc) {
00237     match lc to
00238     | c_l_addr_none() =>
00239         return true;
00240     else
00241         return false;
00242     endmatch
00243 }
00244 bool InstructionPatterns::c_s_addr_ma(ADDRESS& lc) {
00245     match lc to
00246     | c_s_addr_ma() =>
00247         return true;
00248     else
00249         return false;
00250     endmatch
00251 }
00252 bool InstructionPatterns::c_s_addr_mb(ADDRESS& lc) {
00253     match lc to
00254     | c_s_addr_mb() =>
00255         return true;
00256     else
00257         return false;
00258     endmatch
00259 }
00260 bool InstructionPatterns::c_s_addr_notm(ADDRESS& lc) {
00261     match lc to
00262     | c_s_addr_notm() =>
00263         return true;
00264     else
00265         return false;
00266     endmatch
00267 }
00268 bool InstructionPatterns::l_addr_16_old$c_l_addr_none(ADDRESS& lc, int& a, bool a_isVAR) {
00269     match lc to
00270     | l_addr_16_old(_a) =>
00271         if (!a_isVAR && (int)_a != a) return false; else a = _a;
00272         return true;
00273     else
00274         return false;
00275     endmatch
00276 }
00277 bool InstructionPatterns::s_addr_im_r$c_s_addr_ma(ADDRESS& lc, int& a, bool a_isVAR) {
00278     match lc to
00279     | s_addr_im_r(_a) =>
00280         if (!a_isVAR && (int)_a != a) return false; else a = _a;
00281         return true;
00282     else
00283         return false;
00284     endmatch
00285 }
00286 bool InstructionPatterns::s_addr_im_r$c_s_addr_mb(ADDRESS& lc, int& a, bool a_isVAR) {
00287     match lc to
00288     | s_addr_im_r(_a) =>
00289         if (!a_isVAR && (int)_a != a) return false; else a = _a;
00290         return true;
00291     else
00292         return false;
00293     endmatch
00294 }
00295 bool InstructionPatterns::s_addr_im_r$c_s_addr_notm(ADDRESS& lc, int& a, bool a_isVAR) {
00296     match lc to
00297     | s_addr_im_r(_a) =>
00298         if (!a_isVAR && (int)_a != a) return false; else a = _a;
00299         return true;
00300     else
00301         return false;
00302     endmatch
00303 }
00304 Logue* InstructionPatterns::std_call(CSR& csr, ADDRESS& lc, int& addr)
00305 {
00306     ADDRESS __save = lc;
00307     if (
00308     BL$c_br_nnull(lc, addr, VAR, RP, VAL)) {
00309         vector<int> params(1); params = addr; 
00310         if (__save == lc) return NULL;
00311         return csr.instantiateLogue("std_call",params);
00312     } else {
00313         lc = __save;
00314         return NULL;
00315     }
00316 }
00317 Logue* InstructionPatterns::gcc_frame(CSR& csr, ADDRESS& lc, int& locals)
00318 {
00319     ADDRESS __save = lc;
00320     int __loc0;
00321     int __loc1;
00322     int __loc2;
00323     int __loc3;
00324     if (
00325     STW$l_addr_16_old$c_l_addr_none(lc, RP, VAL, __loc0 = -20, VAL, __loc1 = 0, VAL, SP, VAL) && 
00326     OR$c_arith_w$c_c_nonneg(lc, __loc0 = 0, VAL, __loc1 = 3, VAL, __loc2 = 0, VAL, __loc3 = 1, VAL) && 
00327     OR$c_arith_w$c_c_nonneg(lc, __loc0 = 0, VAL, SP, VAL, __loc1 = 0, VAL, __loc2 = 3, VAL) && 
00328     STWM$l_addr_16_old$c_l_addr_none(lc, __loc0 = 1, VAL, locals, VAR, __loc1 = 0, VAL, SP, VAL) && 
00329     ((STW$l_addr_16_old$c_l_addr_none(lc, __loc0 = 4, VAL, __loc1 = 8, VAL, __loc2 = 0, VAL, __loc3 = 3, VAL)) || true)) {
00330         vector<int> params(1); params = locals; 
00331         if (__save == lc) return NULL;
00332         return csr.instantiateLogue("gcc_frame",params);
00333     } else {
00334         lc = __save;
00335         return NULL;
00336     }
00337 }
00338 Logue* InstructionPatterns::gcc_frameless(CSR& csr, ADDRESS& lc, int& locals)
00339 {
00340     ADDRESS __save = lc;
00341     int __loc0;
00342     int __loc1;
00343     int __loc2;
00344     if (
00345     STW$l_addr_16_old$c_l_addr_none(lc, RP, VAL, __loc0 = -20, VAL, __loc1 = 0, VAL, SP, VAL) && 
00346     (LDO(lc, locals, VAR, SP, VAL, SP, VAL) || 
00347     STWM$l_addr_16_old$c_l_addr_none(lc, __loc0, VAR, locals, VAR, __loc1 = 0, VAL, SP, VAL)) && 
00348     ((STW$l_addr_16_old$c_l_addr_none(lc, __loc0, VAR, __loc1, VAR, __loc2 = 0, VAL, SP, VAL)) || true)) {
00349         vector<int> params(1); params = locals; 
00350         if (__save == lc) return NULL;
00351         return csr.instantiateLogue("gcc_frameless",params);
00352     } else {
00353         lc = __save;
00354         return NULL;
00355     }
00356 }
00357 Logue* InstructionPatterns::param_reloc1(CSR& csr, ADDRESS& lc, int& libstub, int& locals)
00358 {
00359     ADDRESS __save = lc;
00360     int __loc0;
00361     int __loc1;
00362     int __loc2;
00363     if (
00364     FSTDS$s_addr_im_r$c_s_addr_ma(lc, __loc0 = 7, VAL, __loc1 = 8, VAL, __loc2 = 0, VAL, SP, VAL) && 
00365     LDWS$s_addr_im_r$c_s_addr_notm(lc, __loc0 = -4, VAL, __loc1 = 0, VAL, SP, VAL, __loc2 = 24, VAL) && 
00366     LDWS$s_addr_im_r$c_s_addr_mb(lc, __loc0 = -8, VAL, __loc1 = 0, VAL, SP, VAL, __loc2 = 23, VAL) && 
00367     BL$c_br_null(lc, libstub, VAR, __loc0 = 0, VAL)) {
00368         vector<int> params(2); params = libstub; params = locals; 
00369         if (__save == lc) return NULL;
00370         return csr.instantiateLogue("param_reloc1",params);
00371     } else {
00372         lc = __save;
00373         return NULL;
00374     }
00375 }
00376 Logue* InstructionPatterns::gcc_unframe(CSR& csr, ADDRESS& lc)
00377 {
00378     ADDRESS __save = lc;
00379     int __loc0;
00380     int __loc1;
00381     int __loc2;
00382     int __loc3;
00383     if (
00384     ((LDW$l_addr_16_old$c_l_addr_none(lc, __loc0 = -20, VAL, __loc1 = 0, VAL, __loc2 = 3, VAL, RP, VAL)) || true) && 
00385     ((LDW$l_addr_16_old$c_l_addr_none(lc, __loc0 = 8, VAL, __loc1 = 0, VAL, __loc2 = 3, VAL, __loc3 = 4, VAL)) || true) && 
00386     LDO(lc, __loc0, VAR, __loc1 = 3, VAL, SP, VAL) && 
00387     LDWM$l_addr_16_old$c_l_addr_none(lc, __loc0, VAR, __loc1 = 0, VAL, SP, VAL, __loc2 = 3, VAL) && 
00388     BV$c_br_null(lc, R0, VAL, RP, VAL)) {
00389         vector<int> params(0); 
00390         if (__save == lc) return NULL;
00391         return csr.instantiateLogue("gcc_unframe",params);
00392     } else {
00393         lc = __save;
00394         return NULL;
00395     }
00396 }
00397 Logue* InstructionPatterns::gcc_unframeless1(CSR& csr, ADDRESS& lc)
00398 {
00399     ADDRESS __save = lc;
00400     int __loc0;
00401     int __loc1;
00402     int __loc2;
00403     if (
00404     ((LDW$l_addr_16_old$c_l_addr_none(lc, __loc0, VAR, __loc1 = 0, VAL, SP, VAL, RP, VAL)) || true) && 
00405     ((LDW$l_addr_16_old$c_l_addr_none(lc, __loc0, VAR, __loc1 = 0, VAL, SP, VAL, __loc2, VAR)) || true) && 
00406     BV$c_br_nnull(lc, R0, VAL, RP, VAL) && 
00407     LDWM$l_addr_16_old$c_l_addr_none(lc, __loc0, VAR, __loc1 = 0, VAL, SP, VAL, __loc2, VAR)) {
00408         vector<int> params(0); 
00409         if (__save == lc) return NULL;
00410         return csr.instantiateLogue("gcc_unframeless1",params);
00411     } else {
00412         lc = __save;
00413         return NULL;
00414     }
00415 }
00416 Logue* InstructionPatterns::gcc_unframeless2(CSR& csr, ADDRESS& lc)
00417 {
00418     ADDRESS __save = lc;
00419     int __loc0;
00420     int __loc1;
00421     int __loc2;
00422     if (
00423     ((LDW$l_addr_16_old$c_l_addr_none(lc, __loc0, VAR, __loc1 = 0, VAL, SP, VAL, __loc2 = 4, VAL)) || true) && 
00424     LDW$l_addr_16_old$c_l_addr_none(lc, __loc0, VAR, __loc1 = 0, VAL, SP, VAL, __loc2 = 3, VAL) && 
00425     BV$c_br_nnull(lc, R0, VAL, RP, VAL) && 
00426     LDO(lc, __loc0, VAR, SP, VAL, SP, VAL)) {
00427         vector<int> params(0); 
00428         if (__save == lc) return NULL;
00429         return csr.instantiateLogue("gcc_unframeless2",params);
00430     } else {
00431         lc = __save;
00432         return NULL;
00433     }
00434 }
00435 Logue* InstructionPatterns::bare_ret(CSR& csr, ADDRESS& lc)
00436 {
00437     ADDRESS __save = lc;
00438     if (
00439     BV$c_br_nnull(lc, R0, VAL, RP, VAL)) {
00440         vector<int> params(0); 
00441         if (__save == lc) return NULL;
00442         return csr.instantiateLogue("bare_ret",params);
00443     } else {
00444         lc = __save;
00445         return NULL;
00446     }
00447 }
00448 Logue* InstructionPatterns::bare_ret_anulled(CSR& csr, ADDRESS& lc)
00449 {
00450     ADDRESS __save = lc;
00451     if (
00452     BV$c_br_null(lc, R0, VAL, RP, VAL)) {
00453         vector<int> params(0); 
00454         if (__save == lc) return NULL;
00455         return csr.instantiateLogue("bare_ret_anulled",params);
00456     } else {
00457         lc = __save;
00458         return NULL;
00459     }
00460 }
00461 LogueDict::LogueDict()
00462 {
00463     {
00464         list<string> params;
00465         params.push_back("addr");
00466         theSemTable.addItem("addr");
00467         this->newLogue("std_call","CALLER_PROLOGUE",params);
00468     }
00469     {
00470         list<string> params;
00471         params.push_back("locals");
00472         theSemTable.addItem("locals");
00473         this->newLogue("gcc_frame","CALLEE_PROLOGUE",params);
00474     }
00475     {
00476         list<string> params;
00477         params.push_back("locals");
00478         theSemTable.addItem("locals");
00479         this->newLogue("gcc_frameless","CALLEE_PROLOGUE",params);
00480     }
00481     {
00482         list<string> params;
00483         params.push_back("libstub");
00484         theSemTable.addItem("libstub");
00485         params.push_back("locals");
00486         theSemTable.addItem("locals");
00487         this->newLogue("param_reloc1","CALLEE_PROLOGUE",params);
00488     }
00489     {
00490         list<string> params;
00491         this->newLogue("gcc_unframe","CALLEE_EPILOGUE",params);
00492     }
00493     {
00494         list<string> params;
00495         this->newLogue("gcc_unframeless1","CALLEE_EPILOGUE",params);
00496     }
00497     {
00498         list<string> params;
00499         this->newLogue("gcc_unframeless2","CALLEE_EPILOGUE",params);
00500     }
00501     {
00502         list<string> params;
00503         this->newLogue("bare_ret","CALLEE_EPILOGUE",params);
00504     }
00505     {
00506         list<string> params;
00507         this->newLogue("bare_ret_anulled","CALLEE_EPILOGUE",params);
00508     }
00509 }

Generated on Tue Sep 19 21:18:24 2006 for Boomerang by  doxygen 1.4.6