sparcdecoder.cpp

Go to the documentation of this file.
00001 #define sign_extend(N,SIZE) (((int)((N) << (sizeof(unsigned)*8-(SIZE)))) >> (sizeof(unsigned)*8-(SIZE)))
00002 #include <assert.h>
00003 
00004 #line 0 "frontend/machine/sparc/decoder.m"
00005 /*
00006  * Copyright (C) 1996-2001, The University of Queensland
00007  *
00008  * See the file "LICENSE.TERMS" for information on usage and
00009  * redistribution of this file, and for a DISCLAIMER OF ALL
00010  * WARRANTIES.
00011  *
00012  */
00013 
00014 /*==============================================================================
00015  * FILE:       decoder.m
00016  * OVERVIEW:   Implementation of the SPARC specific parts of the
00017  *             SparcDecoder class.
00018  *============================================================================*/
00019 
00020 /* $Revision: 1.42 $    // 1.20.2.2
00021  *
00022  * 26 Apr 02 - Mike: Mods for boomerang
00023  * 19 May 02 - Mike: Added many (int) casts: variables from toolkit are unsgnd
00024  * 21 May 02 - Mike: SAVE and RESTORE have full semantics now
00025  * 30 Oct 02 - Mike: dis_Eaddr mode indirectA had extra memof
00026  * 22 Nov 02 - Mike: Support 32 bit V9 branches
00027  * 04 Dec 02 - Mike: r[0] -> 0 automatically (rhs only)
00028  * 30 May 02 - Mike: Also fixed r[0] -> 0 for store instructions
00029  * 03 Nov 04 - Mike: DIS_FDS was returning numbers for the double precision registers
00030 */
00031 
00032 /*==============================================================================
00033  * Dependencies.
00034  *============================================================================*/
00035 
00036 #include <assert.h>
00037 #if defined(_MSC_VER) && _MSC_VER <= 1100
00038 #include "signature.h"
00039 #endif
00040 
00041 #include "decoder.h"
00042 #include "exp.h"
00043 #include "prog.h"
00044 #include "proc.h"
00045 #include "sparcdecoder.h"
00046 #include "rtl.h"
00047 #include "BinaryFile.h"     // For SymbolByAddress()
00048 #include "boomerang.h"
00049 
00050 #define DIS_ROI     (dis_RegImm(roi))
00051 #define DIS_ADDR    (dis_Eaddr(addr))
00052 #define DIS_RD      (dis_RegLhs(rd))
00053 #define DIS_RDR     (dis_RegRhs(rd))
00054 #define DIS_RS1     (dis_RegRhs(rs1))
00055 #define DIS_FS1S    (dis_RegRhs(fs1s+32))
00056 #define DIS_FS2S    (dis_RegRhs(fs2s+32))
00057 // Note: Sparc V9 has a second set of double precision registers that have an
00058 // odd index. So far we only support V8
00059 #define DIS_FDS     (dis_RegLhs(fds+32))
00060 #define DIS_FS1D    (dis_RegRhs((fs1d>>1)+64))
00061 #define DIS_FS2D    (dis_RegRhs((fs2d>>1)+64))
00062 #define DIS_FDD     (dis_RegLhs((fdd>>1)+64))
00063 #define DIS_FDQ     (dis_RegLhs((fdq>>2)+80))
00064 #define DIS_FS1Q    (dis_RegRhs((fs1q>>2)+80))
00065 #define DIS_FS2Q    (dis_RegRhs((fs2q>>2)+80))
00066 
00067 /*==============================================================================
00068  * FUNCTION:       unused
00069  * OVERVIEW:       A dummy function to suppress "unused local variable" messages
00070  * PARAMETERS:     x: integer variable to be "used"
00071  * RETURNS:        Nothing
00072  *============================================================================*/
00073 void SparcDecoder::unused(int x)
00074 {}
00075 
00076 /*==============================================================================
00077  * FUNCTION:       createBranchRtl
00078  * OVERVIEW:       Create an RTL for a Bx instruction
00079  * PARAMETERS:     pc - the location counter
00080  *                 stmts - ptr to list of Statement pointers
00081  *                 name - instruction name (e.g. "BNE,a", or "BPNE")
00082  * RETURNS:        Pointer to newly created RTL, or NULL if invalid
00083  *============================================================================*/
00084 RTL* SparcDecoder::createBranchRtl(ADDRESS pc, std::list<Statement*>* stmts, const char* name) {
00085     RTL* res = new RTL(pc, stmts);
00086     BranchStatement* br = new BranchStatement();
00087     res->appendStmt(br);
00088     if (name[0] == 'F') {
00089         // fbranch is any of [ FBN FBNE FBLG FBUL FBL   FBUG FBG   FBU
00090         //                     FBA FBE  FBUE FBGE FBUGE FBLE FBULE FBO ],
00091         // fbranches are not the same as ibranches, so need a whole different set of tests
00092         if (name[2] == 'U')
00093             name++;             // Just ignore unordered (for now)
00094         switch (name[2]) {
00095         case 'E':                           // FBE
00096             br->setCondType(BRANCH_JE, true);
00097             break;
00098         case 'L':
00099             if (name[3] == 'G')             // FBLG
00100                 br->setCondType(BRANCH_JNE, true);
00101             else if (name[3] == 'E')        // FBLE
00102                 br->setCondType(BRANCH_JSLE, true);
00103             else                            // FBL
00104                 br->setCondType(BRANCH_JSL, true);
00105             break;
00106         case 'G':
00107             if (name[3] == 'E')             // FBGE
00108                 br->setCondType(BRANCH_JSGE, true);
00109             else                            // FBG
00110                 br->setCondType(BRANCH_JSG, true);
00111             break;
00112         case 'N':
00113             if (name[3] == 'E')             // FBNE
00114                 br->setCondType(BRANCH_JNE, true);
00115             // Else it's FBN!
00116             break;
00117         default:
00118             std::cerr << "unknown float branch " << name << std::endl;
00119             delete res;
00120             res = NULL;
00121         }
00122         return res;
00123     }   
00124 
00125     // ibranch is any of [ BN BE  BLE BL  BLEU BCS BNEG BVS
00126     //                     BA BNE BG  BGE BGU  BCC BPOS BVC ],
00127     // Note: BPN, BPE, etc handled below
00128     switch(name[1]) {
00129     case 'E':
00130         br->setCondType(BRANCH_JE);           // BE
00131         break;
00132     case 'L':
00133         if (name[2] == 'E') {
00134             if (name[3] == 'U')
00135                 br->setCondType(BRANCH_JULE); // BLEU
00136             else
00137                 br->setCondType(BRANCH_JSLE); // BLE
00138         }
00139         else
00140             br->setCondType(BRANCH_JSL);      // BL
00141         break;
00142     case 'N':
00143         // BNE, BNEG (won't see BN)
00144         if (name[3] == 'G')
00145             br->setCondType(BRANCH_JMI);      // BNEG
00146         else
00147             br->setCondType(BRANCH_JNE);      // BNE
00148         break;
00149     case 'C':
00150         // BCC, BCS
00151         if (name[2] == 'C')
00152             br->setCondType(BRANCH_JUGE);     // BCC
00153         else
00154             br->setCondType(BRANCH_JUL);      // BCS
00155         break;
00156     case 'V':
00157         // BVC, BVS; should never see these now
00158         if (name[2] == 'C')
00159             std::cerr << "Decoded BVC instruction\n";   // BVC
00160         else
00161             std::cerr << "Decoded BVS instruction\n";   // BVS
00162         break;
00163     case 'G':   
00164         // BGE, BG, BGU
00165         if (name[2] == 'E')
00166             br->setCondType(BRANCH_JSGE);     // BGE
00167         else if (name[2] == 'U')
00168             br->setCondType(BRANCH_JUG);      // BGU
00169         else
00170             br->setCondType(BRANCH_JSG);      // BG
00171         break;
00172     case 'P':   
00173         if (name[2] == 'O') {
00174             br->setCondType(BRANCH_JPOS);         // BPOS
00175             break;
00176         }
00177         // Else, it's a BPXX; remove the P (for predicted) and try again
00178         // (recurse)
00179         // B P P O S ...
00180         // 0 1 2 3 4 ...
00181         char temp[8];
00182         temp[0] = 'B';
00183         strcpy(temp+1, name+2);
00184         delete res;
00185         return createBranchRtl(pc, stmts, temp);
00186     default:
00187         std::cerr << "unknown non-float branch " << name << std::endl;
00188     }   
00189     return res;
00190 }
00191 
00192 
00193 /*==============================================================================
00194  * FUNCTION:       SparcDecoder::decodeInstruction
00195  * OVERVIEW:       Attempt to decode the high level instruction at a given address and return the corresponding HL type
00196  *                  (e.g. CallStatement, GotoStatement etc). If no high level instruction exists at the given address,
00197  *                  then simply return the RTL for the low level instruction at this address. There is an option to also
00198  *                 include the low level statements for a HL instruction.
00199  * PARAMETERS:     pc - the native address of the pc
00200  *                 delta - the difference between the above address and the host address of the pc (i.e. the address
00201  *                  that the pc is at in the loaded object file)
00202  *                 proc - the enclosing procedure. This can be NULL for those of us who are using this method in an
00203  *                  interpreter
00204  * RETURNS:        a DecodeResult structure containing all the information gathered during decoding
00205  *============================================================================*/
00206 DecodeResult& SparcDecoder::decodeInstruction (ADDRESS pc, int delta) { 
00207     static DecodeResult result;
00208     ADDRESS hostPC = pc+delta;
00209 
00210     // Clear the result structure;
00211     result.reset();
00212 
00213     // The actual list of instantiated statements
00214     std::list<Statement*>* stmts = NULL;
00215 
00216     ADDRESS nextPC = NO_ADDRESS;
00217 
00218 
00219 
00220 #line 212 "frontend/machine/sparc/decoder.m"
00221 { 
00222   dword MATCH_p = 
00223     
00224 #line 212 "frontend/machine/sparc/decoder.m"
00225     hostPC
00226     ;
00227   char *MATCH_name;
00228   static char *MATCH_name_cond_0[] = {
00229     "BPN", "BPE", "BPLE", "BPL", "BPLEU", "BPCS", "BPNEG", "BPVS", "BPA,a", 
00230     "BPNE", "BPG", "BPGE", "BPGU", "BPCC", "BPPOS", "BPVC", 
00231   };
00232   static char *MATCH_name_cond_1[] = {
00233     "BPN,a", "BPE,a", "BPLE,a", "BPL,a", "BPLEU,a", "BPCS,a", "BPNEG,a", 
00234     "BPVS,a", "BA", "BPNE,a", "BPG,a", "BPGE,a", "BPGU,a", "BPCC,a", 
00235     "BPPOS,a", "BPVC,a", 
00236   };
00237   static char *MATCH_name_cond_2[] = {
00238     "BN", "BE", "BLE", "BL", "BLEU", "BCS", "BNEG", "BVS", "BA,a", "BNE", 
00239     "BG", "BGE", "BGU", "BCC", "BPOS", "BVC", 
00240   };
00241   static char *MATCH_name_cond_3[] = {
00242     "BN,a", "BE,a", "BLE,a", "BL,a", "BLEU,a", "BCS,a", "BNEG,a", "BVS,a", 
00243     "FBA", "BNE,a", "BG,a", "BGE,a", "BGU,a", "BCC,a", "BPOS,a", "BVC,a", 
00244   };
00245   static char *MATCH_name_cond_5[] = {
00246     "FBN", "FBNE", "FBLG", "FBUL", "FBL", "FBUG", "FBG", "FBU", "FBA,a", 
00247     "FBE", "FBUE", "FBGE", "FBUGE", "FBLE", "FBULE", "FBO", 
00248   };
00249   static char *MATCH_name_cond_6[] = {
00250     "FBN,a", "FBNE,a", "FBLG,a", "FBUL,a", "FBL,a", "FBUG,a", "FBG,a", 
00251     "FBU,a", "CBA", "FBE,a", "FBUE,a", "FBGE,a", "FBUGE,a", "FBLE,a", 
00252     "FBULE,a", "FBO,a", 
00253   };
00254   static char *MATCH_name_cond_7[] = {
00255     "CBN", "CB123", "CB12", "CB13", "CB1", "CB23", "CB2", "CB3", "CBA,a", 
00256     "CB0", "CB03", "CB02", "CB023", "CB01", "CB013", "CB012", 
00257   };
00258   static char *MATCH_name_cond_8[] = {
00259     "CBN,a", "CB123,a", "CB12,a", "CB13,a", "CB1,a", "CB23,a", "CB2,a", 
00260     "CB3,a", "TA", "CB0,a", "CB03,a", "CB02,a", "CB023,a", "CB01,a", 
00261     "CB013,a", "CB012,a", 
00262   };
00263   static char *MATCH_name_op3_46[] = {
00264     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00265     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00266     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00267     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00268     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00269     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00270     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, "RDPSR", "RDWIM", 
00271     "RDTBR", 
00272   };
00273   static char *MATCH_name_opf_51[] = {
00274     (char *)0, "FMOVs", (char *)0, (char *)0, (char *)0, "FNEGs", (char *)0, 
00275     (char *)0, (char *)0, "FABSs", (char *)0, (char *)0, (char *)0, 
00276     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00277     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00278     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00279     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00280     (char *)0, (char *)0, (char *)0, (char *)0, "FSQRTs", "FSQRTd", "FSQRTq", 
00281     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00282     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00283     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00284     (char *)0, (char *)0, (char *)0, "FADDs", "FADDd", "FADDq", (char *)0, 
00285     "FSUBs", "FSUBd", "FSUBq", (char *)0, "FMULs", "FMULd", "FMULq", 
00286     (char *)0, "FDIVs", "FDIVd", "FDIVq", (char *)0, "FCMPs", "FCMPd", 
00287     "FCMPq", (char *)0, "FCMPEs", "FCMPEd", "FCMPEq", (char *)0, (char *)0, 
00288     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00289     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00290     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00291     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00292     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00293     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00294     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00295     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00296     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00297     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00298     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00299     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00300     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00301     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00302     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00303     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00304     (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, (char *)0, 
00305     (char *)0, (char *)0, (char *)0, (char *)0, "FiTOs", (char *)0, "FdTOs", 
00306     "FqTOs", "FiTOd", "FsTOd", (char *)0, "FqTOd", "FiTOq", "FsTOq", "FdTOq", 
00307     (char *)0, (char *)0, "FsTOi", "FdTOi", "FqTOi", 
00308   };
00309   static char *MATCH_name_cond_53[] = {
00310     "TN", "TE", "TLE", "TL", "TLEU", "TCS", "TNEG", "TVS", (char *)0, "TNE", 
00311     "TG", "TGE", "TGU", "TCC", "TPOS", "TVC", 
00312   };
00313   static char *MATCH_name_i_66[] = {"LDA", "LDF", };
00314   static char *MATCH_name_i_67[] = {"LDUBA", "LDFSR", };
00315   static char *MATCH_name_i_68[] = {"LDUHA", "LDDF", };
00316   static char *MATCH_name_i_69[] = {"LDDA", "STF", };
00317   static char *MATCH_name_i_70[] = {"STA", "STFSR", };
00318   static char *MATCH_name_i_71[] = {"STBA", "STDFQ", };
00319   static char *MATCH_name_i_72[] = {"STHA", "STDF", };
00320   static char *MATCH_name_i_73[] = {"STDA", "LDCSR", };
00321   static char *MATCH_name_i_74[] = {"LDSBA", "STCSR", };
00322   static char *MATCH_name_i_75[] = {"LDSHA", "STDCQ", };
00323   unsigned MATCH_w_32_0;
00324   { 
00325     MATCH_w_32_0 = getDword(MATCH_p); 
00326     
00327       switch((MATCH_w_32_0 >> 30 & 0x3) /* op at 0 */) {
00328         case 0: 
00329           
00330             switch((MATCH_w_32_0 >> 22 & 0x7) /* op2 at 0 */) {
00331               case 0: 
00332                 { 
00333                   unsigned n = (MATCH_w_32_0 & 0x3fffff) /* imm22 at 0 */;
00334                   nextPC = 4 + MATCH_p; 
00335                   
00336 #line 629 "frontend/machine/sparc/decoder.m"
00337                    
00338 
00339                         unused(n);
00340 
00341                         stmts = NULL;
00342 
00343                         result.valid = false;
00344 
00345                   
00346 
00347                   
00348                   
00349                   
00350                 }
00351                 
00352                 break;
00353               case 1: 
00354                 if ((MATCH_w_32_0 >> 29 & 0x1) /* a at 0 */ == 1) 
00355                   if ((MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
00356                     MATCH_name = MATCH_name_cond_0[(MATCH_w_32_0 >> 25 & 0xf) 
00357                           /* cond at 0 */]; 
00358                     goto MATCH_label_d0; 
00359                     
00360                   } /*opt-block*/
00361                   else { 
00362                     MATCH_name = MATCH_name_cond_1[(MATCH_w_32_0 >> 25 & 0xf) 
00363                           /* cond at 0 */]; 
00364                     goto MATCH_label_d0; 
00365                     
00366                   } /*opt-block*/ /*opt-block+*/
00367                 else 
00368                   if ((MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
00369                     unsigned cc01 = 
00370                       (MATCH_w_32_0 >> 20 & 0x3) /* cc01 at 0 */;
00371                     unsigned tgt = 
00372                       4 * sign_extend((MATCH_w_32_0 & 0x7ffff) 
00373                                         /* disp19 at 0 */, 19) + 
00374                       addressToPC(MATCH_p);
00375                     nextPC = 4 + MATCH_p; 
00376                     
00377 #line 400 "frontend/machine/sparc/decoder.m"
00378                                 /* Can see bpa xcc,tgt in 32 bit code */
00379 
00380                             unused(cc01);               // Does not matter because is unconditional
00381 
00382                             GotoStatement* jump = new GotoStatement;
00383 
00384                     
00385 
00386                             result.type = SD;
00387 
00388                             result.rtl = new RTL(pc, stmts);
00389 
00390                             result.rtl->appendStmt(jump);
00391 
00392                             jump->setDest(tgt - delta);
00393 
00394                             SHOW_ASM("BPA " << std::hex << tgt-delta)
00395 
00396                             DEBUG_STMTS
00397 
00398                     
00399 
00400                     
00401                     
00402                     
00403                   } /*opt-block*//*opt-block+*/
00404                   else { 
00405                     MATCH_name = MATCH_name_cond_0[(MATCH_w_32_0 >> 25 & 0xf) 
00406                           /* cond at 0 */]; 
00407                     { 
00408                       char *name = MATCH_name;
00409                       unsigned cc01 = 
00410                         (MATCH_w_32_0 >> 20 & 0x3) /* cc01 at 0 */;
00411                       unsigned tgt = 
00412                         4 * sign_extend((MATCH_w_32_0 & 0x7ffff) 
00413                                           /* disp19 at 0 */, 19) + 
00414                         addressToPC(MATCH_p);
00415                       nextPC = 4 + MATCH_p; 
00416                       
00417 #line 411 "frontend/machine/sparc/decoder.m"
00418                       
00419 
00420                             if (cc01 != 0) {        /* If 64 bit cc used, can't handle */
00421 
00422                                 result.valid = false;
00423 
00424                                 result.rtl = new RTL;
00425 
00426                                 result.numBytes = 4;
00427 
00428                                 return result;
00429 
00430                             }
00431 
00432                             GotoStatement* jump = 0;
00433 
00434                             RTL* rtl = NULL;
00435 
00436                             if (strcmp(name,"BPN") == 0) {
00437 
00438                                 jump = new GotoStatement;
00439 
00440                                 rtl = new RTL(pc, stmts);
00441 
00442                                 rtl->appendStmt(jump);
00443 
00444                             } else if (strcmp(name,"BPVS") == 0 || strcmp(name,"BPVC") == 0) {
00445 
00446                                 jump = new GotoStatement;
00447 
00448                                 rtl = new RTL(pc, stmts);
00449 
00450                                 rtl->appendStmt(jump);
00451 
00452                             } else {
00453 
00454                                 rtl = createBranchRtl(pc, stmts, name);
00455 
00456                                 // The BranchStatement will be the last Stmt of the rtl
00457 
00458                                 jump = (GotoStatement*)rtl->getList().back();
00459 
00460                             }
00461 
00462                       
00463 
00464                             // The class of this instruction depends on whether or not
00465 
00466                             // it is one of the 'unconditional' conditional branches
00467 
00468                             // "BPN" (or the pseudo unconditionals BPVx)
00469 
00470                             result.type = SCD;
00471 
00472                             if (strcmp(name, "BPVC") == 0)
00473 
00474                                 result.type = SD;
00475 
00476                             if ((strcmp(name,"BPN") == 0) || (strcmp(name, "BPVS") == 0))
00477 
00478                                 result.type = NCT;
00479 
00480                       
00481 
00482                             result.rtl = rtl;
00483 
00484                             jump->setDest(tgt - delta);
00485 
00486                             SHOW_ASM(name << " " << std::hex << tgt-delta)
00487 
00488                             DEBUG_STMTS
00489 
00490                       
00491 
00492                       
00493                       
00494                       
00495                     }
00496                     
00497                   } /*opt-block*/ /*opt-block+*/
00498                 break;
00499               case 2: 
00500                 if ((MATCH_w_32_0 >> 29 & 0x1) /* a at 0 */ == 1) 
00501                   if ((MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
00502                     MATCH_name = MATCH_name_cond_2[(MATCH_w_32_0 >> 25 & 0xf) 
00503                           /* cond at 0 */]; 
00504                     goto MATCH_label_d2; 
00505                     
00506                   } /*opt-block*/
00507                   else { 
00508                     MATCH_name = MATCH_name_cond_3[(MATCH_w_32_0 >> 25 & 0xf) 
00509                           /* cond at 0 */]; 
00510                     goto MATCH_label_d2; 
00511                     
00512                   } /*opt-block*/ /*opt-block+*/
00513                 else 
00514                   if ((MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
00515                     MATCH_name = MATCH_name_cond_1[(MATCH_w_32_0 >> 25 & 0xf) 
00516                           /* cond at 0 */]; 
00517                     goto MATCH_label_d1; 
00518                     
00519                   } /*opt-block*/
00520                   else { 
00521                     MATCH_name = MATCH_name_cond_2[(MATCH_w_32_0 >> 25 & 0xf) 
00522                           /* cond at 0 */]; 
00523                     goto MATCH_label_d1; 
00524                     
00525                   } /*opt-block*/ /*opt-block+*/
00526                 break;
00527               case 3: case 5: 
00528                 goto MATCH_label_d3; break;
00529               case 4: 
00530                 if ((MATCH_w_32_0 & 0x3fffff) /* imm22 at 0 */ == 0 && 
00531                   (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */ == 0) { 
00532                   MATCH_name = "NOP"; 
00533                   { 
00534                     char *name = MATCH_name;
00535                     nextPC = 4 + MATCH_p; 
00536                     
00537 #line 481 "frontend/machine/sparc/decoder.m"
00538                     
00539 
00540                             result.type = NOP;
00541 
00542                             stmts = instantiate(pc,  name);
00543 
00544                     
00545 
00546                     
00547                     
00548                     
00549                   }
00550                   
00551                 } /*opt-block*/
00552                 else 
00553                   goto MATCH_label_d4;  /*opt-block+*/
00554                 
00555                 break;
00556               case 6: 
00557                 if ((MATCH_w_32_0 >> 29 & 0x1) /* a at 0 */ == 1) 
00558                   if ((MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
00559                     MATCH_name = MATCH_name_cond_5[(MATCH_w_32_0 >> 25 & 0xf) 
00560                           /* cond at 0 */]; 
00561                     goto MATCH_label_d2; 
00562                     
00563                   } /*opt-block*/
00564                   else { 
00565                     MATCH_name = MATCH_name_cond_6[(MATCH_w_32_0 >> 25 & 0xf) 
00566                           /* cond at 0 */]; 
00567                     goto MATCH_label_d2; 
00568                     
00569                   } /*opt-block*/ /*opt-block+*/
00570                 else 
00571                   if ((MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
00572                     MATCH_name = MATCH_name_cond_3[(MATCH_w_32_0 >> 25 & 0xf) 
00573                           /* cond at 0 */]; 
00574                     goto MATCH_label_d1; 
00575                     
00576                   } /*opt-block*/
00577                   else { 
00578                     MATCH_name = MATCH_name_cond_5[(MATCH_w_32_0 >> 25 & 0xf) 
00579                           /* cond at 0 */]; 
00580                     goto MATCH_label_d1; 
00581                     
00582                   } /*opt-block*/ /*opt-block+*/
00583                 break;
00584               case 7: 
00585                 if ((MATCH_w_32_0 >> 29 & 0x1) /* a at 0 */ == 1) 
00586                   if ((MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
00587                     MATCH_name = MATCH_name_cond_7[(MATCH_w_32_0 >> 25 & 0xf) 
00588                           /* cond at 0 */]; 
00589                     goto MATCH_label_d2; 
00590                     
00591                   } /*opt-block*/
00592                   else { 
00593                     MATCH_name = MATCH_name_cond_8[(MATCH_w_32_0 >> 25 & 0xf) 
00594                           /* cond at 0 */]; 
00595                     goto MATCH_label_d2; 
00596                     
00597                   } /*opt-block*/ /*opt-block+*/
00598                 else 
00599                   if ((MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
00600                     MATCH_name = MATCH_name_cond_6[(MATCH_w_32_0 >> 25 & 0xf) 
00601                           /* cond at 0 */]; 
00602                     goto MATCH_label_d1; 
00603                     
00604                   } /*opt-block*/
00605                   else { 
00606                     MATCH_name = MATCH_name_cond_7[(MATCH_w_32_0 >> 25 & 0xf) 
00607                           /* cond at 0 */]; 
00608                     goto MATCH_label_d1; 
00609                     
00610                   } /*opt-block*/ /*opt-block+*/
00611                 break;
00612               default: assert(0);
00613             } /* (MATCH_w_32_0 >> 22 & 0x7) -- op2 at 0 --*/ 
00614           break;
00615         case 1: 
00616           { 
00617             unsigned addr = 
00618               4 * sign_extend((MATCH_w_32_0 & 0x3fffffff) /* disp30 at 0 */, 
00619                           30) + addressToPC(MATCH_p);
00620             nextPC = 4 + MATCH_p; 
00621             
00622 #line 215 "frontend/machine/sparc/decoder.m"
00623             
00624 
00625                     /*
00626 
00627                      * A standard call 
00628 
00629                      */
00630 
00631                     CallStatement* newCall = new CallStatement;
00632 
00633             
00634 
00635                     // Set the destination
00636 
00637                     ADDRESS nativeDest = addr - delta;
00638 
00639                     newCall->setDest(nativeDest);
00640 
00641                     Proc* destProc = prog->setNewProc(nativeDest);
00642 
00643                     if (destProc == (Proc*)-1) destProc = NULL;
00644 
00645                     newCall->setDestProc(destProc);
00646 
00647                     result.rtl = new RTL(pc, stmts);
00648 
00649                     result.rtl->appendStmt(newCall);
00650 
00651                     result.type = SD;
00652 
00653                     SHOW_ASM("call__ " << std::hex << (nativeDest))
00654 
00655                     DEBUG_STMTS
00656 
00657             
00658 
00659             
00660             
00661             
00662           }
00663           
00664           break;
00665         case 2: 
00666           
00667             switch((MATCH_w_32_0 >> 19 & 0x3f) /* op3 at 0 */) {
00668               case 0: 
00669                 MATCH_name = "ADD"; goto MATCH_label_d5; break;
00670               case 1: 
00671                 MATCH_name = "AND"; goto MATCH_label_d5; break;
00672               case 2: 
00673                 MATCH_name = "OR"; goto MATCH_label_d5; break;
00674               case 3: 
00675                 MATCH_name = "XOR"; goto MATCH_label_d5; break;
00676               case 4: 
00677                 MATCH_name = "SUB"; goto MATCH_label_d5; break;
00678               case 5: 
00679                 MATCH_name = "ANDN"; goto MATCH_label_d5; break;
00680               case 6: 
00681                 MATCH_name = "ORN"; goto MATCH_label_d5; break;
00682               case 7: 
00683                 MATCH_name = "XNOR"; goto MATCH_label_d5; break;
00684               case 8: 
00685                 MATCH_name = "ADDX"; goto MATCH_label_d5; break;
00686               case 9: case 13: case 25: case 29: case 44: case 45: case 46: 
00687               case 47: case 54: case 55: case 59: case 62: case 63: 
00688                 goto MATCH_label_d3; break;
00689               case 10: 
00690                 MATCH_name = "UMUL"; goto MATCH_label_d5; break;
00691               case 11: 
00692                 MATCH_name = "SMUL"; goto MATCH_label_d5; break;
00693               case 12: 
00694                 MATCH_name = "SUBX"; goto MATCH_label_d5; break;
00695               case 14: 
00696                 MATCH_name = "UDIV"; goto MATCH_label_d5; break;
00697               case 15: 
00698                 MATCH_name = "SDIV"; goto MATCH_label_d5; break;
00699               case 16: 
00700                 MATCH_name = "ADDcc"; goto MATCH_label_d5; break;
00701               case 17: 
00702                 MATCH_name = "ANDcc"; goto MATCH_label_d5; break;
00703               case 18: 
00704                 MATCH_name = "ORcc"; goto MATCH_label_d5; break;
00705               case 19: 
00706                 MATCH_name = "XORcc"; goto MATCH_label_d5; break;
00707               case 20: 
00708                 MATCH_name = "SUBcc"; goto MATCH_label_d5; break;
00709               case 21: 
00710                 MATCH_name = "ANDNcc"; goto MATCH_label_d5; break;
00711               case 22: 
00712                 MATCH_name = "ORNcc"; goto MATCH_label_d5; break;
00713               case 23: 
00714                 MATCH_name = "XNORcc"; goto MATCH_label_d5; break;
00715               case 24: 
00716                 MATCH_name = "ADDXcc"; goto MATCH_label_d5; break;
00717               case 26: 
00718                 MATCH_name = "UMULcc"; goto MATCH_label_d5; break;
00719               case 27: 
00720                 MATCH_name = "SMULcc"; goto MATCH_label_d5; break;
00721               case 28: 
00722                 MATCH_name = "SUBXcc"; goto MATCH_label_d5; break;
00723               case 30: 
00724                 MATCH_name = "UDIVcc"; goto MATCH_label_d5; break;
00725               case 31: 
00726                 MATCH_name = "SDIVcc"; goto MATCH_label_d5; break;
00727               case 32: 
00728                 MATCH_name = "TADDcc"; goto MATCH_label_d5; break;
00729               case 33: 
00730                 MATCH_name = "TSUBcc"; goto MATCH_label_d5; break;
00731               case 34: 
00732                 MATCH_name = "TADDccTV"; goto MATCH_label_d5; break;
00733               case 35: 
00734                 MATCH_name = "TSUBccTV"; goto MATCH_label_d5; break;
00735               case 36: 
00736                 MATCH_name = "MULScc"; goto MATCH_label_d5; break;
00737               case 37: 
00738                 MATCH_name = "SLL"; goto MATCH_label_d5; break;
00739               case 38: 
00740                 MATCH_name = "SRL"; goto MATCH_label_d5; break;
00741               case 39: 
00742                 MATCH_name = "SRA"; goto MATCH_label_d5; break;
00743               case 40: 
00744                 if ((MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */ == 0) { 
00745                   MATCH_name = "RDY"; 
00746                   { 
00747                     char *name = MATCH_name;
00748                     unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
00749                     nextPC = 4 + MATCH_p; 
00750                     
00751 #line 533 "frontend/machine/sparc/decoder.m"
00752                      
00753 
00754                             stmts = instantiate(pc,  name, DIS_RD);
00755 
00756                     
00757 
00758                     
00759                     
00760                     
00761                   }
00762                   
00763                 } /*opt-block*/
00764                 else 
00765                   goto MATCH_label_d3;  /*opt-block+*/
00766                 
00767                 break;
00768               case 41: 
00769                 MATCH_name = MATCH_name_op3_46[(MATCH_w_32_0 >> 19 & 0x3f) 
00770                       /* op3 at 0 */]; 
00771                 { 
00772                   char *name = MATCH_name;
00773                   unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
00774                   nextPC = 4 + MATCH_p; 
00775                   
00776 #line 536 "frontend/machine/sparc/decoder.m"
00777                    
00778 
00779                         stmts = instantiate(pc,  name, DIS_RD);
00780 
00781                   
00782 
00783                   
00784                   
00785                   
00786                 }
00787                 
00788                 break;
00789               case 42: 
00790                 MATCH_name = MATCH_name_op3_46[(MATCH_w_32_0 >> 19 & 0x3f) 
00791                       /* op3 at 0 */]; 
00792                 { 
00793                   char *name = MATCH_name;
00794                   unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
00795                   nextPC = 4 + MATCH_p; 
00796                   
00797 #line 539 "frontend/machine/sparc/decoder.m"
00798                    
00799 
00800                         stmts = instantiate(pc,  name, DIS_RD);
00801 
00802                   
00803 
00804                   
00805                   
00806                   
00807                 }
00808                 
00809                 break;
00810               case 43: 
00811                 MATCH_name = MATCH_name_op3_46[(MATCH_w_32_0 >> 19 & 0x3f) 
00812                       /* op3 at 0 */]; 
00813                 { 
00814                   char *name = MATCH_name;
00815                   unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
00816                   nextPC = 4 + MATCH_p; 
00817                   
00818 #line 542 "frontend/machine/sparc/decoder.m"
00819                    
00820 
00821                         stmts = instantiate(pc,  name, DIS_RD);
00822 
00823                   
00824 
00825                   
00826                   
00827                   
00828                 }
00829                 
00830                 break;
00831               case 48: 
00832                 if (1 <= (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */ && 
00833                   (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */ < 32) 
00834                   goto MATCH_label_d3;  /*opt-block+*/
00835                 else { 
00836                   MATCH_name = "WRY"; 
00837                   { 
00838                     char *name = MATCH_name;
00839                     unsigned roi = addressToPC(MATCH_p);
00840                     unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
00841                     nextPC = 4 + MATCH_p; 
00842                     
00843 #line 545 "frontend/machine/sparc/decoder.m"
00844                      
00845 
00846                             stmts = instantiate(pc,  name, DIS_RS1, DIS_ROI);
00847 
00848                     
00849 
00850                     
00851                     
00852                     
00853                   }
00854                   
00855                 } /*opt-block*/
00856                 
00857                 break;
00858               case 49: 
00859                 MATCH_name = "WRPSR"; 
00860                 { 
00861                   char *name = MATCH_name;
00862                   unsigned roi = addressToPC(MATCH_p);
00863                   unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
00864                   nextPC = 4 + MATCH_p; 
00865                   
00866 #line 548 "frontend/machine/sparc/decoder.m"
00867                    
00868 
00869                         stmts = instantiate(pc,  name, DIS_RS1, DIS_ROI);
00870 
00871                   
00872 
00873                   
00874                   
00875                   
00876                 }
00877                 
00878                 break;
00879               case 50: 
00880                 MATCH_name = "WRWIM"; 
00881                 { 
00882                   char *name = MATCH_name;
00883                   unsigned roi = addressToPC(MATCH_p);
00884                   unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
00885                   nextPC = 4 + MATCH_p; 
00886                   
00887 #line 551 "frontend/machine/sparc/decoder.m"
00888                    
00889 
00890                         stmts = instantiate(pc,  name, DIS_RS1, DIS_ROI);
00891 
00892                   
00893 
00894                   
00895                   
00896                   
00897                 }
00898                 
00899                 break;
00900               case 51: 
00901                 MATCH_name = "WRTBR"; 
00902                 { 
00903                   char *name = MATCH_name;
00904                   unsigned roi = addressToPC(MATCH_p);
00905                   unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
00906                   nextPC = 4 + MATCH_p; 
00907                   
00908 #line 554 "frontend/machine/sparc/decoder.m"
00909                    
00910 
00911                         stmts = instantiate(pc,  name, DIS_RS1, DIS_ROI);
00912 
00913                   
00914 
00915                   
00916                   
00917                   
00918                 }
00919                 
00920                 break;
00921               case 52: 
00922                 if (80 <= (MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */ && 
00923                   (MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */ < 196 || 
00924                   212 <= (MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */ && 
00925                   (MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */ < 512) 
00926                   goto MATCH_label_d3;  /*opt-block+*/
00927                 else 
00928                   switch((MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */) {
00929                     case 0: case 2: case 3: case 4: case 6: case 7: case 8: 
00930                     case 10: case 11: case 12: case 13: case 14: case 15: 
00931                     case 16: case 17: case 18: case 19: case 20: case 21: 
00932                     case 22: case 23: case 24: case 25: case 26: case 27: 
00933                     case 28: case 29: case 30: case 31: case 32: case 33: 
00934                     case 34: case 35: case 36: case 37: case 38: case 39: 
00935                     case 40: case 44: case 45: case 46: case 47: case 48: 
00936                     case 49: case 50: case 51: case 52: case 53: case 54: 
00937                     case 55: case 56: case 57: case 58: case 59: case 60: 
00938                     case 61: case 62: case 63: case 64: case 68: case 72: 
00939                     case 76: case 197: case 202: case 207: case 208: 
00940                       goto MATCH_label_d3; break;
00941                     case 1: case 5: case 9: case 41: 
00942                       MATCH_name = 
00943                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
00944                             /* opf at 0 */]; 
00945                       { 
00946                         char *name = MATCH_name;
00947                         unsigned fds = 
00948                           (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
00949                         unsigned fs2s = (MATCH_w_32_0 & 0x1f) /* fs2s at 0 */;
00950                         nextPC = 4 + MATCH_p; 
00951                         
00952 #line 560 "frontend/machine/sparc/decoder.m"
00953                          
00954 
00955                                 stmts = instantiate(pc,  name, DIS_FS2S, DIS_FDS);
00956 
00957                         
00958 
00959                         
00960                         
00961                         
00962                       }
00963                       
00964                       break;
00965                     case 42: 
00966                       MATCH_name = 
00967                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
00968                             /* opf at 0 */]; 
00969                       { 
00970                         char *name = MATCH_name;
00971                         unsigned fdd = 
00972                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdd at 0 */;
00973                         unsigned fs2d = (MATCH_w_32_0 & 0x1f) /* fs2d at 0 */;
00974                         nextPC = 4 + MATCH_p; 
00975                         
00976 #line 611 "frontend/machine/sparc/decoder.m"
00977                         
00978 
00979                                 stmts = instantiate(pc, name, DIS_FS2D, DIS_FDD);
00980 
00981                         
00982 
00983                         
00984                         
00985                         
00986                       }
00987                       
00988                       break;
00989                     case 43: 
00990                       MATCH_name = 
00991                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
00992                             /* opf at 0 */]; 
00993                       { 
00994                         char *name = MATCH_name;
00995                         unsigned fdq = 
00996                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdq at 0 */;
00997                         unsigned fs2q = (MATCH_w_32_0 & 0x1f) /* fs2q at 0 */;
00998                         nextPC = 4 + MATCH_p; 
00999                         
01000 #line 614 "frontend/machine/sparc/decoder.m"
01001                         
01002 
01003                                 stmts = instantiate(pc, name, DIS_FS2Q, DIS_FDQ);
01004 
01005                         
01006 
01007                         
01008 
01009                             // In V9, the privileged RETT becomes user-mode RETURN
01010 
01011                             // It has the semantics of "ret restore" without the add part of the restore
01012 
01013                         
01014                         
01015                         
01016                       }
01017                       
01018                       break;
01019                     case 65: case 69: case 73: case 77: 
01020                       MATCH_name = 
01021                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01022                             /* opf at 0 */]; 
01023                       { 
01024                         char *name = MATCH_name;
01025                         unsigned fds = 
01026                           (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
01027                         unsigned fs1s = 
01028                           (MATCH_w_32_0 >> 14 & 0x1f) /* fs1s at 0 */;
01029                         unsigned fs2s = (MATCH_w_32_0 & 0x1f) /* fs2s at 0 */;
01030                         nextPC = 4 + MATCH_p; 
01031                         
01032 #line 563 "frontend/machine/sparc/decoder.m"
01033                          
01034 
01035                                 stmts = instantiate(pc,  name, DIS_FS1S, DIS_FS2S, DIS_FDS);
01036 
01037                          
01038 
01039                         
01040                         
01041                         
01042                       }
01043                       
01044                       break;
01045                     case 66: case 70: case 74: case 78: 
01046                       MATCH_name = 
01047                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01048                             /* opf at 0 */]; 
01049                       { 
01050                         char *name = MATCH_name;
01051                         unsigned fdd = 
01052                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdd at 0 */;
01053                         unsigned fs1d = 
01054                           (MATCH_w_32_0 >> 14 & 0x1f) /* fs1d at 0 */;
01055                         unsigned fs2d = (MATCH_w_32_0 & 0x1f) /* fs2d at 0 */;
01056                         nextPC = 4 + MATCH_p; 
01057                         
01058 #line 566 "frontend/machine/sparc/decoder.m"
01059                          
01060 
01061                                 stmts = instantiate(pc,  name, DIS_FS1D, DIS_FS2D, DIS_FDD);
01062 
01063                          
01064 
01065                         
01066                         
01067                         
01068                       }
01069                       
01070                       break;
01071                     case 67: case 71: case 75: case 79: 
01072                       MATCH_name = 
01073                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01074                             /* opf at 0 */]; 
01075                       { 
01076                         char *name = MATCH_name;
01077                         unsigned fdq = 
01078                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdq at 0 */;
01079                         unsigned fs1q = 
01080                           (MATCH_w_32_0 >> 14 & 0x1f) /* fs1q at 0 */;
01081                         unsigned fs2q = (MATCH_w_32_0 & 0x1f) /* fs2q at 0 */;
01082                         nextPC = 4 + MATCH_p; 
01083                         
01084 #line 569 "frontend/machine/sparc/decoder.m"
01085                          
01086 
01087                                 stmts = instantiate(pc,  name, DIS_FS1Q, DIS_FS2Q, DIS_FDQ);
01088 
01089                          
01090 
01091                         
01092                         
01093                         
01094                       }
01095                       
01096                       break;
01097                     case 196: case 209: 
01098                       MATCH_name = 
01099                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01100                             /* opf at 0 */]; 
01101                       { 
01102                         char *name = MATCH_name;
01103                         unsigned fds = 
01104                           (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
01105                         unsigned fs2s = (MATCH_w_32_0 & 0x1f) /* fs2s at 0 */;
01106                         nextPC = 4 + MATCH_p; 
01107                         
01108 #line 581 "frontend/machine/sparc/decoder.m"
01109                         
01110 
01111                                 stmts = instantiate(pc, name, DIS_FS2S, DIS_FDS);
01112 
01113                         
01114 
01115                             // Note: itod and dtoi have different sized registers
01116 
01117                         
01118                         
01119                         
01120                       }
01121                       
01122                       break;
01123                     case 198: 
01124                       MATCH_name = 
01125                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01126                             /* opf at 0 */]; 
01127                       { 
01128                         char *name = MATCH_name;
01129                         unsigned fds = 
01130                           (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
01131                         unsigned fs2d = (MATCH_w_32_0 & 0x1f) /* fs2d at 0 */;
01132                         nextPC = 4 + MATCH_p; 
01133                         
01134 #line 597 "frontend/machine/sparc/decoder.m"
01135                         
01136 
01137                                 stmts = instantiate(pc, name, DIS_FS2D, DIS_FDS);
01138 
01139                         
01140 
01141                         
01142                         
01143                         
01144                       }
01145                       
01146                       break;
01147                     case 199: 
01148                       MATCH_name = 
01149                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01150                             /* opf at 0 */]; 
01151                       { 
01152                         char *name = MATCH_name;
01153                         unsigned fds = 
01154                           (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
01155                         unsigned fs2q = (MATCH_w_32_0 & 0x1f) /* fs2q at 0 */;
01156                         nextPC = 4 + MATCH_p; 
01157                         
01158 #line 602 "frontend/machine/sparc/decoder.m"
01159                         
01160 
01161                                 stmts = instantiate(pc, name, DIS_FS2Q, DIS_FDS);
01162 
01163                         
01164 
01165                         
01166                         
01167                         
01168                       }
01169                       
01170                       break;
01171                     case 200: 
01172                       MATCH_name = 
01173                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01174                             /* opf at 0 */]; 
01175                       { 
01176                         char *name = MATCH_name;
01177                         unsigned fdd = 
01178                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdd at 0 */;
01179                         unsigned fs2s = (MATCH_w_32_0 & 0x1f) /* fs2s at 0 */;
01180                         nextPC = 4 + MATCH_p; 
01181                         
01182 #line 584 "frontend/machine/sparc/decoder.m"
01183                         
01184 
01185                                 stmts = instantiate(pc, name, DIS_FS2S, DIS_FDD);
01186 
01187                         
01188                         
01189                         
01190                       }
01191                       
01192                       break;
01193                     case 201: 
01194                       MATCH_name = 
01195                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01196                             /* opf at 0 */]; 
01197                       { 
01198                         char *name = MATCH_name;
01199                         unsigned fdd = 
01200                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdd at 0 */;
01201                         unsigned fs2s = (MATCH_w_32_0 & 0x1f) /* fs2s at 0 */;
01202                         nextPC = 4 + MATCH_p; 
01203                         
01204 #line 594 "frontend/machine/sparc/decoder.m"
01205                         
01206 
01207                                 stmts = instantiate(pc, name, DIS_FS2S, DIS_FDD);
01208 
01209                         
01210                         
01211                         
01212                       }
01213                       
01214                       break;
01215                     case 203: 
01216                       MATCH_name = 
01217                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01218                             /* opf at 0 */]; 
01219                       { 
01220                         char *name = MATCH_name;
01221                         unsigned fdd = 
01222                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdd at 0 */;
01223                         unsigned fs2q = (MATCH_w_32_0 & 0x1f) /* fs2q at 0 */;
01224                         nextPC = 4 + MATCH_p; 
01225                         
01226 #line 607 "frontend/machine/sparc/decoder.m"
01227                         
01228 
01229                                 stmts = instantiate(pc, name, DIS_FS2Q, DIS_FDD);
01230 
01231                         
01232 
01233                         
01234 
01235                         
01236                         
01237                         
01238                       }
01239                       
01240                       break;
01241                     case 204: 
01242                       MATCH_name = 
01243                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01244                             /* opf at 0 */]; 
01245                       { 
01246                         char *name = MATCH_name;
01247                         unsigned fdq = 
01248                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdq at 0 */;
01249                         unsigned fs2s = (MATCH_w_32_0 & 0x1f) /* fs2s at 0 */;
01250                         nextPC = 4 + MATCH_p; 
01251                         
01252 #line 589 "frontend/machine/sparc/decoder.m"
01253                         
01254 
01255                                 stmts = instantiate(pc, name, DIS_FS2S, DIS_FDQ);
01256 
01257                         
01258                         
01259                         
01260                       }
01261                       
01262                       break;
01263                     case 205: 
01264                       MATCH_name = 
01265                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01266                             /* opf at 0 */]; 
01267                       { 
01268                         char *name = MATCH_name;
01269                         unsigned fdq = 
01270                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdq at 0 */;
01271                         unsigned fs2s = (MATCH_w_32_0 & 0x1f) /* fs2s at 0 */;
01272                         nextPC = 4 + MATCH_p; 
01273                         
01274 #line 599 "frontend/machine/sparc/decoder.m"
01275                         
01276 
01277                                 stmts = instantiate(pc, name, DIS_FS2S, DIS_FDQ);
01278 
01279                         
01280                         
01281                         
01282                       }
01283                       
01284                       break;
01285                     case 206: 
01286                       MATCH_name = 
01287                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01288                             /* opf at 0 */]; 
01289                       { 
01290                         char *name = MATCH_name;
01291                         unsigned fdq = 
01292                           (MATCH_w_32_0 >> 25 & 0x1f) /* fdq at 0 */;
01293                         unsigned fs2d = (MATCH_w_32_0 & 0x1f) /* fs2d at 0 */;
01294                         nextPC = 4 + MATCH_p; 
01295                         
01296 #line 604 "frontend/machine/sparc/decoder.m"
01297                         
01298 
01299                                 stmts = instantiate(pc, name, DIS_FS2D, DIS_FDQ);
01300 
01301                         
01302                         
01303                         
01304                       }
01305                       
01306                       break;
01307                     case 210: 
01308                       MATCH_name = 
01309                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01310                             /* opf at 0 */]; 
01311                       { 
01312                         char *name = MATCH_name;
01313                         unsigned fds = 
01314                           (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
01315                         unsigned fs2d = (MATCH_w_32_0 & 0x1f) /* fs2d at 0 */;
01316                         nextPC = 4 + MATCH_p; 
01317                         
01318 #line 587 "frontend/machine/sparc/decoder.m"
01319                         
01320 
01321                                 stmts = instantiate(pc, name, DIS_FS2D, DIS_FDS);
01322 
01323                         
01324 
01325                         
01326                         
01327                         
01328                       }
01329                       
01330                       break;
01331                     case 211: 
01332                       MATCH_name = 
01333                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01334                             /* opf at 0 */]; 
01335                       { 
01336                         char *name = MATCH_name;
01337                         unsigned fds = 
01338                           (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
01339                         unsigned fs2q = (MATCH_w_32_0 & 0x1f) /* fs2q at 0 */;
01340                         nextPC = 4 + MATCH_p; 
01341                         
01342 #line 592 "frontend/machine/sparc/decoder.m"
01343                         
01344 
01345                                 stmts = instantiate(pc, name, DIS_FS2Q, DIS_FDS);
01346 
01347                         
01348 
01349                         
01350                         
01351                         
01352                       }
01353                       
01354                       break;
01355                     default: assert(0);
01356                   } /* (MATCH_w_32_0 >> 5 & 0x1ff) -- opf at 0 --*/ 
01357                 break;
01358               case 53: 
01359                 if (0 <= (MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */ && 
01360                   (MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */ < 81 || 
01361                   88 <= (MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */ && 
01362                   (MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */ < 512) 
01363                   goto MATCH_label_d3;  /*opt-block+*/
01364                 else 
01365                   switch((MATCH_w_32_0 >> 5 & 0x1ff) /* opf at 0 */) {
01366                     case 84: 
01367                       goto MATCH_label_d3; break;
01368                     case 81: case 85: 
01369                       MATCH_name = 
01370                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01371                             /* opf at 0 */]; 
01372                       { 
01373                         char *name = MATCH_name;
01374                         unsigned fs1s = 
01375                           (MATCH_w_32_0 >> 14 & 0x1f) /* fs1s at 0 */;
01376                         unsigned fs2s = (MATCH_w_32_0 & 0x1f) /* fs2s at 0 */;
01377                         nextPC = 4 + MATCH_p; 
01378                         
01379 #line 572 "frontend/machine/sparc/decoder.m"
01380                          
01381 
01382                                 stmts = instantiate(pc,  name, DIS_FS1S, DIS_FS2S);
01383 
01384                         
01385 
01386                         
01387                         
01388                         
01389                       }
01390                       
01391                       break;
01392                     case 82: case 86: 
01393                       MATCH_name = 
01394                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01395                             /* opf at 0 */]; 
01396                       { 
01397                         char *name = MATCH_name;
01398                         unsigned fs1d = 
01399                           (MATCH_w_32_0 >> 14 & 0x1f) /* fs1d at 0 */;
01400                         unsigned fs2d = (MATCH_w_32_0 & 0x1f) /* fs2d at 0 */;
01401                         nextPC = 4 + MATCH_p; 
01402                         
01403 #line 575 "frontend/machine/sparc/decoder.m"
01404                          
01405 
01406                                 stmts = instantiate(pc,  name, DIS_FS1D, DIS_FS2D);
01407 
01408                         
01409 
01410                         
01411                         
01412                         
01413                       }
01414                       
01415                       break;
01416                     case 83: case 87: 
01417                       MATCH_name = 
01418                         MATCH_name_opf_51[(MATCH_w_32_0 >> 5 & 0x1ff) 
01419                             /* opf at 0 */]; 
01420                       { 
01421                         char *name = MATCH_name;
01422                         unsigned fs1q = 
01423                           (MATCH_w_32_0 >> 14 & 0x1f) /* fs1q at 0 */;
01424                         unsigned fs2q = (MATCH_w_32_0 & 0x1f) /* fs2q at 0 */;
01425                         nextPC = 4 + MATCH_p; 
01426                         
01427 #line 578 "frontend/machine/sparc/decoder.m"
01428                          
01429 
01430                                 stmts = instantiate(pc,  name, DIS_FS1Q, DIS_FS2Q);
01431 
01432                         
01433 
01434                         
01435                         
01436                         
01437                       }
01438                       
01439                       break;
01440                     default: assert(0);
01441                   } /* (MATCH_w_32_0 >> 5 & 0x1ff) -- opf at 0 --*/ 
01442                 break;
01443               case 56: 
01444                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) 
01445                   
01446                     switch((MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */) {
01447                       case 0: 
01448                         
01449                           switch((MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */) {
01450                             case 0: case 1: case 2: case 3: case 4: case 5: 
01451                             case 6: case 7: case 8: case 9: case 10: case 11: 
01452                             case 12: case 13: case 14: case 16: case 17: 
01453                             case 18: case 19: case 20: case 21: case 22: 
01454                             case 23: case 24: case 25: case 26: case 27: 
01455                             case 28: case 29: case 30: 
01456                               goto MATCH_label_d6; break;
01457                             case 15: 
01458                               if ((MATCH_w_32_0 & 0x1fff) 
01459                                       /* simm13 at 0 */ == 8) { 
01460                                 nextPC = 4 + MATCH_p; 
01461                                 
01462 #line 262 "frontend/machine/sparc/decoder.m"
01463                                 
01464 
01465                                         /*
01466 
01467                                          * Just a ret (leaf; uses %o7 instead of %i7)
01468 
01469                                          */
01470 
01471                                         result.rtl = new RTL(pc, stmts);
01472 
01473                                         result.rtl->appendStmt(new ReturnStatement);
01474 
01475                                         result.type = DD;
01476 
01477                                         SHOW_ASM("retl_")
01478 
01479                                         DEBUG_STMTS
01480 
01481                                 
01482 
01483                                 
01484                                 
01485                                 
01486                               } /*opt-block*//*opt-block+*/
01487                               else 
01488                                 goto MATCH_label_d6;  /*opt-block+*/
01489                               
01490                               break;
01491                             case 31: 
01492                               if ((MATCH_w_32_0 & 0x1fff) 
01493                                       /* simm13 at 0 */ == 8) { 
01494                                 nextPC = 4 + MATCH_p; 
01495                                 
01496 #line 252 "frontend/machine/sparc/decoder.m"
01497                                 
01498 
01499                                         /*
01500 
01501                                          * Just a ret (non leaf)
01502 
01503                                          */
01504 
01505                                         result.rtl = new RTL(pc, stmts);
01506 
01507                                         result.rtl->appendStmt(new ReturnStatement);
01508 
01509                                         result.type = DD;
01510 
01511                                         SHOW_ASM("ret_")
01512 
01513                                         DEBUG_STMTS
01514 
01515                                 
01516 
01517                                 
01518                                 
01519                                 
01520                               } /*opt-block*//*opt-block+*/
01521                               else 
01522                                 goto MATCH_label_d6;  /*opt-block+*/
01523                               
01524                               break;
01525                             default: assert(0);
01526                           } /* (MATCH_w_32_0 >> 14 & 0x1f) -- rs1 at 0 --*/ 
01527                         break;
01528                       case 1: case 2: case 3: case 4: case 5: case 6: case 7: 
01529                       case 8: case 9: case 10: case 11: case 12: case 13: 
01530                       case 14: case 16: case 17: case 18: case 19: case 20: 
01531                       case 21: case 22: case 23: case 24: case 25: case 26: 
01532                       case 27: case 28: case 29: case 30: case 31: 
01533                         goto MATCH_label_d6; break;
01534                       case 15: 
01535                         goto MATCH_label_d7; break;
01536                       default: assert(0);
01537                     } /* (MATCH_w_32_0 >> 25 & 0x1f) -- rd at 0 --*/  
01538                 else 
01539                   if ((MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */ == 15) 
01540                     goto MATCH_label_d7;  /*opt-block+*/
01541                   else 
01542                     goto MATCH_label_d6;  /*opt-block+*/ /*opt-block+*/
01543                 break;
01544               case 57: 
01545                 MATCH_name = "RETURN"; 
01546                 { 
01547                   char *name = MATCH_name;
01548                   unsigned addr = addressToPC(MATCH_p);
01549                   nextPC = 4 + MATCH_p; 
01550                   
01551 #line 620 "frontend/machine/sparc/decoder.m"
01552                    
01553 
01554                         stmts = instantiate(pc, name, DIS_ADDR);
01555 
01556                         result.rtl = new RTL(pc, stmts);
01557 
01558                         result.rtl->appendStmt(new ReturnStatement);
01559 
01560                         result.type = DD;
01561 
01562                   
01563 
01564                   
01565                   
01566                   
01567                 }
01568                 
01569                 break;
01570               case 58: 
01571                 if (0 <= (MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ && 
01572                   (MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ < 2 && 
01573                   (MATCH_w_32_0 >> 25 & 0xf) /* cond at 0 */ == 8) { 
01574                   MATCH_name = MATCH_name_cond_8[(MATCH_w_32_0 >> 25 & 0xf) 
01575                         /* cond at 0 */]; 
01576                   goto MATCH_label_d8; 
01577                   
01578                 } /*opt-block*/
01579                 else { 
01580                   MATCH_name = MATCH_name_cond_53[(MATCH_w_32_0 >> 25 & 0xf) 
01581                         /* cond at 0 */]; 
01582                   goto MATCH_label_d8; 
01583                   
01584                 } /*opt-block*/
01585                 
01586                 break;
01587               case 60: 
01588                 { 
01589                   unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
01590                   unsigned roi = addressToPC(MATCH_p);
01591                   unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
01592                   nextPC = 4 + MATCH_p; 
01593                   
01594 #line 471 "frontend/machine/sparc/decoder.m"
01595                   
01596 
01597                         // Decided to treat SAVE as an ordinary instruction
01598 
01599                         // That is, use the large list of effects from the SSL file, and
01600 
01601                         // hope that optimisation will vastly help the common cases
01602 
01603                         stmts = instantiate(pc, "SAVE", DIS_RS1, DIS_ROI, DIS_RD);
01604 
01605                   
01606 
01607                   
01608                   
01609                   
01610                 }
01611                 
01612                 break;
01613               case 61: 
01614                 { 
01615                   unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
01616                   unsigned roi = addressToPC(MATCH_p);
01617                   unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
01618                   nextPC = 4 + MATCH_p; 
01619                   
01620 #line 477 "frontend/machine/sparc/decoder.m"
01621                   
01622 
01623                         // Decided to treat RESTORE as an ordinary instruction
01624 
01625                         stmts = instantiate(pc, "RESTORE", DIS_RS1, DIS_ROI, DIS_RD);
01626 
01627                   
01628 
01629                   
01630                   
01631                   
01632                 }
01633                 
01634                 break;
01635               default: assert(0);
01636             } /* (MATCH_w_32_0 >> 19 & 0x3f) -- op3 at 0 --*/ 
01637           break;
01638         case 3: 
01639           
01640             switch((MATCH_w_32_0 >> 19 & 0x3f) /* op3 at 0 */) {
01641               case 0: 
01642                 MATCH_name = "LD"; goto MATCH_label_d9; break;
01643               case 1: 
01644                 MATCH_name = "LDUB"; goto MATCH_label_d9; break;
01645               case 2: 
01646                 MATCH_name = "LDUH"; goto MATCH_label_d9; break;
01647               case 3: 
01648                 MATCH_name = "LDD"; goto MATCH_label_d9; break;
01649               case 4: 
01650                 MATCH_name = "ST"; goto MATCH_label_d10; break;
01651               case 5: 
01652                 MATCH_name = "STB"; goto MATCH_label_d10; break;
01653               case 6: 
01654                 MATCH_name = "STH"; goto MATCH_label_d10; break;
01655               case 7: 
01656                 MATCH_name = "STD"; goto MATCH_label_d10; break;
01657               case 8: case 11: case 12: case 14: case 24: case 27: case 28: 
01658               case 30: case 34: case 40: case 41: case 42: case 43: case 44: 
01659               case 45: case 46: case 47: case 48: case 50: case 51: case 52: 
01660               case 55: case 56: case 57: case 58: case 59: case 60: case 61: 
01661               case 62: case 63: 
01662                 goto MATCH_label_d3; break;
01663               case 9: 
01664                 MATCH_name = "LDSB"; goto MATCH_label_d9; break;
01665               case 10: 
01666                 MATCH_name = "LDSH"; goto MATCH_label_d9; break;
01667               case 13: 
01668                 MATCH_name = "LDSTUB"; goto MATCH_label_d9; break;
01669               case 15: 
01670                 MATCH_name = "SWAP."; goto MATCH_label_d9; break;
01671               case 16: 
01672                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01673                   MATCH_name = 
01674                     MATCH_name_i_66[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01675                   goto MATCH_label_d11; 
01676                   
01677                 } /*opt-block*/
01678                 else 
01679                   goto MATCH_label_d3;  /*opt-block+*/
01680                 
01681                 break;
01682               case 17: 
01683                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01684                   MATCH_name = 
01685                     MATCH_name_i_67[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01686                   goto MATCH_label_d11; 
01687                   
01688                 } /*opt-block*/
01689                 else 
01690                   goto MATCH_label_d3;  /*opt-block+*/
01691                 
01692                 break;
01693               case 18: 
01694                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01695                   MATCH_name = 
01696                     MATCH_name_i_68[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01697                   goto MATCH_label_d11; 
01698                   
01699                 } /*opt-block*/
01700                 else 
01701                   goto MATCH_label_d3;  /*opt-block+*/
01702                 
01703                 break;
01704               case 19: 
01705                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01706                   MATCH_name = 
01707                     MATCH_name_i_69[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01708                   goto MATCH_label_d11; 
01709                   
01710                 } /*opt-block*/
01711                 else 
01712                   goto MATCH_label_d3;  /*opt-block+*/
01713                 
01714                 break;
01715               case 20: 
01716                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01717                   MATCH_name = 
01718                     MATCH_name_i_70[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01719                   goto MATCH_label_d12; 
01720                   
01721                 } /*opt-block*/
01722                 else 
01723                   goto MATCH_label_d3;  /*opt-block+*/
01724                 
01725                 break;
01726               case 21: 
01727                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01728                   MATCH_name = 
01729                     MATCH_name_i_71[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01730                   goto MATCH_label_d12; 
01731                   
01732                 } /*opt-block*/
01733                 else 
01734                   goto MATCH_label_d3;  /*opt-block+*/
01735                 
01736                 break;
01737               case 22: 
01738                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01739                   MATCH_name = 
01740                     MATCH_name_i_72[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01741                   goto MATCH_label_d12; 
01742                   
01743                 } /*opt-block*/
01744                 else 
01745                   goto MATCH_label_d3;  /*opt-block+*/
01746                 
01747                 break;
01748               case 23: 
01749                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01750                   MATCH_name = 
01751                     MATCH_name_i_73[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01752                   goto MATCH_label_d12; 
01753                   
01754                 } /*opt-block*/
01755                 else 
01756                   goto MATCH_label_d3;  /*opt-block+*/
01757                 
01758                 break;
01759               case 25: 
01760                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01761                   MATCH_name = 
01762                     MATCH_name_i_74[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01763                   goto MATCH_label_d11; 
01764                   
01765                 } /*opt-block*/
01766                 else 
01767                   goto MATCH_label_d3;  /*opt-block+*/
01768                 
01769                 break;
01770               case 26: 
01771                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01772                   MATCH_name = 
01773                     MATCH_name_i_75[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01774                   goto MATCH_label_d11; 
01775                   
01776                 } /*opt-block*/
01777                 else 
01778                   goto MATCH_label_d3;  /*opt-block+*/
01779                 
01780                 break;
01781               case 29: 
01782                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01783                   MATCH_name = "LDSTUBA"; 
01784                   goto MATCH_label_d11; 
01785                   
01786                 } /*opt-block*/
01787                 else 
01788                   goto MATCH_label_d3;  /*opt-block+*/
01789                 
01790                 break;
01791               case 31: 
01792                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 0) { 
01793                   MATCH_name = "SWAPA"; 
01794                   goto MATCH_label_d11; 
01795                   
01796                 } /*opt-block*/
01797                 else 
01798                   goto MATCH_label_d3;  /*opt-block+*/
01799                 
01800                 break;
01801               case 32: 
01802                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01803                   MATCH_name = 
01804                     MATCH_name_i_66[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01805                   goto MATCH_label_d13; 
01806                   
01807                 } /*opt-block*/
01808                 else { 
01809                   MATCH_name = "LDF"; 
01810                   goto MATCH_label_d13; 
01811                   
01812                 } /*opt-block*/
01813                 
01814                 break;
01815               case 33: 
01816                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01817                   MATCH_name = 
01818                     MATCH_name_i_67[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01819                   goto MATCH_label_d14; 
01820                   
01821                 } /*opt-block*/
01822                 else { 
01823                   MATCH_name = "LDFSR"; 
01824                   goto MATCH_label_d14; 
01825                   
01826                 } /*opt-block*/
01827                 
01828                 break;
01829               case 35: 
01830                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01831                   MATCH_name = 
01832                     MATCH_name_i_68[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01833                   goto MATCH_label_d15; 
01834                   
01835                 } /*opt-block*/
01836                 else { 
01837                   MATCH_name = "LDDF"; 
01838                   goto MATCH_label_d15; 
01839                   
01840                 } /*opt-block*/
01841                 
01842                 break;
01843               case 36: 
01844                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01845                   MATCH_name = 
01846                     MATCH_name_i_69[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01847                   goto MATCH_label_d16; 
01848                   
01849                 } /*opt-block*/
01850                 else { 
01851                   MATCH_name = "STF"; 
01852                   goto MATCH_label_d16; 
01853                   
01854                 } /*opt-block*/
01855                 
01856                 break;
01857               case 37: 
01858                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01859                   MATCH_name = 
01860                     MATCH_name_i_70[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01861                   goto MATCH_label_d17; 
01862                   
01863                 } /*opt-block*/
01864                 else { 
01865                   MATCH_name = "STFSR"; 
01866                   goto MATCH_label_d17; 
01867                   
01868                 } /*opt-block*/
01869                 
01870                 break;
01871               case 38: 
01872                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01873                   MATCH_name = 
01874                     MATCH_name_i_71[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01875                   goto MATCH_label_d18; 
01876                   
01877                 } /*opt-block*/
01878                 else { 
01879                   MATCH_name = "STDFQ"; 
01880                   goto MATCH_label_d18; 
01881                   
01882                 } /*opt-block*/
01883                 
01884                 break;
01885               case 39: 
01886                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01887                   MATCH_name = 
01888                     MATCH_name_i_72[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01889                   goto MATCH_label_d19; 
01890                   
01891                 } /*opt-block*/
01892                 else { 
01893                   MATCH_name = "STDF"; 
01894                   goto MATCH_label_d19; 
01895                   
01896                 } /*opt-block*/
01897                 
01898                 break;
01899               case 49: 
01900                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01901                   MATCH_name = 
01902                     MATCH_name_i_73[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01903                   goto MATCH_label_d20; 
01904                   
01905                 } /*opt-block*/
01906                 else { 
01907                   MATCH_name = "LDCSR"; 
01908                   goto MATCH_label_d20; 
01909                   
01910                 } /*opt-block*/
01911                 
01912                 break;
01913               case 53: 
01914                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01915                   MATCH_name = 
01916                     MATCH_name_i_74[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01917                   goto MATCH_label_d21; 
01918                   
01919                 } /*opt-block*/
01920                 else { 
01921                   MATCH_name = "STCSR"; 
01922                   goto MATCH_label_d21; 
01923                   
01924                 } /*opt-block*/
01925                 
01926                 break;
01927               case 54: 
01928                 if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
01929                   MATCH_name = 
01930                     MATCH_name_i_75[(MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */]; 
01931                   goto MATCH_label_d22; 
01932                   
01933                 } /*opt-block*/
01934                 else { 
01935                   MATCH_name = "STDCQ"; 
01936                   goto MATCH_label_d22; 
01937                   
01938                 } /*opt-block*/
01939                 
01940                 break;
01941               default: assert(0);
01942             } /* (MATCH_w_32_0 >> 19 & 0x3f) -- op3 at 0 --*/ 
01943           break;
01944         default: assert(0);
01945       } /* (MATCH_w_32_0 >> 30 & 0x3) -- op at 0 --*/ 
01946     
01947   }goto MATCH_finished_d; 
01948   
01949   MATCH_label_d0: (void)0; /*placeholder for label*/ 
01950     { 
01951       char *name = MATCH_name;
01952       unsigned cc01 = (MATCH_w_32_0 >> 20 & 0x3) /* cc01 at 0 */;
01953       unsigned tgt = 
01954         4 * sign_extend((MATCH_w_32_0 & 0x7ffff) /* disp19 at 0 */, 19) + 
01955         addressToPC(MATCH_p);
01956       nextPC = 4 + MATCH_p; 
01957       
01958 #line 316 "frontend/machine/sparc/decoder.m"
01959        
01960 
01961             /*
01962 
01963              * Anulled , predicted branch (treat as for non predicted)
01964 
01965              */
01966 
01967       
01968 
01969             // Instantiate a GotoStatement for the unconditional branches, HLJconds for the rest.
01970 
01971             // NOTE: NJMC toolkit cannot handle embedded else statements!
01972 
01973             if (cc01 != 0) {        /* If 64 bit cc used, can't handle */
01974 
01975                 result.valid = false;
01976 
01977                 result.rtl = new RTL;
01978 
01979                 result.numBytes = 4;
01980 
01981                 return result;
01982 
01983             }
01984 
01985             GotoStatement* jump = 0;
01986 
01987             RTL* rtl = NULL;                    // Init to NULL to suppress a warning
01988 
01989             if (strcmp(name,"BPA,a") == 0 || strcmp(name,"BPN,a") == 0) {
01990 
01991                 jump = new GotoStatement;
01992 
01993                 rtl = new RTL(pc, stmts);
01994 
01995                 rtl->appendStmt(jump);
01996 
01997             } else if (strcmp(name,"BPVS,a") == 0 || strcmp(name,"BPVC,a") == 0) {
01998 
01999                 jump = new GotoStatement;
02000 
02001                 rtl = new RTL(pc, stmts);
02002 
02003                 rtl->appendStmt(jump);
02004 
02005             } else {
02006 
02007                 rtl = createBranchRtl(pc, stmts, name);
02008 
02009                 jump = (GotoStatement*) rtl->getList().back();
02010 
02011             }
02012 
02013       
02014 
02015             // The class of this instruction depends on whether or not it is one of the 'unconditional' conditional branches
02016 
02017             // "BPA,A" or "BPN,A"
02018 
02019             result.type = SCDAN;
02020 
02021             if ((strcmp(name,"BPA,a") == 0) || (strcmp(name, "BPVC,a") == 0)) {
02022 
02023                 result.type = SU;
02024 
02025             } else {
02026 
02027                 result.type = SKIP;
02028 
02029             }
02030 
02031       
02032 
02033             result.rtl = rtl;
02034 
02035             jump->setDest(tgt - delta);
02036 
02037             SHOW_ASM(name << " " << std::hex << tgt-delta)
02038 
02039             DEBUG_STMTS
02040 
02041             
02042 
02043       
02044       
02045       
02046     } 
02047     goto MATCH_finished_d; 
02048     
02049   MATCH_label_d1: (void)0; /*placeholder for label*/ 
02050     { 
02051       char *name = MATCH_name;
02052       unsigned tgt = 
02053         4 * sign_extend((MATCH_w_32_0 & 0x3fffff) /* disp22 at 0 */, 22) + 
02054         addressToPC(MATCH_p);
02055       nextPC = 4 + MATCH_p; 
02056       
02057 #line 358 "frontend/machine/sparc/decoder.m"
02058        
02059 
02060             /*
02061 
02062              * Non anulled branch
02063 
02064              */
02065 
02066             // First, check for CBxxx branches (branches that depend on co-processor instructions). These are invalid,
02067 
02068             // as far as we are concerned
02069 
02070             if (name[0] == 'C') {
02071 
02072                 result.valid = false;
02073 
02074                 result.rtl = new RTL;
02075 
02076                 result.numBytes = 4;
02077 
02078                 return result;
02079 
02080             }
02081 
02082             // Instantiate a GotoStatement for the unconditional branches, BranchStatement for the rest
02083 
02084             // NOTE: NJMC toolkit cannot handle embedded plain else statements! (But OK with curly bracket before the else)
02085 
02086             GotoStatement* jump = 0;
02087 
02088             RTL* rtl = NULL;
02089 
02090             if (strcmp(name,"BA") == 0 || strcmp(name,"BN") == 0) {
02091 
02092                 jump = new GotoStatement;
02093 
02094                 rtl = new RTL(pc, stmts);
02095 
02096                 rtl->appendStmt(jump);
02097 
02098             } else if (strcmp(name,"BVS") == 0 || strcmp(name,"BVC") == 0) {
02099 
02100                 jump = new GotoStatement;
02101 
02102                 rtl = new RTL(pc, stmts);
02103 
02104                 rtl->appendStmt(jump);
02105 
02106             } else {
02107 
02108                 rtl = createBranchRtl(pc, stmts, name);
02109 
02110                 jump = (BranchStatement*) rtl->getList().back();
02111 
02112             }
02113 
02114       
02115 
02116             // The class of this instruction depends on whether or not it is one of the 'unconditional' conditional branches
02117 
02118             // "BA" or "BN" (or the pseudo unconditionals BVx)
02119 
02120             result.type = SCD;
02121 
02122             if ((strcmp(name,"BA") == 0) || (strcmp(name, "BVC") == 0))
02123 
02124                 result.type = SD;
02125 
02126             if ((strcmp(name,"BN") == 0) || (strcmp(name, "BVS") == 0))
02127 
02128                 result.type = NCT;
02129 
02130       
02131 
02132             result.rtl = rtl;
02133 
02134             jump->setDest(tgt - delta);
02135 
02136             SHOW_ASM(name << " " << std::hex << tgt-delta)
02137 
02138             DEBUG_STMTS
02139 
02140       
02141 
02142       
02143       
02144       
02145     } 
02146     goto MATCH_finished_d; 
02147     
02148   MATCH_label_d2: (void)0; /*placeholder for label*/ 
02149     { 
02150       char *name = MATCH_name;
02151       unsigned tgt = 
02152         4 * sign_extend((MATCH_w_32_0 & 0x3fffff) /* disp22 at 0 */, 22) + 
02153         addressToPC(MATCH_p);
02154       nextPC = 4 + MATCH_p; 
02155       
02156 #line 272 "frontend/machine/sparc/decoder.m"
02157        
02158 
02159             /*
02160 
02161              * Anulled branch
02162 
02163              */
02164 
02165       
02166 
02167             // First, check for CBxxx branches (branches that depend on co-processor instructions). These are invalid,
02168 
02169             // as far as we are concerned
02170 
02171             if (name[0] == 'C') {
02172 
02173                 result.valid = false;
02174 
02175                 result.rtl = new RTL;
02176 
02177                 result.numBytes = 4;
02178 
02179                 return result;
02180 
02181             }
02182 
02183             // Instantiate a GotoStatement for the unconditional branches, HLJconds for the rest.
02184 
02185             // NOTE: NJMC toolkit cannot handle embedded else statements!
02186 
02187             GotoStatement* jump = 0;
02188 
02189             RTL* rtl = NULL;                    // Init to NULL to suppress a warning
02190 
02191             if (strcmp(name,"BA,a") == 0 || strcmp(name,"BN,a") == 0) {
02192 
02193                 jump = new GotoStatement;
02194 
02195                 rtl = new RTL(pc, stmts);
02196 
02197                 rtl->appendStmt(jump);
02198 
02199             } else if (strcmp(name,"BVS,a") == 0 || strcmp(name,"BVC,a") == 0) {
02200 
02201                 jump = new GotoStatement;
02202 
02203                 rtl = new RTL(pc, stmts);
02204 
02205                 rtl->appendStmt(jump);
02206 
02207             } else {
02208 
02209                 rtl = createBranchRtl(pc, stmts, name);
02210 
02211                 jump = (GotoStatement*) rtl->getList().back();
02212 
02213             }
02214 
02215       
02216 
02217             // The class of this instruction depends on whether or not it is one of the 'unconditional' conditional branches
02218 
02219             // "BA,A" or "BN,A"
02220 
02221             result.type = SCDAN;
02222 
02223             if ((strcmp(name,"BA,a") == 0) || (strcmp(name, "BVC,a") == 0)) {
02224 
02225                 result.type = SU;
02226 
02227             } else {
02228 
02229                 result.type = SKIP;
02230 
02231             }
02232 
02233       
02234 
02235             result.rtl = rtl;
02236 
02237             jump->setDest(tgt - delta);
02238 
02239             SHOW_ASM(name << " " << std::hex << tgt-delta)
02240 
02241             DEBUG_STMTS
02242 
02243             
02244 
02245       
02246       
02247       
02248     } 
02249     goto MATCH_finished_d; 
02250     
02251   MATCH_label_d3: (void)0; /*placeholder for label*/ 
02252     { 
02253       unsigned n = MATCH_w_32_0 /* inst at 0 */;
02254       nextPC = 4 + MATCH_p; 
02255       
02256 #line 634 "frontend/machine/sparc/decoder.m"
02257        
02258 
02259             // What does this mean?
02260 
02261             unused(n);
02262 
02263             result.valid = false;
02264 
02265             stmts = NULL;
02266 
02267       
02268 
02269       
02270       
02271       
02272     } 
02273     goto MATCH_finished_d; 
02274     
02275   MATCH_label_d4: (void)0; /*placeholder for label*/ 
02276     { 
02277       unsigned imm22 = (MATCH_w_32_0 & 0x3fffff) /* imm22 at 0 */ << 10;
02278       unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
02279       nextPC = 4 + MATCH_p; 
02280       
02281 #line 485 "frontend/machine/sparc/decoder.m"
02282        
02283 
02284             stmts = instantiate(pc,  "sethi", dis_Num(imm22), DIS_RD);
02285 
02286       
02287 
02288       
02289       
02290       
02291     } 
02292     goto MATCH_finished_d; 
02293     
02294   MATCH_label_d5: (void)0; /*placeholder for label*/ 
02295     { 
02296       char *name = MATCH_name;
02297       unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
02298       unsigned roi = addressToPC(MATCH_p);
02299       unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
02300       nextPC = 4 + MATCH_p; 
02301       
02302 #line 557 "frontend/machine/sparc/decoder.m"
02303        
02304 
02305             stmts = instantiate(pc,  name, DIS_RS1, DIS_ROI, DIS_RD);
02306 
02307       
02308 
02309       
02310       
02311       
02312     } 
02313     goto MATCH_finished_d; 
02314     
02315   MATCH_label_d6: (void)0; /*placeholder for label*/ 
02316     { 
02317       unsigned addr = addressToPC(MATCH_p);
02318       unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
02319       nextPC = 4 + MATCH_p; 
02320       
02321 #line 448 "frontend/machine/sparc/decoder.m"
02322       
02323 
02324             /*
02325 
02326              * JMPL, with rd != %o7, i.e. register jump
02327 
02328              * Note: if rd==%o7, then would be handled with the call_ arm
02329 
02330              */
02331 
02332             CaseStatement* jump = new CaseStatement;
02333 
02334             // Record the fact that it is a computed jump
02335 
02336             jump->setIsComputed();
02337 
02338             result.rtl = new RTL(pc, stmts);
02339 
02340             result.rtl->appendStmt(jump);
02341 
02342             result.type = DD;
02343 
02344             jump->setDest(dis_Eaddr(addr));
02345 
02346             unused(rd);
02347 
02348             SHOW_ASM("JMPL ")
02349 
02350             DEBUG_STMTS
02351 
02352       
02353 
02354       
02355 
02356         //  //  //  //  //  //  //  //
02357 
02358         //                          //
02359 
02360         //   Ordinary instructions  //
02361 
02362         //                          //
02363 
02364         //  //  //  //  //  //  //  //
02365 
02366       
02367 
02368       
02369       
02370       
02371     } 
02372     goto MATCH_finished_d; 
02373     
02374   MATCH_label_d7: (void)0; /*placeholder for label*/ 
02375     { 
02376       unsigned addr = addressToPC(MATCH_p);
02377       nextPC = 4 + MATCH_p; 
02378       
02379 #line 233 "frontend/machine/sparc/decoder.m"
02380       
02381 
02382             /*
02383 
02384              * A JMPL with rd == %o7, i.e. a register call
02385 
02386              */
02387 
02388             CallStatement* newCall = new CallStatement;
02389 
02390       
02391 
02392             // Record the fact that this is a computed call
02393 
02394             newCall->setIsComputed();
02395 
02396       
02397 
02398             // Set the destination expression
02399 
02400             newCall->setDest(dis_Eaddr(addr));
02401 
02402             result.rtl = new RTL(pc, stmts);
02403 
02404             result.rtl->appendStmt(newCall);
02405 
02406             result.type = DD;
02407 
02408       
02409 
02410             SHOW_ASM("call_ " << dis_Eaddr(addr))
02411 
02412             DEBUG_STMTS
02413 
02414       
02415 
02416       
02417 
02418       
02419       
02420       
02421     } 
02422     goto MATCH_finished_d; 
02423     
02424   MATCH_label_d8: (void)0; /*placeholder for label*/ 
02425     { 
02426       char *name = MATCH_name;
02427       unsigned addr = addressToPC(MATCH_p);
02428       nextPC = 4 + MATCH_p; 
02429       
02430 #line 626 "frontend/machine/sparc/decoder.m"
02431        
02432 
02433             stmts = instantiate(pc,  name, DIS_ADDR);
02434 
02435       
02436 
02437       
02438       
02439       
02440     } 
02441     goto MATCH_finished_d; 
02442     
02443   MATCH_label_d9: (void)0; /*placeholder for label*/ 
02444     { 
02445       char *name = MATCH_name;
02446       unsigned addr = addressToPC(MATCH_p);
02447       unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
02448       nextPC = 4 + MATCH_p; 
02449       
02450 #line 488 "frontend/machine/sparc/decoder.m"
02451        
02452 
02453             stmts = instantiate(pc,  name, DIS_ADDR, DIS_RD);
02454 
02455       
02456 
02457       
02458       
02459       
02460     } 
02461     goto MATCH_finished_d; 
02462     
02463   MATCH_label_d10: (void)0; /*placeholder for label*/ 
02464     { 
02465       char *name = MATCH_name;
02466       unsigned addr = addressToPC(MATCH_p);
02467       unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
02468       nextPC = 4 + MATCH_p; 
02469       
02470 #line 501 "frontend/machine/sparc/decoder.m"
02471        
02472 
02473             // Note: RD is on the "right hand side" only for stores
02474 
02475             stmts = instantiate(pc,  name, DIS_RDR, DIS_ADDR);
02476 
02477       
02478 
02479       
02480       
02481       
02482     } 
02483     goto MATCH_finished_d; 
02484     
02485   MATCH_label_d11: (void)0; /*placeholder for label*/ 
02486     { 
02487       char *name = MATCH_name;
02488       unsigned addr = addressToPC(MATCH_p);
02489       unsigned asi = (MATCH_w_32_0 >> 5 & 0xff) /* asi at 0 */;
02490       unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
02491       nextPC = 4 + MATCH_p; 
02492       
02493 #line 497 "frontend/machine/sparc/decoder.m"
02494        
02495 
02496             unused(asi);            // Note: this could be serious!
02497 
02498             stmts = instantiate(pc,  name, DIS_RD, DIS_ADDR);
02499 
02500       
02501 
02502       
02503       
02504       
02505     } 
02506     goto MATCH_finished_d; 
02507     
02508   MATCH_label_d12: (void)0; /*placeholder for label*/ 
02509     { 
02510       char *name = MATCH_name;
02511       unsigned addr = addressToPC(MATCH_p);
02512       unsigned asi = (MATCH_w_32_0 >> 5 & 0xff) /* asi at 0 */;
02513       unsigned rd = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
02514       nextPC = 4 + MATCH_p; 
02515       
02516 #line 511 "frontend/machine/sparc/decoder.m"
02517        
02518 
02519             unused(asi);            // Note: this could be serious!
02520 
02521             stmts = instantiate(pc,  name, DIS_RDR, DIS_ADDR);
02522 
02523       
02524 
02525       
02526       
02527       
02528     } 
02529     goto MATCH_finished_d; 
02530     
02531   MATCH_label_d13: (void)0; /*placeholder for label*/ 
02532     { 
02533       char *name = MATCH_name;
02534       unsigned addr = addressToPC(MATCH_p);
02535       unsigned fds = (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
02536       nextPC = 4 + MATCH_p; 
02537       
02538 #line 491 "frontend/machine/sparc/decoder.m"
02539        
02540 
02541             stmts = instantiate(pc,  name, DIS_ADDR, DIS_FDS);
02542 
02543       
02544 
02545       
02546       
02547       
02548     } 
02549     goto MATCH_finished_d; 
02550     
02551   MATCH_label_d14: (void)0; /*placeholder for label*/ 
02552     { 
02553       char *name = MATCH_name;
02554       unsigned addr = addressToPC(MATCH_p);
02555       nextPC = 4 + MATCH_p; 
02556       
02557 #line 515 "frontend/machine/sparc/decoder.m"
02558        
02559 
02560             stmts = instantiate(pc,  name, DIS_ADDR);
02561 
02562       
02563 
02564       
02565       
02566       
02567     } 
02568     goto MATCH_finished_d; 
02569     
02570   MATCH_label_d15: (void)0; /*placeholder for label*/ 
02571     { 
02572       char *name = MATCH_name;
02573       unsigned addr = addressToPC(MATCH_p);
02574       unsigned fdd = (MATCH_w_32_0 >> 25 & 0x1f) /* fdd at 0 */;
02575       nextPC = 4 + MATCH_p; 
02576       
02577 #line 494 "frontend/machine/sparc/decoder.m"
02578        
02579 
02580             stmts = instantiate(pc,  name, DIS_ADDR, DIS_FDD);
02581 
02582       
02583 
02584       
02585       
02586       
02587     } 
02588     goto MATCH_finished_d; 
02589     
02590   MATCH_label_d16: (void)0; /*placeholder for label*/ 
02591     { 
02592       char *name = MATCH_name;
02593       unsigned addr = addressToPC(MATCH_p);
02594       unsigned fds = (MATCH_w_32_0 >> 25 & 0x1f) /* fds at 0 */;
02595       nextPC = 4 + MATCH_p; 
02596       
02597 #line 505 "frontend/machine/sparc/decoder.m"
02598        
02599 
02600             stmts = instantiate(pc,  name, DIS_FDS, DIS_ADDR);
02601 
02602       
02603 
02604       
02605       
02606       
02607     } 
02608     goto MATCH_finished_d; 
02609     
02610   MATCH_label_d17: (void)0; /*placeholder for label*/ 
02611     { 
02612       char *name = MATCH_name;
02613       unsigned addr = addressToPC(MATCH_p);
02614       nextPC = 4 + MATCH_p; 
02615       
02616 #line 521 "frontend/machine/sparc/decoder.m"
02617        
02618 
02619             stmts = instantiate(pc,  name, DIS_ADDR);
02620 
02621       
02622 
02623       
02624       
02625       
02626     } 
02627     goto MATCH_finished_d; 
02628     
02629   MATCH_label_d18: (void)0; /*placeholder for label*/ 
02630     { 
02631       char *name = MATCH_name;
02632       unsigned addr = addressToPC(MATCH_p);
02633       nextPC = 4 + MATCH_p; 
02634       
02635 #line 527 "frontend/machine/sparc/decoder.m"
02636        
02637 
02638             stmts = instantiate(pc,  name, DIS_ADDR);
02639 
02640       
02641 
02642       
02643       
02644       
02645     } 
02646     goto MATCH_finished_d; 
02647     
02648   MATCH_label_d19: (void)0; /*placeholder for label*/ 
02649     { 
02650       char *name = MATCH_name;
02651       unsigned addr = addressToPC(MATCH_p);
02652       unsigned fdd = (MATCH_w_32_0 >> 25 & 0x1f) /* fdd at 0 */;
02653       nextPC = 4 + MATCH_p; 
02654       
02655 #line 508 "frontend/machine/sparc/decoder.m"
02656        
02657 
02658             stmts = instantiate(pc,  name, DIS_FDD, DIS_ADDR);
02659 
02660       
02661 
02662       
02663       
02664       
02665     } 
02666     goto MATCH_finished_d; 
02667     
02668   MATCH_label_d20: (void)0; /*placeholder for label*/ 
02669     { 
02670       char *name = MATCH_name;
02671       unsigned addr = addressToPC(MATCH_p);
02672       nextPC = 4 + MATCH_p; 
02673       
02674 #line 518 "frontend/machine/sparc/decoder.m"
02675        
02676 
02677             stmts = instantiate(pc,  name, DIS_ADDR);
02678 
02679       
02680 
02681       
02682       
02683       
02684     } 
02685     goto MATCH_finished_d; 
02686     
02687   MATCH_label_d21: (void)0; /*placeholder for label*/ 
02688     { 
02689       char *name = MATCH_name;
02690       unsigned addr = addressToPC(MATCH_p);
02691       nextPC = 4 + MATCH_p; 
02692       
02693 #line 524 "frontend/machine/sparc/decoder.m"
02694        
02695 
02696             stmts = instantiate(pc,  name, DIS_ADDR);
02697 
02698       
02699 
02700       
02701       
02702       
02703     } 
02704     goto MATCH_finished_d; 
02705     
02706   MATCH_label_d22: (void)0; /*placeholder for label*/ 
02707     { 
02708       char *name = MATCH_name;
02709       unsigned addr = addressToPC(MATCH_p);
02710       nextPC = 4 + MATCH_p; 
02711       
02712 #line 530 "frontend/machine/sparc/decoder.m"
02713        
02714 
02715             stmts = instantiate(pc,  name, DIS_ADDR);
02716 
02717       
02718 
02719       
02720       
02721       
02722     } 
02723     goto MATCH_finished_d; 
02724     
02725   MATCH_finished_d: (void)0; /*placeholder for label*/
02726   
02727 }
02728 
02729 #line 645 "frontend/machine/sparc/decoder.m"
02730 
02731     result.numBytes = nextPC - hostPC;
02732     if (result.valid && result.rtl == 0)    // Don't override higher level res
02733         result.rtl = new RTL(pc, stmts);
02734 
02735     return result;
02736 }
02737 
02738 
02739 /***********************************************************************
02740  * These are functions used to decode instruction operands into
02741  * expressions (Exp*s).
02742  **********************************************************************/
02743 
02744 /*==============================================================================
02745  * FUNCTION:        SparcDecoder::dis_RegLhs
02746  * OVERVIEW:        Decode the register on the LHS
02747  * PARAMETERS:      r - register (0-31)
02748  * RETURNS:         the expression representing the register
02749  *============================================================================*/
02750 Exp* SparcDecoder::dis_RegLhs(unsigned r)
02751 {
02752     return Location::regOf(r);
02753 }
02754 
02755 /*==============================================================================
02756  * FUNCTION:        SparcDecoder::dis_RegRhs
02757  * OVERVIEW:        Decode the register on the RHS
02758  * NOTE:            Replaces r[0] with const 0
02759  * NOTE:            Not used by DIS_RD since don't want 0 on LHS
02760  * PARAMETERS:      r - register (0-31)
02761  * RETURNS:         the expression representing the register
02762  *============================================================================*/
02763 Exp* SparcDecoder::dis_RegRhs(unsigned r)
02764 {
02765     if (r == 0)
02766         return new Const(0);
02767     return Location::regOf(r);
02768 }
02769 
02770 /*==============================================================================
02771  * FUNCTION:        SparcDecoder::dis_RegImm
02772  * OVERVIEW:        Decode the register or immediate at the given address.
02773  * NOTE:            Used via macro DIS_ROI
02774  * PARAMETERS:      pc - an address in the instruction stream
02775  * RETURNS:         the register or immediate at the given address
02776  *============================================================================*/
02777 Exp* SparcDecoder::dis_RegImm(unsigned pc)
02778 {
02779 
02780 
02781 
02782 #line 694 "frontend/machine/sparc/decoder.m"
02783 { 
02784   dword MATCH_p = 
02785     
02786 #line 694 "frontend/machine/sparc/decoder.m"
02787     pc
02788     ;
02789   unsigned MATCH_w_32_0;
02790   { 
02791     MATCH_w_32_0 = getDword(MATCH_p); 
02792     if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) { 
02793       int /* [~4096..4095] */ i = 
02794         sign_extend((MATCH_w_32_0 & 0x1fff) /* simm13 at 0 */, 13);
02795       
02796 #line 696 "frontend/machine/sparc/decoder.m"
02797       
02798 
02799             Exp* expr = new Const(i);
02800 
02801             return expr;
02802 
02803       
02804       
02805       
02806     } /*opt-block*//*opt-block+*/
02807     else { 
02808       unsigned rs2 = (MATCH_w_32_0 & 0x1f) /* rs2 at 0 */;
02809       
02810 #line 698 "frontend/machine/sparc/decoder.m"
02811       
02812 
02813             return dis_RegRhs(rs2);
02814 
02815       
02816       
02817       
02818     } /*opt-block*//*opt-block+*/
02819     
02820   }goto MATCH_finished_c; 
02821   
02822   MATCH_finished_c: (void)0; /*placeholder for label*/
02823   
02824 }
02825 
02826 #line 702 "frontend/machine/sparc/decoder.m"
02827 }
02828 
02829 /*==============================================================================
02830  * FUNCTION:        SparcDecoder::dis_Eaddr
02831  * OVERVIEW:        Converts a dynamic address to a Exp* expression.
02832  *                  E.g. %o7 --> r[ 15 ]
02833  * PARAMETERS:      pc - the instruction stream address of the dynamic address
02834  *                  ignore - redundant parameter on SPARC
02835  * RETURNS:         the Exp* representation of the given address
02836  *============================================================================*/
02837 Exp* SparcDecoder::dis_Eaddr(ADDRESS pc, int ignore /* = 0 */)
02838 {
02839     Exp* expr;
02840 
02841 
02842 
02843 #line 715 "frontend/machine/sparc/decoder.m"
02844 { 
02845   dword MATCH_p = 
02846     
02847 #line 715 "frontend/machine/sparc/decoder.m"
02848     pc
02849     ;
02850   unsigned MATCH_w_32_0;
02851   { 
02852     MATCH_w_32_0 = getDword(MATCH_p); 
02853     if ((MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ == 1) 
02854       if ((MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */ == 0) { 
02855         int /* [~4096..4095] */ i = 
02856           sign_extend((MATCH_w_32_0 & 0x1fff) /* simm13 at 0 */, 13);
02857         
02858 #line 722 "frontend/machine/sparc/decoder.m"
02859         
02860 
02861                 expr = new Const((int)i);
02862 
02863         
02864         
02865         
02866       } /*opt-block*//*opt-block+*/
02867       else { 
02868         int /* [~4096..4095] */ i = 
02869           sign_extend((MATCH_w_32_0 & 0x1fff) /* simm13 at 0 */, 13);
02870         unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
02871         
02872 #line 725 "frontend/machine/sparc/decoder.m"
02873         
02874 
02875                 expr = new Binary(opPlus,
02876 
02877                     Location::regOf(rs1),
02878 
02879                     new Const((int)i));
02880 
02881         
02882         
02883         
02884       } /*opt-block*//*opt-block+*/ /*opt-block+*/
02885     else 
02886       if ((MATCH_w_32_0 & 0x1f) /* rs2 at 0 */ == 0) { 
02887         unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
02888         
02889 #line 716 "frontend/machine/sparc/decoder.m"
02890         
02891 
02892                 expr = Location::regOf(rs1);
02893 
02894         
02895         
02896         
02897       } /*opt-block*//*opt-block+*/
02898       else { 
02899         unsigned rs1 = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
02900         unsigned rs2 = (MATCH_w_32_0 & 0x1f) /* rs2 at 0 */;
02901         
02902 #line 719 "frontend/machine/sparc/decoder.m"
02903         
02904 
02905                 expr = new Binary(opPlus,
02906 
02907                     Location::regOf(rs1),
02908 
02909                     Location::regOf(rs2));
02910 
02911         
02912         
02913         
02914       } /*opt-block*//*opt-block+*/ /*opt-block+*/
02915     
02916   }goto MATCH_finished_b; 
02917   
02918   MATCH_finished_b: (void)0; /*placeholder for label*/
02919   
02920 }
02921 
02922 #line 730 "frontend/machine/sparc/decoder.m"
02923 
02924     return expr;
02925 }
02926 
02927 /*==============================================================================
02928  * FUNCTION:      isFuncPrologue()
02929  * OVERVIEW:      Check to see if the instructions at the given offset match any callee prologue, i.e. does it look
02930  *                  like this offset is a pointer to a function?
02931  * PARAMETERS:    hostPC - pointer to the code in question (host address)
02932  * RETURNS:       True if a match found
02933  *============================================================================*/
02934 bool SparcDecoder::isFuncPrologue(ADDRESS hostPC)
02935 {
02936     return false;
02937 }
02938 
02939 /*==============================================================================
02940  * FUNCTION:      isRestore()
02941  * OVERVIEW:      Check to see if the instruction at the given offset is a restore instruction
02942  * PARAMETERS:    hostPC - pointer to the code in question (host address)
02943  * RETURNS:       True if a match found
02944  *============================================================================*/
02945 bool SparcDecoder::isRestore(ADDRESS hostPC) {
02946 
02947 
02948 #line 767 "frontend/machine/sparc/decoder.m"
02949 { 
02950   dword MATCH_p = 
02951     
02952 #line 767 "frontend/machine/sparc/decoder.m"
02953     hostPC
02954     ;
02955   unsigned MATCH_w_32_0;
02956   { 
02957     MATCH_w_32_0 = getDword(MATCH_p); 
02958     if ((MATCH_w_32_0 >> 30 & 0x3) /* op at 0 */ == 2 && 
02959       (MATCH_w_32_0 >> 19 & 0x3f) /* op3 at 0 */ == 61 && 
02960       (0 <= (MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ && 
02961       (MATCH_w_32_0 >> 13 & 0x1) /* i at 0 */ < 2)) { 
02962       unsigned a = (MATCH_w_32_0 >> 14 & 0x1f) /* rs1 at 0 */;
02963       unsigned b = addressToPC(MATCH_p);
02964       unsigned c = (MATCH_w_32_0 >> 25 & 0x1f) /* rd at 0 */;
02965       
02966 #line 769 "frontend/machine/sparc/decoder.m"
02967       
02968 
02969                 unused(a);      // Suppress warning messages
02970 
02971                 unused(b);
02972 
02973                 unused(c);
02974 
02975                 return true;
02976 
02977       
02978       
02979       
02980     } /*opt-block*//*opt-block+*/
02981     else 
02982       goto MATCH_label_a0;  /*opt-block+*/
02983     
02984   }goto MATCH_finished_a; 
02985   
02986   MATCH_label_a0: (void)0; /*placeholder for label*/ 
02987     
02988 #line 773 "frontend/machine/sparc/decoder.m"
02989     
02990                 return false;
02991 
02992     
02993      
02994     goto MATCH_finished_a; 
02995     
02996   MATCH_finished_a: (void)0; /*placeholder for label*/
02997   
02998 }
02999 
03000 #line 777 "frontend/machine/sparc/decoder.m"
03001 }
03002 
03003  /**********************************
03004  * These are the fetch routines.
03005  **********************************/
03006 
03007 /*==============================================================================
03008  * FUNCTION:        getDword
03009  * OVERVIEW:        Returns the double starting at the given address.
03010  * PARAMETERS:      lc - address at which to decode the double
03011  * RETURNS:         the decoded double
03012  *============================================================================*/
03013 DWord SparcDecoder::getDword(ADDRESS lc)
03014 {
03015     Byte* p = (Byte*)lc;
03016     return (p[0] << 24) + (p[1] << 16) + (p[2] << 8) + p[3];
03017 }
03018 
03019 /*==============================================================================
03020  * FUNCTION:       SparcDecoder::SparcDecoder
03021  * OVERVIEW:       
03022  * PARAMETERS:     None
03023  * RETURNS:        N/A
03024  *============================================================================*/
03025 SparcDecoder::SparcDecoder(Prog* prog) : NJMCDecoder(prog)
03026 {
03027     std::string file = Boomerang::get()->getProgPath() + "frontend/machine/sparc/sparc.ssl";
03028     RTLDict.readSSLFile(file.c_str());
03029 }
03030 
03031 // For now...
03032 int SparcDecoder::decodeAssemblyInstruction(unsigned, int)
03033 { return 0; }
03034 
03035 
03036 

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