hppa/decoder.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 1 "machine/hppa/decoder.m"
00005 /*==============================================================================
00006  * FILE:       decoder.m
00007  * OVERVIEW:   Implementation of the HP pa-risc specific parts of the
00008  *             NJMCDecoder class.
00009  *
00010  * (C) 1996-2001 The University of Queensland, BT Group
00011  *============================================================================*/
00012 
00013 /* $Revision: 1.1 $
00014  *
00015  *    Apr 01 - Simon: Created
00016  * 04 May 01 - Mike: Create RTLs not strings; moved addressing mode functions
00017  *                      here (from decoder_low.m)
00018  * 08 May 01 - Mike: New addressing modes for dis_addr handles "modify"
00019  * 09 May 01 - Mike: Match several logues; add idReg where needed; fixed ma
00020  *              addressing mode
00021  * 11 May 01 - Mike: Match branches as high level jumps
00022  * 13 May 01 - Mike: Fixed problems with B.l.n
00023  * 14 May 01 - Mike: Added some early code for cmpib_all
00024  * 17 May 01 - Mike: Added gcc frameless logues; handle non anulled CMPIB
00025  * 27 Jun 01 - Mike: B.l -> BL (1.1 opcode) etc; addressing modes too
00026  * 19 Jul 01 - Simon: Updated dis_addr(). Added dis_x_addr_shift().
00027  * 19 Jul 01 - Simon: Also got cmpibf working with various conditions.
00028  * 23 Jul 01 - Simon: Added cmpb_all and addr_ldisp_17_old
00029  * 01 Aug 01 - Mike: BL with no target register treated as branch, not call
00030  * 06 Aug 01 - Mike: Added ADD[I]B; removed getBump()
00031  * 07 Aug 01 - Mike: Added bare_ret, bare_ret_anulled patterns; some patterns
00032  *              are type DU now; fixed SCDAN cases
00033  * 07 Aug 01 - Simon: dis_addr() gone completely - [addr] => [xd,s,b]
00034  * 10 Aug 01 - Simon: added dis_c_bit(); added BB/BVB High Level Branches
00035  * 20 Aug 01 - Mike: Check for param_reloc1 pattern
00036  */
00037 
00038 #include "global.h"
00039 #include "proc.h"
00040 #include "prog.h"
00041 #include "decoder.h"
00042 #include "ss.h"
00043 #include "rtl.h"
00044 #include "csr.h"
00045 #include "hppa.pat.h"      // generated from `sparc.pat'
00046 #include "hppa-names.h"    // generated by 'tools -fieldnames' - has
00047                             //   arrays of names of fields
00048 #include "BinaryFile.h"     // For SymbolByAddress()
00049 
00050 
00051 static const JCOND_TYPE hl_jcond_type[] = {
00052     HLJCOND_JNE, // no 'jump_never' enumeration for JCOND_TYPE
00053     HLJCOND_JE,
00054     HLJCOND_JSL,
00055     HLJCOND_JSLE,
00056     HLJCOND_JUL,
00057     HLJCOND_JULE,
00058     HLJCOND_JOF,
00059     HLJCOND_JNE, // no 'jump_if_odd' enumeration for JCOND_TYPE
00060     HLJCOND_JE,
00061     HLJCOND_JNE,
00062     HLJCOND_JSGE,
00063     HLJCOND_JSG,
00064     HLJCOND_JUGE,
00065     HLJCOND_JUG,
00066     HLJCOND_JNOF,
00067     HLJCOND_JE  // no 'jump_if_even' enumeration for JCOND_TYPE
00068 };
00069 
00070 // Handle the completer for the addr addressing mode
00071 void c_addr(ADDRESS hostpc, SemStr* ssb, SemStr* ssx);
00072 
00073 bool is_null(ADDRESS hostPC)
00074 {
00075     bool res;
00076 
00077 
00078 #line 71 "machine/hppa/decoder.m"
00079 { 
00080   dword MATCH_p = 
00081     
00082 #line 71 "machine/hppa/decoder.m"
00083     hostPC
00084     ;
00085   unsigned MATCH_w_32_0;
00086   { 
00087     MATCH_w_32_0 = getDword(MATCH_p); 
00088     
00089       switch((MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */) {
00090         case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: 
00091         case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: 
00092         case 16: case 17: case 18: case 19: case 20: case 21: case 22: 
00093         case 23: case 24: case 25: case 26: case 27: case 28: case 29: 
00094         case 30: case 31: case 36: case 37: case 38: case 44: case 45: 
00095         case 46: case 52: case 53: case 54: case 55: case 60: case 61: 
00096         case 62: case 63: 
00097           assert(0);  /* no match */break;
00098         case 32: case 33: case 34: case 35: case 39: case 40: case 41: 
00099         case 42: case 43: case 47: case 48: case 49: case 50: case 51: 
00100         case 56: case 57: case 58: case 59: 
00101           if ((MATCH_w_32_0 >> 1 & 0x1) /* n_30 at 0 */ == 1) 
00102             
00103 #line 76 "machine/hppa/decoder.m"
00104              {
00105 
00106                         res = true;
00107 
00108                     }
00109 
00110             
00111              /*opt-block+*/
00112           else 
00113             
00114 #line 73 "machine/hppa/decoder.m"
00115              {
00116 
00117                         res = false;
00118 
00119                     }
00120 
00121             
00122              /*opt-block+*/
00123           
00124           break;
00125         default: assert(0);
00126       } /* (MATCH_w_32_0 >> 26 & 0x3f) -- op at 0 --*/ 
00127     
00128   }goto MATCH_finished_e; 
00129   
00130   MATCH_finished_e: (void)0; /*placeholder for label*/
00131   
00132 }
00133 
00134 #line 80 "machine/hppa/decoder.m"
00135 
00136     return res;
00137 }
00138 
00139 
00140 DecodeResult& NJMCDecoder::decodeInstruction (ADDRESS pc, int delta,
00141     UserProc* proc /* = NULL */)
00142 { 
00143     static DecodeResult result;
00144     ADDRESS hostPC = pc+delta;
00145 
00146     // Clear the result structure;
00147     result.reset();
00148 
00149     // The actual list of instantiated RTs
00150     list<RT*>* RTs = NULL;
00151     preInstSem = NULL;          // No semantics before the instruction yet
00152     postInstSem = NULL;         // No semantics after the instruction yet
00153 
00154     ADDRESS nextPC;
00155 
00156     // Try matching a logue first.
00157     ADDRESS saveHostPC = hostPC;
00158     int addr, locals, libstub;
00159     Logue* logue;
00160 
00161     if ((logue = InstructionPatterns::std_call(csr,hostPC,addr)) != NULL) {
00162         /*
00163          * Ordinary call to fixed dest
00164          */
00165         HLCall* newCall = new HLCall(pc, 0, RTs);
00166         // Set the fixed destination. Note that addr is (at present!!) just
00167         // the offset in the instruction, so we have to add native pc
00168         newCall->setDest(addr + pc);
00169         result.numBytes = hostPC - saveHostPC;
00170         // See if this call is to a special symbol
00171         const char* dest = prog.pBF->SymbolByAddress((ADDRESS)(addr + pc));
00172         if (dest && (strcmp(dest, "__main") == 0)) {
00173             // Treat this as a NOP
00174         } else {
00175 
00176             result.rtl = newCall;
00177             result.type = SD;
00178 
00179             // Record the prologue of this caller
00180             newCall->setPrologue(logue);
00181 
00182             SHOW_ASM("std_call 0x" << hex << addr-delta)
00183         }
00184     }
00185 
00186     //
00187     // Callee prologues
00188     //
00189     else if ((logue = InstructionPatterns::gcc_frame(csr,hostPC, locals))
00190       != NULL) {
00191         /*
00192          * Standard prologue for gcc: sets up frame in %r3; optionally saves
00193          * several registers to the stack
00194          */
00195         if (proc != NULL) {
00196 
00197             // Record the prologue of this callee
00198             assert(logue->getType() == Logue::CALLEE_PROLOGUE);
00199             proc->setPrologue((CalleePrologue*)logue);
00200         }
00201 
00202         result.numBytes = hostPC - saveHostPC;
00203         result.rtl = new RTL(pc,RTs);
00204         result.type = NCT;
00205         SHOW_ASM("gcc_frame " << dec << locals)
00206     }
00207     else if ((logue = InstructionPatterns::gcc_frameless(csr,hostPC, locals))
00208       != NULL) {
00209         /*
00210          * Gcc prologue where optimisation is on, and no frame pointer is needed
00211          */
00212         if (proc != NULL) {
00213 
00214             // Record the prologue of this callee
00215             assert(logue->getType() == Logue::CALLEE_PROLOGUE);
00216             proc->setPrologue((CalleePrologue*)logue);
00217         }
00218 
00219         result.numBytes = hostPC - saveHostPC;
00220         result.rtl = new RTL(pc,RTs);
00221         result.type = NCT;
00222         SHOW_ASM("gcc_frameless " << dec << locals)
00223     }
00224     else if ((locals=8, logue = InstructionPatterns::param_reloc1(csr,hostPC,
00225       libstub, locals)) != NULL) {
00226         /*
00227          * Parameter relocation stub common when passing a double as the second
00228          * parameter to printf
00229          */
00230         if (proc != NULL) {
00231             // Record the prologue of this callee
00232             assert(logue->getType() == Logue::CALLEE_PROLOGUE);
00233             proc->setPrologue((CalleePrologue*)logue);
00234         }
00235 
00236         // The semantics of the first 3 instructions are difficult to translate
00237         // However, they boil down to these three, and the parameter analysis
00238         // should be able to use these:
00239         // *64* m[%afp + 0] = r[39];
00240         SemStr* ssSrc = new SemStr;
00241         SemStr* ssDst = new SemStr;
00242         *ssSrc << idRegOf << idIntConst << 39;
00243         *ssDst << idMemOf << idAFP;
00244         RTs = new list<RT*>;
00245         RTAssgn* pRt = new RTAssgn(ssDst, ssSrc, 64); RTs->push_back(pRt);
00246         // *32* r[23] := m[%afp    ];
00247         ssSrc = new SemStr; ssDst = new SemStr;
00248         *ssSrc << idMemOf << idAFP;
00249         *ssDst << idRegOf << idIntConst << 23;
00250         pRt = new RTAssgn(ssDst, ssSrc, 32);
00251         RTs->push_back(pRt);
00252         // *32* r[24] := m[%afp + 4];
00253         ssSrc = new SemStr; ssDst = new SemStr;
00254         *ssSrc << idMemOf << idPlus << idAFP << idIntConst << 4;
00255         *ssDst << idRegOf << idIntConst << 24;
00256         pRt = new RTAssgn(ssDst, ssSrc, 32); RTs->push_back(pRt);
00257 
00258         // Find the destination of the final jump. It starts 12 bytes later than
00259         // the pc of the whole pattern
00260         ADDRESS dest = pc + 12 + libstub;
00261         // Treat it like a call, followed by a return
00262         HLCall* newCall = new HLCall(pc, 0, RTs);
00263         // Set the fixed destination.
00264         newCall->setDest(dest);
00265         newCall->setReturnAfterCall(true);
00266         result.numBytes = hostPC - saveHostPC;
00267         result.rtl = newCall;
00268         result.type = SU;
00269 
00270         // Record the prologue of this caller (though it's the wrong type)
00271         newCall->setPrologue(logue);
00272         SHOW_ASM("param_reloc1 " << hex << dest)
00273     }
00274 
00275     //
00276     // Callee epilogues
00277     //
00278     else if ((logue = InstructionPatterns::gcc_unframe(csr, hostPC)) != NULL) {
00279         /*
00280          * Standard removal of current frame for gcc; optional restore of
00281          * several registers from stack
00282          */
00283         result.numBytes = hostPC - saveHostPC;
00284         result.rtl = new HLReturn(pc,RTs);
00285         result.type = DU;
00286 
00287         // Record the epilogue of this callee
00288         if (proc != NULL) {
00289             assert(logue->getType() == Logue::CALLEE_EPILOGUE);
00290             proc->setEpilogue((CalleeEpilogue*)logue);
00291         }
00292     
00293         SHOW_ASM("gcc_unframe");
00294     }
00295     else if ((logue = InstructionPatterns::gcc_unframeless1(csr, hostPC)) !=
00296       NULL) {
00297         /*
00298          * Removal of current frame for gcc (where no frame pointer was used)
00299          */
00300         result.numBytes = hostPC - saveHostPC;
00301         result.rtl = new HLReturn(pc,RTs);
00302         // Although the actual return instruction is a DD (Dynamic Delayed
00303         // branch), we call it a DU so the delay slot instruction is not decoded
00304         result.type = DU;
00305 
00306         // Record the epilogue of this callee
00307         if (proc != NULL) {
00308             assert(logue->getType() == Logue::CALLEE_EPILOGUE);
00309             proc->setEpilogue((CalleeEpilogue*)logue);
00310         }
00311     
00312         SHOW_ASM("gcc_unframeless1");
00313     }
00314     else if ((logue = InstructionPatterns::gcc_unframeless2(csr, hostPC)) !=
00315       NULL) {
00316         /*
00317          * Removal of current frame for gcc (where no frame pointer was used)
00318          */
00319         result.numBytes = hostPC - saveHostPC;
00320         result.rtl = new HLReturn(pc,RTs);
00321         result.type = DU;
00322 
00323         // Record the epilogue of this callee
00324         if (proc != NULL) {
00325             assert(logue->getType() == Logue::CALLEE_EPILOGUE);
00326             proc->setEpilogue((CalleeEpilogue*)logue);
00327         }
00328     
00329         SHOW_ASM("gcc_unframeless2");
00330     }
00331     else if ((logue = InstructionPatterns::bare_ret(csr, hostPC)) != NULL) {
00332         /*
00333          * Just a bare (non anulled) return statement
00334          */
00335         result.numBytes = 8;        // BV and the delay slot instruction
00336         result.rtl = new HLReturn(pc, RTs);
00337         // This is a DD instruction; the front end will decode the delay slot
00338         // instruction
00339         result.type = DD;
00340 
00341         // Record the epilogue of this callee
00342         if (proc != NULL) {
00343             assert(logue->getType() == Logue::CALLEE_EPILOGUE);
00344             proc->setEpilogue((CalleeEpilogue*)logue);
00345         }
00346     
00347         SHOW_ASM("bare_ret");
00348     }
00349     else if ((logue = InstructionPatterns::bare_ret_anulled(csr, hostPC))
00350       != NULL) {
00351         /*
00352          * Just a bare (anulled) return statement
00353          */
00354         result.numBytes = 4;        // BV only
00355         result.rtl = new HLReturn(pc, RTs);
00356         result.type = DU;       // No delay slot to decode
00357 
00358         // Record the epilogue of this callee
00359         if (proc != NULL) {
00360             assert(logue->getType() == Logue::CALLEE_EPILOGUE);
00361             proc->setEpilogue((CalleeEpilogue*)logue);
00362         }
00363     
00364         SHOW_ASM("bare_ret_anulled");
00365     }
00366 
00367     else {
00368         // Branches and other high level instructions
00369 
00370 
00371 #line 313 "machine/hppa/decoder.m"
00372 { 
00373   dword MATCH_p = 
00374     
00375 #line 313 "machine/hppa/decoder.m"
00376     hostPC
00377     ;
00378   char *MATCH_name;
00379   unsigned MATCH_w_32_0;
00380   { 
00381     MATCH_w_32_0 = getDword(MATCH_p); 
00382     
00383       switch((MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */) {
00384         case 0: case 1: case 3: case 4: case 5: case 6: case 7: case 8: 
00385         case 9: case 10: case 11: case 12: case 13: case 14: case 15: 
00386         case 16: case 17: case 18: case 19: case 20: case 21: case 22: 
00387         case 23: case 24: case 25: case 26: case 27: case 28: case 29: 
00388         case 30: case 31: case 38: case 46: case 52: case 53: case 54: 
00389         case 55: case 56: case 57: case 60: case 61: case 62: case 63: 
00390           goto MATCH_label_d0; break;
00391         case 2: 
00392           if (1 <= (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ && 
00393             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ < 4 || 
00394             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ == 6 || 
00395             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ == 18 || 
00396             32 <= (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ && 
00397             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ < 34 || 
00398             35 <= (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ && 
00399             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ < 38 || 
00400             44 <= (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ && 
00401             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ < 46 || 
00402             49 <= (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ && 
00403             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ < 51 || 
00404             53 <= (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ && 
00405             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ < 56 || 
00406             61 <= (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ && 
00407             (MATCH_w_32_0 >> 6 & 0x3f) /* ext6_20 at 0 */ < 64) 
00408             goto MATCH_label_d0;  /*opt-block+*/
00409           else { 
00410             unsigned cmplt = addressToPC(MATCH_p);
00411             unsigned r_06 = (MATCH_w_32_0 >> 21 & 0x1f) /* r_06 at 0 */;
00412             unsigned r_11 = (MATCH_w_32_0 >> 16 & 0x1f) /* r_11 at 0 */;
00413             unsigned t_27 = (MATCH_w_32_0 & 0x1f) /* t_27 at 0 */;
00414             nextPC = 4 + MATCH_p; 
00415             
00416 #line 470 "machine/hppa/decoder.m"
00417              {
00418 
00419                         // Decode the instruction
00420 
00421                         low_level(RTs, hostPC, pc, result, nextPC);
00422 
00423                         int condvalue;
00424 
00425                         c_c(cmplt, condvalue);
00426 
00427                         if (condvalue != 0)
00428 
00429                             // Anulled. Need to decode the next instruction, and make each
00430 
00431                             // RTAssgn in it conditional on !r[tmpNul]
00432 
00433                             // We can't do this here, so we just make result.type equal to
00434 
00435                             // NCTA, and the front end will do this for us
00436 
00437                             result.type = NCTA;
00438 
00439                         not_used(r_11); not_used(r_06); not_used(t_27);
00440 
00441                     }
00442 
00443             
00444             
00445             
00446           } /*opt-block*//*opt-block+*/
00447           
00448           break;
00449         case 32: case 34: case 39: case 47: 
00450           { 
00451             unsigned c_cmplt = addressToPC(MATCH_p);
00452             unsigned null_cmplt = addressToPC(MATCH_p);
00453             unsigned r1 = (MATCH_w_32_0 >> 16 & 0x1f) /* r_11 at 0 */;
00454             unsigned r2 = (MATCH_w_32_0 >> 21 & 0x1f) /* r_06 at 0 */;
00455             unsigned target = 
00456               ((MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */ << 2) + 
00457               ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 12) + 
00458               ((sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 
00459                           1) & 0x7ffff) << 13);
00460             nextPC = 4 + MATCH_p; 
00461             
00462 #line 369 "machine/hppa/decoder.m"
00463              {
00464 
00465                         int condvalue;
00466 
00467                         SemStr* cond_ss = c_c(c_cmplt, condvalue);
00468 
00469                         HLJcond* jump = new HLJcond(pc, RTs);
00470 
00471                         jump->setCondType(hl_jcond_type[condvalue]);
00472 
00473                         jump->setDest(dis_Num(target + pc + 8));
00474 
00475                         SemStr* reg1 = dis_Reg(r1);
00476 
00477                         SemStr* reg2 = dis_Reg(r2);
00478 
00479                         reg1->prep(idRegOf);
00480 
00481                         reg2->prep(idRegOf);
00482 
00483                         SemStr* exp = new SemStr;
00484 
00485                         *exp << idMinus << *reg1 << *reg2;
00486 
00487                         substituteCallArgs("c_c", cond_ss, reg1, reg2, exp);
00488 
00489                         jump->setCondExpr(cond_ss);
00490 
00491                         bool isNull = is_null(null_cmplt);
00492 
00493                         // If isNull, then taken forward or failing backwards anull
00494 
00495                         result.type = isNull ? (((int)target >= 0) ? SCDAT : SCDAN) : SCD;
00496 
00497                         result.rtl = jump;
00498 
00499                         result.numBytes = 4;
00500 
00501                     }
00502 
00503             
00504             
00505             
00506           }
00507           
00508           break;
00509         case 33: case 35: case 59: 
00510           { 
00511             unsigned c_cmplt = addressToPC(MATCH_p);
00512             unsigned im5_11 = 
00513               ((sign_extend((MATCH_w_32_0 >> 16 & 0x1) /* im1_15 at 0 */, 
00514                           1) & 0xfffffff) << 4) + 
00515               (MATCH_w_32_0 >> 17 & 0xf) /* im4_11 at 0 */;
00516             unsigned null_cmplt = addressToPC(MATCH_p);
00517             unsigned r_06 = (MATCH_w_32_0 >> 21 & 0x1f) /* r_06 at 0 */;
00518             unsigned target = 
00519               ((MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */ << 2) + 
00520               ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 12) + 
00521               ((sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 
00522                           1) & 0x7ffff) << 13);
00523             nextPC = 4 + MATCH_p; 
00524             
00525 #line 349 "machine/hppa/decoder.m"
00526              {
00527 
00528                         int condvalue;
00529 
00530                         SemStr* cond_ss = c_c(c_cmplt, condvalue);
00531 
00532                         HLJcond* jump = new HLJcond(pc, RTs);
00533 
00534                         jump->setCondType(hl_jcond_type[condvalue]);
00535 
00536                         jump->setDest(dis_Num(target + pc + 8));
00537 
00538                         SemStr* imm = dis_Num(im5_11);
00539 
00540                         SemStr* reg = dis_Reg(r_06);
00541 
00542                         reg->prep(idRegOf);
00543 
00544                         SemStr* exp = new SemStr;
00545 
00546                         *exp << idMinus << *imm << *reg;
00547 
00548                         substituteCallArgs("c_c", cond_ss, imm, reg, exp);
00549 
00550                         jump->setCondExpr(cond_ss);
00551 
00552                         bool isNull = is_null(null_cmplt);
00553 
00554                         // If isNull, then taken forward or failing backwards anull
00555 
00556                         result.type = isNull ? (((int)target >= 0) ? SCDAT : SCDAN) : SCD;
00557 
00558                         result.rtl = jump;
00559 
00560                         result.numBytes = 4;
00561 
00562                     }
00563 
00564             
00565 
00566             
00567             
00568             
00569           }
00570           
00571           break;
00572         case 36: 
00573           goto MATCH_label_d1; break;
00574         case 37: case 44: case 45: 
00575           goto MATCH_label_d1; break;
00576         case 40: 
00577           MATCH_name = "ADDBT"; goto MATCH_label_d2; break;
00578         case 41: 
00579           MATCH_name = "ADDIBT"; goto MATCH_label_d3; break;
00580         case 42: 
00581           MATCH_name = "ADDBF"; goto MATCH_label_d2; break;
00582         case 43: 
00583           MATCH_name = "ADDIBF"; goto MATCH_label_d3; break;
00584         case 48: 
00585           goto MATCH_label_d4; break;
00586         case 49: 
00587           if ((MATCH_w_32_0 >> 13 & 0x1) /* d_18 at 0 */ == 1) 
00588             goto MATCH_label_d0;  /*opt-block+*/
00589           else 
00590             goto MATCH_label_d4;  /*opt-block+*/
00591           
00592           break;
00593         case 50: 
00594           MATCH_name = "MOVB"; 
00595           { 
00596             char *name = MATCH_name;
00597             unsigned c_cmplt = addressToPC(MATCH_p);
00598             unsigned null_cmplt = addressToPC(MATCH_p);
00599             unsigned r1 = (MATCH_w_32_0 >> 16 & 0x1f) /* r_11 at 0 */;
00600             unsigned r2 = (MATCH_w_32_0 >> 21 & 0x1f) /* r_06 at 0 */;
00601             unsigned target = 
00602               ((MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */ << 2) + 
00603               ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 12) + 
00604               ((sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 
00605                           1) & 0x7ffff) << 13);
00606             nextPC = 4 + MATCH_p; 
00607             
00608 #line 409 "machine/hppa/decoder.m"
00609              {
00610 
00611                         int condvalue;
00612 
00613                         SemStr* cond_ss = c_c(c_cmplt, condvalue);
00614 
00615                         RTs = instantiate(pc, name, dis_Reg(r1), dis_Reg(r2));
00616 
00617                         HLJcond* jump = new HLJcond(pc, RTs);
00618 
00619                         jump->setCondType(hl_jcond_type[condvalue]);
00620 
00621                         jump->setDest(dis_Num(target + pc + 8));
00622 
00623                         SemStr* reg1 = dis_Reg(r1);
00624 
00625                         SemStr* reg2 = dis_Reg(r2);
00626 
00627                         reg1->prep(idRegOf);
00628 
00629                         reg2->prep(idRegOf);
00630 
00631                         SemStr* tgt = new SemStr(*reg2);
00632 
00633                         substituteCallArgs("c_c", cond_ss, reg1, reg2, tgt);
00634 
00635                         jump->setCondExpr(cond_ss);
00636 
00637                         bool isNull = is_null(null_cmplt);
00638 
00639                         result.type = isNull ? (((int)target >= 0) ? SCDAT : SCDAN) : SCD;
00640 
00641                         result.rtl = jump;
00642 
00643                         result.numBytes = 4;
00644 
00645                     }
00646 
00647             
00648             
00649             
00650           }
00651           
00652           break;
00653         case 51: 
00654           MATCH_name = "MOVIB"; 
00655           { 
00656             char *name = MATCH_name;
00657             unsigned c_cmplt = addressToPC(MATCH_p);
00658             unsigned i = 
00659               ((sign_extend((MATCH_w_32_0 >> 16 & 0x1) /* im1_15 at 0 */, 
00660                           1) & 0xfffffff) << 4) + 
00661               (MATCH_w_32_0 >> 17 & 0xf) /* im4_11 at 0 */;
00662             unsigned null_cmplt = addressToPC(MATCH_p);
00663             unsigned r = (MATCH_w_32_0 >> 21 & 0x1f) /* r_06 at 0 */;
00664             unsigned target = 
00665               ((MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */ << 2) + 
00666               ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 12) + 
00667               ((sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 
00668                           1) & 0x7ffff) << 13);
00669             nextPC = 4 + MATCH_p; 
00670             
00671 #line 428 "machine/hppa/decoder.m"
00672              {
00673 
00674                         int condvalue;
00675 
00676                         SemStr* cond_ss = c_c(c_cmplt, condvalue);
00677 
00678                         RTs = instantiate(pc, name, dis_Num(i), dis_Reg(r));
00679 
00680                         HLJcond* jump = new HLJcond(pc, RTs);
00681 
00682                         jump->setCondType(hl_jcond_type[condvalue]);
00683 
00684                         jump->setDest(dis_Num(target + pc + 8));
00685 
00686                         SemStr* imm = dis_Reg(i);
00687 
00688                         SemStr* reg = dis_Reg(r);
00689 
00690                         imm->prep(idIntConst);
00691 
00692                         reg->prep(idRegOf);
00693 
00694                         SemStr* tgt = new SemStr(*reg);
00695 
00696                         substituteCallArgs("c_c", cond_ss, imm, reg, tgt);
00697 
00698                         jump->setCondExpr(cond_ss);
00699 
00700                         bool isNull = is_null(null_cmplt);
00701 
00702                         result.type = isNull ? (((int)target >= 0) ? SCDAT : SCDAN) : SCD;
00703 
00704                         result.rtl = jump;
00705 
00706                         result.numBytes = 4;
00707 
00708                     }
00709 
00710             
00711             
00712             
00713           }
00714           
00715           break;
00716         case 58: 
00717           if (1 <= (MATCH_w_32_0 >> 13 & 0x7) /* ext3_16 at 0 */ && 
00718             (MATCH_w_32_0 >> 13 & 0x7) /* ext3_16 at 0 */ < 8) 
00719             goto MATCH_label_d0;  /*opt-block+*/
00720           else { 
00721             unsigned nulli = addressToPC(MATCH_p);
00722             unsigned t_06 = (MATCH_w_32_0 >> 21 & 0x1f) /* t_06 at 0 */;
00723             unsigned ubr_target = 
00724               8 + ((MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */ << 2) + 
00725               ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 12) + 
00726               ((MATCH_w_32_0 >> 16 & 0x1f) /* w5_11 at 0 */ << 13) + 
00727               (sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 1) << 18);
00728             nextPC = 4 + MATCH_p; 
00729             
00730 #line 315 "machine/hppa/decoder.m"
00731              {
00732 
00733                         HLJump* jump;
00734 
00735                         // The return registers are 2 (standard) or 31 (millicode)
00736 
00737                         if ((t_06 == 2) || (t_06 == 31))
00738 
00739                             jump = new HLCall(pc, 0, RTs);
00740 
00741                         if ((t_06 != 2) && (t_06 != 31))    // Can't use "else"
00742 
00743                             jump = new HLJump(pc, RTs);
00744 
00745                         result.rtl = jump;
00746 
00747                         bool isNull = is_null(nulli);
00748 
00749                         if (isNull)
00750 
00751                             result.type = SU;
00752 
00753                         if (!isNull)                        // Can't use "else"
00754 
00755                             result.type = SD;
00756 
00757                         jump->setDest(ubr_target + pc);     // This may change
00758 
00759                         result.numBytes = 4;
00760 
00761                     }
00762 
00763                     
00764 
00765             
00766             
00767             
00768           } /*opt-block*//*opt-block+*/
00769           
00770           break;
00771         default: assert(0);
00772       } /* (MATCH_w_32_0 >> 26 & 0x3f) -- op at 0 --*/ 
00773     
00774   }goto MATCH_finished_d; 
00775   
00776   MATCH_label_d0: (void)0; /*placeholder for label*/ 
00777     { 
00778       nextPC = MATCH_p; 
00779       
00780 #line 494 "machine/hppa/decoder.m"
00781       {
00782 
00783                   // Low level instruction
00784 
00785                   low_level(RTs, hostPC, pc, result, nextPC);
00786 
00787               }
00788 
00789       
00790       
00791       
00792     } 
00793     goto MATCH_finished_d; 
00794     
00795   MATCH_label_d1: (void)0; /*placeholder for label*/ 
00796     { 
00797       unsigned cmplt = addressToPC(MATCH_p);
00798       unsigned imm11 = 
00799         (sign_extend((MATCH_w_32_0 & 0x1) /* i_31 at 0 */, 1) << 10) + 
00800         (MATCH_w_32_0 >> 1 & 0x3ff) /* im10_21 at 0 */;
00801       unsigned r_06 = (MATCH_w_32_0 >> 21 & 0x1f) /* r_06 at 0 */;
00802       unsigned t_11 = (MATCH_w_32_0 >> 16 & 0x1f) /* t_11 at 0 */;
00803       nextPC = 4 + MATCH_p; 
00804       
00805 #line 483 "machine/hppa/decoder.m"
00806        {
00807 
00808                   // Decode the instruction
00809 
00810                   low_level(RTs, hostPC, pc, result, nextPC);
00811 
00812                   int condvalue;
00813 
00814                   c_c(cmplt, condvalue);
00815 
00816                   if (condvalue != 0)
00817 
00818                       // Anulled. Need to decode the next instruction, and make each
00819 
00820                       // RTAssgn in it conditional on !r[tmpNul]
00821 
00822                       result.type = NCTA;
00823 
00824                   not_used(imm11); not_used(r_06); not_used(t_11);
00825 
00826               } 
00827 
00828       
00829       
00830       
00831     } 
00832     goto MATCH_finished_d; 
00833     
00834   MATCH_label_d2: (void)0; /*placeholder for label*/ 
00835     { 
00836       char *name = MATCH_name;
00837       unsigned c_cmplt = addressToPC(MATCH_p);
00838       unsigned null_cmplt = addressToPC(MATCH_p);
00839       unsigned r1 = (MATCH_w_32_0 >> 16 & 0x1f) /* r_11 at 0 */;
00840       unsigned r2 = (MATCH_w_32_0 >> 21 & 0x1f) /* r_06 at 0 */;
00841       unsigned target = 
00842         ((MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */ << 2) + 
00843         ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 12) + 
00844         ((sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 
00845                     1) & 0x7ffff) << 13);
00846       nextPC = 4 + MATCH_p; 
00847       
00848 #line 447 "machine/hppa/decoder.m"
00849        {
00850 
00851                   int condvalue;
00852 
00853                   SemStr* cond_ss = c_c(c_cmplt, condvalue);
00854 
00855                   // Get semantics for the add part (only)
00856 
00857                   RTs = instantiate(pc, name, dis_Reg(r1), dis_Reg(r2));
00858 
00859                   HLJcond* jump = new HLJcond(pc, RTs);
00860 
00861                   jump->setCondType(hl_jcond_type[condvalue]);
00862 
00863                   jump->setDest(dis_Num(target + pc + 8));
00864 
00865                   SemStr* reg1 = dis_Reg(r1);
00866 
00867                   SemStr* reg2 = dis_Reg(r2);
00868 
00869                   reg1->prep(idRegOf);
00870 
00871                   reg2->prep(idRegOf);
00872 
00873                   SemStr* tgt = new SemStr(*reg2);      // Each actual is deleted
00874 
00875                   substituteCallArgs("c_c", cond_ss, reg1, reg2, tgt);
00876 
00877                   jump->setCondExpr(cond_ss);
00878 
00879                   bool isNull = is_null(null_cmplt);
00880 
00881                   // If isNull, then taken forward or failing backwards anull
00882 
00883                   result.type = isNull ? (((int)target >= 0) ? SCDAT : SCDAN) : SCD;
00884 
00885                   result.rtl = jump;
00886 
00887                   result.numBytes = 4;
00888 
00889               }
00890 
00891               // The following two groups of instructions may or may not be anulling
00892 
00893               // (NCTA). If not, let the low level decoder take care of it.
00894 
00895       
00896       
00897       
00898     } 
00899     goto MATCH_finished_d; 
00900     
00901   MATCH_label_d3: (void)0; /*placeholder for label*/ 
00902     { 
00903       char *name = MATCH_name;
00904       unsigned c_cmplt = addressToPC(MATCH_p);
00905       unsigned im5_11 = 
00906         ((sign_extend((MATCH_w_32_0 >> 16 & 0x1) /* im1_15 at 0 */, 
00907                     1) & 0xfffffff) << 4) + 
00908         (MATCH_w_32_0 >> 17 & 0xf) /* im4_11 at 0 */;
00909       unsigned null_cmplt = addressToPC(MATCH_p);
00910       unsigned r_06 = (MATCH_w_32_0 >> 21 & 0x1f) /* r_06 at 0 */;
00911       unsigned target = 
00912         ((MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */ << 2) + 
00913         ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 12) + 
00914         ((sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 
00915                     1) & 0x7ffff) << 13);
00916       nextPC = 4 + MATCH_p; 
00917       
00918 #line 389 "machine/hppa/decoder.m"
00919        {
00920 
00921                   int condvalue;
00922 
00923                   SemStr* cond_ss = c_c(c_cmplt, condvalue);
00924 
00925                   // Get semantics for the add part (only)
00926 
00927                   RTs = instantiate(pc, name, dis_Num(im5_11), dis_Reg(r_06));
00928 
00929                   HLJcond* jump = new HLJcond(pc, RTs);
00930 
00931                   jump->setCondType(hl_jcond_type[condvalue]);
00932 
00933                   jump->setDest(dis_Num(target + pc + 8));
00934 
00935                   SemStr* imm = dis_Num(im5_11);
00936 
00937                   SemStr* reg = dis_Reg(r_06);
00938 
00939                   reg->prep(idRegOf);
00940 
00941                   SemStr* tgt = new SemStr(*reg);      // Each actual is deleted
00942 
00943                   substituteCallArgs("c_c", cond_ss, imm, reg, tgt);
00944 
00945                   jump->setCondExpr(cond_ss);
00946 
00947                   bool isNull = is_null(null_cmplt);
00948 
00949                   // If isNull, then taken forward or failing backwards anull
00950 
00951                   result.type = isNull ? (((int)target >= 0) ? SCDAT : SCDAN) : SCD;
00952 
00953                   result.rtl = jump;
00954 
00955                   result.numBytes = 4;
00956 
00957               }
00958 
00959       
00960       
00961       
00962     } 
00963     goto MATCH_finished_d; 
00964     
00965   MATCH_label_d4: (void)0; /*placeholder for label*/ 
00966     { 
00967       unsigned bit_cmplt = addressToPC(MATCH_p);
00968       unsigned c_cmplt = addressToPC(MATCH_p);
00969       unsigned null_cmplt = addressToPC(MATCH_p);
00970       unsigned r = (MATCH_w_32_0 >> 16 & 0x1f) /* r_11 at 0 */;
00971       unsigned target = 
00972         ((MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */ << 2) + 
00973         ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 12) + 
00974         ((sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 
00975                     1) & 0x7ffff) << 13);
00976       nextPC = 4 + MATCH_p; 
00977       
00978 #line 332 "machine/hppa/decoder.m"
00979        {
00980 
00981                   int condvalue;
00982 
00983                   SemStr* cond_ss = c_c(c_cmplt, condvalue);
00984 
00985                   HLJcond* jump = new HLJcond(pc, RTs);
00986 
00987                   jump->setDest(dis_Num(target + pc + 8));
00988 
00989                   SemStr* reg = dis_Reg(r);
00990 
00991                   SemStr* mask = dis_c_bit(bit_cmplt);
00992 
00993                   SemStr* exp = new SemStr;
00994 
00995                   *exp << idBitAnd << *mask << *reg;
00996 
00997                   substituteCallArgs("c_c", cond_ss, mask, reg, exp);
00998 
00999                   jump->setCondExpr(cond_ss);
01000 
01001                   bool isNull = is_null(null_cmplt);
01002 
01003                   result.type = isNull ? (((int)target >= 0) ? SCDAT : SCDAN) : SCD;
01004 
01005                   result.rtl = jump;
01006 
01007                   result.numBytes = 4;
01008 
01009               }
01010 
01011               
01012 
01013       
01014       
01015       
01016     } 
01017     goto MATCH_finished_d; 
01018     
01019   MATCH_finished_d: (void)0; /*placeholder for label*/
01020   
01021 }
01022 
01023 #line 499 "machine/hppa/decoder.m"
01024     }
01025     return result;
01026 }
01027 
01028 // Let the low level decoder handle this instruction
01029 void NJMCDecoder::low_level(list<RT*>*& RTs, ADDRESS hostPC, ADDRESS pc,
01030   DecodeResult& result, ADDRESS& nextPC)
01031 {
01032     RTs = decodeLowLevelInstruction(hostPC, pc, result);
01033     if (preInstSem && RTs)
01034         RTs->insert(RTs->begin(), preInstSem->begin(), preInstSem->end());
01035     if (postInstSem && RTs)
01036         RTs->insert(RTs->end(), postInstSem->begin(), postInstSem->end());
01037     result.rtl = new RTL(pc, RTs);
01038     nextPC = hostPC + 4;        // 4 byte instruction
01039     result.numBytes = 4;
01040 }
01041 
01042 SemStr* NJMCDecoder::dis_c_bit(ADDRESS hostpc)
01043 {
01044     SemStr* result;
01045 
01046 
01047 #line 519 "machine/hppa/decoder.m"
01048 { 
01049   dword MATCH_p = 
01050     
01051 #line 519 "machine/hppa/decoder.m"
01052     hostpc
01053     ;
01054   unsigned MATCH_w_32_0;
01055   { 
01056     MATCH_w_32_0 = getDword(MATCH_p); 
01057     if (0 <= (MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */ && 
01058       (MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */ < 48) 
01059       goto MATCH_label_c0;  /*opt-block+*/
01060     else 
01061       switch((MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */) {
01062         case 50: case 51: case 52: case 53: case 54: case 55: case 56: 
01063         case 57: case 58: case 59: case 60: case 61: case 62: case 63: 
01064           goto MATCH_label_c0; break;
01065         case 48: 
01066           
01067 #line 524 "machine/hppa/decoder.m"
01068            {
01069 
01070                       result = instantiateNamedParam( "bitpos_sar", dis_Num(0));
01071 
01072                   }
01073 
01074           
01075           
01076           
01077           break;
01078         case 49: 
01079           if ((MATCH_w_32_0 >> 13 & 0x1) /* d_18 at 0 */ == 0) { 
01080             unsigned p = (MATCH_w_32_0 >> 21 & 0x1f) /* p_06 at 0 */;
01081             
01082 #line 521 "machine/hppa/decoder.m"
01083              {
01084 
01085                         result = instantiateNamedParam( "bitpos_fix", dis_Num(p));
01086 
01087                     }
01088 
01089             
01090             
01091             
01092           } /*opt-block*//*opt-block+*/
01093           else 
01094             goto MATCH_label_c0;  /*opt-block+*/
01095           
01096           break;
01097         default: assert(0);
01098       } /* (MATCH_w_32_0 >> 26 & 0x3f) -- op at 0 --*/ 
01099     
01100   }goto MATCH_finished_c; 
01101   
01102   MATCH_label_c0: (void)0; /*placeholder for label*/ 
01103     assert(0);  /* no match */ 
01104     goto MATCH_finished_c; 
01105     
01106   MATCH_finished_c: (void)0; /*placeholder for label*/
01107   
01108 }
01109 
01110 #line 528 "machine/hppa/decoder.m"
01111     return result;
01112 }
01113 
01114 SemStr* NJMCDecoder::dis_xd(ADDRESS hostpc)
01115 {
01116     SemStr* result;
01117 
01118 
01119 #line 533 "machine/hppa/decoder.m"
01120 { 
01121   dword MATCH_p = 
01122     
01123 #line 533 "machine/hppa/decoder.m"
01124     hostpc
01125     ;
01126   unsigned MATCH_w_32_0;
01127   { 
01128     MATCH_w_32_0 = getDword(MATCH_p); 
01129     
01130       switch((MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */) {
01131         case 0: case 1: case 2: case 4: case 5: case 6: case 7: case 8: 
01132         case 10: case 12: case 13: case 14: case 15: case 20: case 21: 
01133         case 22: case 23: case 28: case 29: case 30: case 31: case 32: 
01134         case 33: case 34: case 35: case 36: case 37: case 38: case 39: 
01135         case 40: case 41: case 42: case 43: case 44: case 45: case 46: 
01136         case 47: case 48: case 49: case 50: case 51: case 52: case 53: 
01137         case 54: case 55: case 58: case 59: case 60: case 61: case 62: 
01138         case 63: 
01139           goto MATCH_label_b0; break;
01140         case 3: 
01141           if ((MATCH_w_32_0 >> 12 & 0x1) /* addr_19 at 0 */ == 1) 
01142             if (8 <= (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ && 
01143               (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ < 16) { 
01144               unsigned i = 
01145                 (sign_extend((MATCH_w_32_0 & 0x1) /* i_31 at 0 */, 1) << 4) + 
01146                 (MATCH_w_32_0 >> 1 & 0xf) /* im4_27 at 0 */;
01147               
01148 #line 553 "machine/hppa/decoder.m"
01149                {
01150 
01151                           result = instantiateNamedParam( "s_addr_r_im"   , dis_Num(i));
01152 
01153                     }
01154 
01155               
01156               
01157               
01158             } /*opt-block*//*opt-block+*/
01159             else 
01160               goto MATCH_label_b4;  /*opt-block+*/ /*opt-block+*/
01161           else 
01162             
01163               switch((MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */) {
01164                 case 0: 
01165                   if ((MATCH_w_32_0 >> 13 & 0x1) /* u_18 at 0 */ == 1) { 
01166                     unsigned x = (MATCH_w_32_0 >> 16 & 0x1f) /* x_11 at 0 */;
01167                     
01168 #line 538 "machine/hppa/decoder.m"
01169                      {
01170 
01171                                 result = instantiateNamedParam( "x_addr_s_byte" , dis_Reg(x));
01172 
01173                           }
01174 
01175                     
01176                     
01177                     
01178                   } /*opt-block*//*opt-block+*/
01179                   else 
01180                     goto MATCH_label_b1;  /*opt-block+*/
01181                   
01182                   break;
01183                 case 1: 
01184                   if ((MATCH_w_32_0 >> 13 & 0x1) /* u_18 at 0 */ == 1) { 
01185                     unsigned x = (MATCH_w_32_0 >> 16 & 0x1f) /* x_11 at 0 */;
01186                     
01187 #line 541 "machine/hppa/decoder.m"
01188                      {
01189 
01190                                 result = instantiateNamedParam( "x_addr_s_hwrd" , dis_Reg(x));
01191 
01192                           }
01193 
01194                     
01195                     
01196                     
01197                   } /*opt-block*//*opt-block+*/
01198                   else 
01199                     goto MATCH_label_b1;  /*opt-block+*/
01200                   
01201                   break;
01202                 case 2: case 6: 
01203                   if ((MATCH_w_32_0 >> 13 & 0x1) /* u_18 at 0 */ == 1) 
01204                     goto MATCH_label_b2;  /*opt-block+*/
01205                   else 
01206                     goto MATCH_label_b1;  /*opt-block+*/
01207                   
01208                   break;
01209                 case 3: case 4: case 5: case 7: 
01210                   if ((MATCH_w_32_0 >> 13 & 0x1) /* u_18 at 0 */ == 1) 
01211                     goto MATCH_label_b3;  /*opt-block+*/
01212                   else 
01213                     goto MATCH_label_b1;  /*opt-block+*/
01214                   
01215                   break;
01216                 case 8: case 9: case 10: case 11: case 12: case 13: case 14: 
01217                 case 15: 
01218                   goto MATCH_label_b0; break;
01219                 default: assert(0);
01220               } /* (MATCH_w_32_0 >> 6 & 0xf) -- ext4_22 at 0 --*/  
01221           break;
01222         case 9: 
01223           if ((MATCH_w_32_0 >> 7 & 0x3) /* uid2_23 at 0 */ == 0) 
01224             if ((MATCH_w_32_0 >> 12 & 0x1) /* addr_19 at 0 */ == 1) 
01225               goto MATCH_label_b4;  /*opt-block+*/
01226             else 
01227               if ((MATCH_w_32_0 >> 13 & 0x1) /* u_18 at 0 */ == 1 && 
01228                 (0 <= (MATCH_w_32_0 >> 9 & 0x1) /* addr_22 at 0 */ && 
01229                 (MATCH_w_32_0 >> 9 & 0x1) /* addr_22 at 0 */ < 2)) 
01230                 goto MATCH_label_b2;  /*opt-block+*/
01231               else 
01232                 goto MATCH_label_b1;  /*opt-block+*/ /*opt-block+*/ 
01233           else 
01234             goto MATCH_label_b0;  /*opt-block+*/
01235           break;
01236         case 11: 
01237           if ((MATCH_w_32_0 >> 7 & 0x3) /* uid2_23 at 0 */ == 0) 
01238             if ((MATCH_w_32_0 >> 12 & 0x1) /* addr_19 at 0 */ == 1) 
01239               goto MATCH_label_b4;  /*opt-block+*/
01240             else 
01241               if ((MATCH_w_32_0 >> 13 & 0x1) /* u_18 at 0 */ == 1 && 
01242                 (0 <= (MATCH_w_32_0 >> 9 & 0x1) /* addr_22 at 0 */ && 
01243                 (MATCH_w_32_0 >> 9 & 0x1) /* addr_22 at 0 */ < 2)) 
01244                 goto MATCH_label_b3;  /*opt-block+*/
01245               else 
01246                 goto MATCH_label_b1;  /*opt-block+*/ /*opt-block+*/ 
01247           else 
01248             goto MATCH_label_b0;  /*opt-block+*/
01249           break;
01250         case 16: case 17: case 18: case 19: case 24: case 25: case 26: 
01251         case 27: 
01252           { 
01253             unsigned i = 
01254               (sign_extend((MATCH_w_32_0 & 0x1) /* i_31 at 0 */, 1) << 13) + 
01255               (MATCH_w_32_0 >> 1 & 0x1fff) /* im13_18 at 0 */;
01256             
01257 #line 556 "machine/hppa/decoder.m"
01258              {
01259 
01260                         result = instantiateNamedParam( "l_addr_16_old" , dis_Num(i));
01261 
01262                   }
01263 
01264             
01265             
01266             
01267           }
01268           
01269           break;
01270         case 56: case 57: 
01271           { 
01272             unsigned i = 
01273               ((MATCH_w_32_0 >> 2 & 0x1) /* w_29 at 0 */ << 10) + 
01274               ((MATCH_w_32_0 >> 16 & 0x1f) /* w5_11 at 0 */ << 11) + 
01275               (sign_extend((MATCH_w_32_0 & 0x1) /* w_31 at 0 */, 1) << 16) + 
01276               (MATCH_w_32_0 >> 3 & 0x3ff) /* w10_19 at 0 */;
01277             
01278 #line 559 "machine/hppa/decoder.m"
01279              {
01280 
01281                         result = instantiateNamedParam( "l_addr_17_old" , dis_Num(i));
01282 
01283                   }
01284 
01285             
01286             
01287             
01288           }
01289           
01290           break;
01291         default: assert(0);
01292       } /* (MATCH_w_32_0 >> 26 & 0x3f) -- op at 0 --*/ 
01293     
01294   }goto MATCH_finished_b; 
01295   
01296   MATCH_label_b0: (void)0; /*placeholder for label*/ 
01297     assert(0);  /* no match */ 
01298     goto MATCH_finished_b; 
01299     
01300   MATCH_label_b1: (void)0; /*placeholder for label*/ 
01301     { 
01302       unsigned x = (MATCH_w_32_0 >> 16 & 0x1f) /* x_11 at 0 */;
01303       
01304 #line 535 "machine/hppa/decoder.m"
01305        {
01306 
01307                   result = instantiateNamedParam( "x_addr_nots"   , dis_Reg(x));
01308 
01309             }
01310 
01311       
01312       
01313       
01314     } 
01315     goto MATCH_finished_b; 
01316     
01317   MATCH_label_b2: (void)0; /*placeholder for label*/ 
01318     { 
01319       unsigned x = (MATCH_w_32_0 >> 16 & 0x1f) /* x_11 at 0 */;
01320       
01321 #line 544 "machine/hppa/decoder.m"
01322        {
01323 
01324                   result = instantiateNamedParam( "x_addr_s_word" , dis_Reg(x));
01325 
01326             }
01327 
01328       
01329       
01330       
01331     } 
01332     goto MATCH_finished_b; 
01333     
01334   MATCH_label_b3: (void)0; /*placeholder for label*/ 
01335     { 
01336       unsigned x = (MATCH_w_32_0 >> 16 & 0x1f) /* x_11 at 0 */;
01337       
01338 #line 547 "machine/hppa/decoder.m"
01339        {
01340 
01341                   result = instantiateNamedParam( "x_addr_s_dwrd" , dis_Reg(x));
01342 
01343             }
01344 
01345       
01346       
01347       
01348     } 
01349     goto MATCH_finished_b; 
01350     
01351   MATCH_label_b4: (void)0; /*placeholder for label*/ 
01352     { 
01353       unsigned i = 
01354         (sign_extend((MATCH_w_32_0 >> 16 & 0x1) /* im1_15 at 0 */, 1) << 4) + 
01355         (MATCH_w_32_0 >> 17 & 0xf) /* im4_11 at 0 */;
01356       
01357 #line 550 "machine/hppa/decoder.m"
01358        {
01359 
01360                   result = instantiateNamedParam( "s_addr_im_r"   , dis_Num(i));
01361 
01362             }
01363 
01364       
01365       
01366       
01367     } 
01368     goto MATCH_finished_b; 
01369     
01370   MATCH_finished_b: (void)0; /*placeholder for label*/
01371   
01372 }
01373 
01374 #line 563 "machine/hppa/decoder.m"
01375     return result;
01376 }
01377 
01378 /*==============================================================================
01379  * FUNCTION:        c_addr
01380  * OVERVIEW:        Processes completers for various addressing modes
01381  * NOTE:            I think we need to pass the base register to this function
01382  * PARAMETERS:      hostpc - the instruction stream address of the dynamic
01383  *                    address
01384  *                  ssb - SemStr* for the base register that gets modified
01385  *                  ssx - SemStr* for the amount to be added to ssb
01386  * RETURNS:         the SemStr representation of the given address
01387  *============================================================================*/
01388 SemStr* NJMCDecoder::dis_c_addr(ADDRESS hostPC)
01389 {
01390     SemStr* result = NULL;
01391 
01392 
01393 #line 578 "machine/hppa/decoder.m"
01394 { 
01395   dword MATCH_p = 
01396     
01397 #line 578 "machine/hppa/decoder.m"
01398     hostPC
01399     ;
01400   unsigned MATCH_w_32_0;
01401   { 
01402     MATCH_w_32_0 = getDword(MATCH_p); 
01403     if (28 <= (MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */ && 
01404       (MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */ < 64) 
01405       goto MATCH_label_a0;  /*opt-block+*/
01406     else 
01407       switch((MATCH_w_32_0 >> 26 & 0x3f) /* op at 0 */) {
01408         case 0: case 1: case 2: case 4: case 5: case 6: case 7: case 8: 
01409         case 10: case 12: case 13: case 14: case 15: case 20: case 21: 
01410         case 22: case 23: 
01411           goto MATCH_label_a0; break;
01412         case 3: 
01413           if ((MATCH_w_32_0 >> 12 & 0x1) /* addr_19 at 0 */ == 1) 
01414             if ((MATCH_w_32_0 >> 5 & 0x1) /* m_26 at 0 */ == 1) 
01415               if ((MATCH_w_32_0 >> 13 & 0x1) /* a_18 at 0 */ == 1) 
01416                 if (12 <= (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ && 
01417                   (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ < 14) 
01418                   
01419 #line 593 "machine/hppa/decoder.m"
01420                   
01421 
01422                            { result = instantiateNamedParam( "c_y_addr_me" ); }
01423 
01424                   
01425                    /*opt-block+*/
01426                 else 
01427                   goto MATCH_label_a5;  /*opt-block+*/ /*opt-block+*/
01428               else 
01429                 if (12 <= (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ && 
01430                   (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ < 14) 
01431                   
01432 #line 591 "machine/hppa/decoder.m"
01433                   
01434 
01435                            { result = instantiateNamedParam( "c_y_addr_m" ); }
01436 
01437                   
01438                    /*opt-block+*/
01439                 else 
01440                   goto MATCH_label_a4;  /*opt-block+*/ /*opt-block+*/ 
01441             else 
01442               if (12 <= (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ && 
01443                 (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ < 14) 
01444                 if ((MATCH_w_32_0 >> 13 & 0x1) /* a_18 at 0 */ == 1) 
01445                   
01446 #line 589 "machine/hppa/decoder.m"
01447                   
01448 
01449                            { result = instantiateNamedParam( "c_y_addr_e" ); }
01450 
01451                   
01452                    /*opt-block+*/
01453                 else 
01454                   
01455 #line 595 "machine/hppa/decoder.m"
01456                   
01457 
01458                            { result = instantiateNamedParam( "c_y_addr_none" ); }
01459 
01460                   
01461                    /*opt-block+*/ /*opt-block+*/
01462               else 
01463                 goto MATCH_label_a3;  /*opt-block+*/  
01464           else 
01465             if (0 <= (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ && 
01466               (MATCH_w_32_0 >> 6 & 0xf) /* ext4_22 at 0 */ < 8) 
01467               if ((MATCH_w_32_0 >> 5 & 0x1) /* m_26 at 0 */ == 1) 
01468                 goto MATCH_label_a2;  /*opt-block+*/
01469               else 
01470                 goto MATCH_label_a1;  /*opt-block+*/ /*opt-block+*/
01471             else 
01472               goto MATCH_label_a0;  /*opt-block+*/ 
01473           break;
01474         case 9: case 11: 
01475           if ((MATCH_w_32_0 >> 7 & 0x3) /* uid2_23 at 0 */ == 0) 
01476             if ((MATCH_w_32_0 >> 12 & 0x1) /* addr_19 at 0 */ == 1) 
01477               if ((MATCH_w_32_0 >> 5 & 0x1) /* m_26 at 0 */ == 1) 
01478                 if ((MATCH_w_32_0 >> 13 & 0x1) /* a_18 at 0 */ == 1 && 
01479                   (0 <= (MATCH_w_32_0 >> 9 & 0x1) /* addr_22 at 0 */ && 
01480                   (MATCH_w_32_0 >> 9 & 0x1) /* addr_22 at 0 */ < 2)) 
01481                   goto MATCH_label_a5;  /*opt-block+*/
01482                 else 
01483                   goto MATCH_label_a4;  /*opt-block+*/ /*opt-block+*/
01484               else 
01485                 goto MATCH_label_a3;  /*opt-block+*/ 
01486             else 
01487               if ((MATCH_w_32_0 >> 5 & 0x1) /* m_26 at 0 */ == 1 && 
01488                 (0 <= (MATCH_w_32_0 >> 9 & 0x1) /* addr_22 at 0 */ && 
01489                 (MATCH_w_32_0 >> 9 & 0x1) /* addr_22 at 0 */ < 2)) 
01490                 goto MATCH_label_a2;  /*opt-block+*/
01491               else 
01492                 goto MATCH_label_a1;  /*opt-block+*/ /*opt-block+*/ 
01493           else 
01494             goto MATCH_label_a0;  /*opt-block+*/
01495           break;
01496         case 16: case 17: case 18: case 19: case 24: case 25: case 26: 
01497         case 27: 
01498           
01499 #line 597 "machine/hppa/decoder.m"
01500           
01501 
01502                  { result = instantiateNamedParam( "c_l_addr_none" ); }
01503 
01504           
01505           
01506           
01507           break;
01508         default: assert(0);
01509       } /* (MATCH_w_32_0 >> 26 & 0x3f) -- op at 0 --*/ 
01510     
01511   }goto MATCH_finished_a; 
01512   
01513   MATCH_label_a0: (void)0; /*placeholder for label*/ 
01514     assert(0);  /* no match */ 
01515     goto MATCH_finished_a; 
01516     
01517   MATCH_label_a1: (void)0; /*placeholder for label*/ 
01518     
01519 #line 587 "machine/hppa/decoder.m"
01520     
01521 
01522              { result = instantiateNamedParam( "c_x_addr_notm" ); }
01523 
01524     
01525      
01526     goto MATCH_finished_a; 
01527     
01528   MATCH_label_a2: (void)0; /*placeholder for label*/ 
01529     
01530 #line 585 "machine/hppa/decoder.m"
01531     
01532 
01533              { result = instantiateNamedParam( "c_x_addr_m" ); }
01534 
01535     
01536      
01537     goto MATCH_finished_a; 
01538     
01539   MATCH_label_a3: (void)0; /*placeholder for label*/ 
01540     
01541 #line 583 "machine/hppa/decoder.m"
01542     
01543 
01544              { result = instantiateNamedParam( "c_s_addr_notm" ); }
01545 
01546     
01547      
01548     goto MATCH_finished_a; 
01549     
01550   MATCH_label_a4: (void)0; /*placeholder for label*/ 
01551     
01552 #line 581 "machine/hppa/decoder.m"
01553     
01554 
01555              { result = instantiateNamedParam( "c_s_addr_ma" ); }
01556 
01557     
01558      
01559     goto MATCH_finished_a; 
01560     
01561   MATCH_label_a5: (void)0; /*placeholder for label*/ 
01562     
01563 #line 579 "machine/hppa/decoder.m"
01564     
01565 
01566              { result = instantiateNamedParam( "c_s_addr_mb" ); }
01567 
01568     
01569      
01570     goto MATCH_finished_a; 
01571     
01572   MATCH_finished_a: (void)0; /*placeholder for label*/
01573   
01574 }
01575 
01576 #line 601 "machine/hppa/decoder.m"
01577     return result;
01578 }
01579 
01580 SemStr* NJMCDecoder::dis_c_wcr(unsigned hostPC)
01581 {
01582     return 0;
01583 }
01584 
01585 SemStr* NJMCDecoder::dis_ct(unsigned hostPC)
01586 {
01587     return 0;
01588 }
01589 
01590 SemStr* NJMCDecoder::dis_Freg(int regNum, int fmt)
01591 {
01592     int r;          // Final register number
01593     switch (fmt) {
01594         case 0:     // SGL
01595             r = regNum + 64;
01596             break;
01597         case 1:     // DBL
01598             r = regNum + 32;
01599             break;
01600         case 2:     // QUAD
01601             r = regNum + 128;
01602             break;
01603         default:
01604             printf("Error decoding floating point register %d with format %d\n",
01605               regNum, fmt);
01606             r = 0;
01607     }
01608     SemStr* ss = new SemStr;
01609     *ss << idIntConst << r;
01610     return ss;
01611 }
01612 
01613 SemStr* NJMCDecoder::dis_Creg(int regNum)
01614 {
01615     SemStr* ss = new SemStr;
01616     *ss << idIntConst << (regNum + 256);
01617     return ss;
01618 }
01619 
01620 SemStr* NJMCDecoder::dis_Sreg(int regNum)
01621 {
01622     SemStr* ss = new SemStr;
01623     *ss << idIntConst << regNum;
01624     return ss;
01625 }
01626 
01627 /*==============================================================================
01628  * FUNCTION:      isFuncPrologue()
01629  * OVERVIEW:      Check to see if the instructions at the given offset match
01630  *                  any callee prologue, i.e. does it look like this offset
01631  *                  is a pointer to a function?
01632  * PARAMETERS:    hostPC - pointer to the code in question (native address)
01633  * RETURNS:       True if a match found
01634  *============================================================================*/
01635 bool isFuncPrologue(ADDRESS hostPC)
01636 {
01637 #if 0
01638     int hiVal, loVal, reg, locals;
01639     if ((InstructionPatterns::new_reg_win(prog.csrSrc,hostPC, locals)) != NULL)
01640             return true;
01641     if ((InstructionPatterns::new_reg_win_large(prog.csrSrc, hostPC,
01642         hiVal, loVal, reg)) != NULL)
01643             return true;
01644     if ((InstructionPatterns::same_reg_win(prog.csrSrc, hostPC, locals))
01645         != NULL)
01646             return true;
01647     if ((InstructionPatterns::same_reg_win_large(prog.csrSrc, hostPC,
01648         hiVal, loVal, reg)) != NULL)
01649             return true;
01650 #endif
01651 
01652     return false;
01653 }
01654 
01655 
01656 

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