| OLD | NEW | 
| (Empty) |  | 
 |    1 // Copyright 2011 the V8 project authors. All rights reserved. | 
 |    2 // | 
 |    3 // Copyright IBM Corp. 2012, 2013. All rights reserved. | 
 |    4 // | 
 |    5 // Use of this source code is governed by a BSD-style license that can be | 
 |    6 // found in the LICENSE file. | 
 |    7  | 
 |    8 #ifndef V8_PPC_CONSTANTS_PPC_H_ | 
 |    9 #define V8_PPC_CONSTANTS_PPC_H_ | 
 |   10  | 
 |   11 namespace v8 { | 
 |   12 namespace internal { | 
 |   13  | 
 |   14 // Number of registers | 
 |   15 const int kNumRegisters = 32; | 
 |   16  | 
 |   17 // FP support. | 
 |   18 const int kNumFPDoubleRegisters = 32; | 
 |   19 const int kNumFPRegisters = kNumFPDoubleRegisters; | 
 |   20  | 
 |   21 const int kNoRegister = -1; | 
 |   22  | 
 |   23 // sign-extend the least significant 16-bits of value <imm> | 
 |   24 #define SIGN_EXT_IMM16(imm) ((static_cast<int>(imm) << 16) >> 16) | 
 |   25  | 
 |   26 // sign-extend the least significant 26-bits of value <imm> | 
 |   27 #define SIGN_EXT_IMM26(imm) ((static_cast<int>(imm) << 6) >> 6) | 
 |   28  | 
 |   29 // ----------------------------------------------------------------------------- | 
 |   30 // Conditions. | 
 |   31  | 
 |   32 // Defines constants and accessor classes to assemble, disassemble and | 
 |   33 // simulate PPC instructions. | 
 |   34 // | 
 |   35 // Section references in the code refer to the "PowerPC Microprocessor | 
 |   36 // Family: The Programmer.s Reference Guide" from 10/95 | 
 |   37 // https://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF77852
     5699600741775/$file/prg.pdf | 
 |   38 // | 
 |   39  | 
 |   40 // Constants for specific fields are defined in their respective named enums. | 
 |   41 // General constants are in an anonymous enum in class Instr. | 
 |   42 enum Condition { | 
 |   43   kNoCondition = -1, | 
 |   44   eq         =  0,         // Equal. | 
 |   45   ne         =  1,         // Not equal. | 
 |   46   ge         =  2,         // Greater or equal. | 
 |   47   lt         =  3,         // Less than. | 
 |   48   gt         =  4,         // Greater than. | 
 |   49   le         =  5,         // Less then or equal | 
 |   50   unordered  =  6,         // Floating-point unordered | 
 |   51   ordered    =  7, | 
 |   52   overflow   =  8,         // Summary overflow | 
 |   53   nooverflow =  9, | 
 |   54   al         = 10          // Always. | 
 |   55 }; | 
 |   56  | 
 |   57  | 
 |   58 inline Condition NegateCondition(Condition cond) { | 
 |   59   ASSERT(cond != al); | 
 |   60   return static_cast<Condition>(cond ^ ne); | 
 |   61 } | 
 |   62  | 
 |   63  | 
 |   64 // Commute a condition such that {a cond b == b cond' a}. | 
 |   65 inline Condition CommuteCondition(Condition cond) { | 
 |   66   switch (cond) { | 
 |   67     case lt: | 
 |   68       return gt; | 
 |   69     case gt: | 
 |   70       return lt; | 
 |   71     case ge: | 
 |   72       return le; | 
 |   73     case le: | 
 |   74       return ge; | 
 |   75     default: | 
 |   76       return cond; | 
 |   77   } | 
 |   78 } | 
 |   79  | 
 |   80 // ----------------------------------------------------------------------------- | 
 |   81 // Instructions encoding. | 
 |   82  | 
 |   83 // Instr is merely used by the Assembler to distinguish 32bit integers | 
 |   84 // representing instructions from usual 32 bit values. | 
 |   85 // Instruction objects are pointers to 32bit values, and provide methods to | 
 |   86 // access the various ISA fields. | 
 |   87 typedef int32_t Instr; | 
 |   88  | 
 |   89 // Opcodes as defined in section 4.2 table 34 (32bit PowerPC) | 
 |   90 enum Opcode { | 
 |   91   TWI     =  3 << 26,  // Trap Word Immediate | 
 |   92   MULLI   =  7 << 26,  // Multiply Low Immediate | 
 |   93   SUBFIC  =  8 << 26,  // Subtract from Immediate Carrying | 
 |   94   CMPLI   = 10 << 26,  // Compare Logical Immediate | 
 |   95   CMPI    = 11 << 26,  // Compare Immediate | 
 |   96   ADDIC   = 12 << 26,  // Add Immediate Carrying | 
 |   97   ADDICx  = 13 << 26,  // Add Immediate Carrying and Record | 
 |   98   ADDI    = 14 << 26,  // Add Immediate | 
 |   99   ADDIS   = 15 << 26,  // Add Immediate Shifted | 
 |  100   BCX     = 16 << 26,  // Branch Conditional | 
 |  101   SC      = 17 << 26,  // System Call | 
 |  102   BX      = 18 << 26,  // Branch | 
 |  103   EXT1    = 19 << 26,  // Extended code set 1 | 
 |  104   RLWIMIX = 20 << 26,  // Rotate Left Word Immediate then Mask Insert | 
 |  105   RLWINMX = 21 << 26,  // Rotate Left Word Immediate then AND with Mask | 
 |  106   RLWNMX  = 23 << 26,  // Rotate Left Word then AND with Mask | 
 |  107   ORI     = 24 << 26,  // OR Immediate | 
 |  108   ORIS    = 25 << 26,  // OR Immediate Shifted | 
 |  109   XORI    = 26 << 26,  // XOR Immediate | 
 |  110   XORIS   = 27 << 26,  // XOR Immediate Shifted | 
 |  111   ANDIx   = 28 << 26,  // AND Immediate | 
 |  112   ANDISx  = 29 << 26,  // AND Immediate Shifted | 
 |  113   EXT5    = 30 << 26,  // Extended code set 5 - 64bit only | 
 |  114   EXT2    = 31 << 26,  // Extended code set 2 | 
 |  115   LWZ     = 32 << 26,  // Load Word and Zero | 
 |  116   LWZU    = 33 << 26,  // Load Word with Zero Update | 
 |  117   LBZ     = 34 << 26,  // Load Byte and Zero | 
 |  118   LBZU    = 35 << 26,  // Load Byte and Zero with Update | 
 |  119   STW     = 36 << 26,  // Store | 
 |  120   STWU    = 37 << 26,  // Store Word with Update | 
 |  121   STB     = 38 << 26,  // Store Byte | 
 |  122   STBU    = 39 << 26,  // Store Byte with Update | 
 |  123   LHZ     = 40 << 26,  // Load Half and Zero | 
 |  124   LHZU    = 41 << 26,  // Load Half and Zero with Update | 
 |  125   LHA     = 42 << 26,  // Load Half Algebraic | 
 |  126   LHAU    = 43 << 26,  // Load Half Algebraic with Update | 
 |  127   STH     = 44 << 26,  // Store Half | 
 |  128   STHU    = 45 << 26,  // Store Half with Update | 
 |  129   LMW     = 46 << 26,  // Load Multiple Word | 
 |  130   STMW    = 47 << 26,  // Store Multiple Word | 
 |  131   LFS     = 48 << 26,  // Load Floating-Point Single | 
 |  132   LFSU    = 49 << 26,  // Load Floating-Point Single with Update | 
 |  133   LFD     = 50 << 26,  // Load Floating-Point Double | 
 |  134   LFDU    = 51 << 26,  // Load Floating-Point Double with Update | 
 |  135   STFS    = 52 << 26,  // Store Floating-Point Single | 
 |  136   STFSU   = 53 << 26,  // Store Floating-Point Single with Update | 
 |  137   STFD    = 54 << 26,  // Store Floating-Point Double | 
 |  138   STFDU   = 55 << 26,  // Store Floating-Point Double with Update | 
 |  139   LD      = 58 << 26,  // Load Double Word | 
 |  140   EXT3    = 59 << 26,  // Extended code set 3 | 
 |  141   STD     = 62 << 26,  // Store Double Word (optionally with Update) | 
 |  142   EXT4    = 63 << 26   // Extended code set 4 | 
 |  143 }; | 
 |  144  | 
 |  145 // Bits 10-1 | 
 |  146 enum OpcodeExt1 { | 
 |  147   MCRF   = 0 << 1,    // Move Condition Register Field | 
 |  148   BCLRX  = 16 << 1,   // Branch Conditional Link Register | 
 |  149   CRNOR  = 33 << 1,   // Condition Register NOR) | 
 |  150   RFI    = 50 << 1,   // Return from Interrupt | 
 |  151   CRANDC = 129 << 1,  // Condition Register AND with Complement | 
 |  152   ISYNC  = 150 << 1,  // Instruction Synchronize | 
 |  153   CRXOR  = 193 << 1,  // Condition Register XOR | 
 |  154   CRNAND = 225 << 1,  // Condition Register NAND | 
 |  155   CRAND  = 257 << 1,  // Condition Register AND | 
 |  156   CREQV  = 289 << 1,  // Condition Register Equivalent | 
 |  157   CRORC  = 417 << 1,  // Condition Register OR with Complement | 
 |  158   CROR   = 449 << 1,  // Condition Register OR | 
 |  159   BCCTRX = 528 << 1   // Branch Conditional to Count Register | 
 |  160 }; | 
 |  161  | 
 |  162 // Bits 9-1 or 10-1 | 
 |  163 enum OpcodeExt2 { | 
 |  164   CMP = 0 << 1, | 
 |  165   TW = 4 << 1, | 
 |  166   SUBFCX = 8 << 1, | 
 |  167   ADDCX = 10 << 1, | 
 |  168   MULHWUX = 11 << 1, | 
 |  169   MFCR = 19 << 1, | 
 |  170   LWARX = 20 << 1, | 
 |  171   LDX = 21 << 1, | 
 |  172   LWZX = 23 << 1,    // load word zero w/ x-form | 
 |  173   SLWX = 24 << 1, | 
 |  174   CNTLZWX = 26 << 1, | 
 |  175   SLDX = 27 << 1, | 
 |  176   ANDX = 28 << 1, | 
 |  177   CMPL = 32 << 1, | 
 |  178   SUBFX = 40 << 1, | 
 |  179   LDUX = 53 << 1, | 
 |  180   DCBST = 54 << 1, | 
 |  181   LWZUX = 55 << 1,   // load word zero w/ update x-form | 
 |  182   CNTLZDX = 58 << 1, | 
 |  183   ANDCX = 60 << 1, | 
 |  184   MULHWX = 75 << 1, | 
 |  185   DCBF = 86 << 1, | 
 |  186   LBZX = 87 << 1,    // load byte zero w/ x-form | 
 |  187   NEGX = 104 << 1, | 
 |  188   LBZUX = 119 << 1,  // load byte zero w/ update x-form | 
 |  189   NORX = 124 << 1, | 
 |  190   SUBFEX = 136 << 1, | 
 |  191   ADDEX = 138 << 1, | 
 |  192   STDX = 149 << 1, | 
 |  193   STWX = 151 << 1,    // store word w/ x-form | 
 |  194   STDUX = 181 << 1, | 
 |  195   STWUX = 183 << 1,   // store word w/ update x-form | 
 |  196 /* | 
 |  197   MTCRF | 
 |  198   MTMSR | 
 |  199   STWCXx | 
 |  200   SUBFZEX | 
 |  201 */ | 
 |  202   ADDZEX = 202 << 1,  // Add to Zero Extended | 
 |  203 /* | 
 |  204   MTSR | 
 |  205 */ | 
 |  206   STBX = 215 << 1,    // store byte w/ x-form | 
 |  207   MULLD  = 233 << 1,  // Multiply Low Double Word | 
 |  208   MULLW  = 235 << 1,  // Multiply Low Word | 
 |  209   STBUX = 247 << 1,   // store byte w/ update x-form | 
 |  210   ADDX = 266 << 1,    // Add | 
 |  211   LHZX = 279 << 1,    // load half-word zero w/ x-form | 
 |  212   LHZUX = 311 << 1,   // load half-word zero w/ update x-form | 
 |  213   LHAX =343 << 1,     // load half-word algebraic w/ x-form | 
 |  214   LHAUX = 375 << 1,   // load half-word algebraic w/ update x-form | 
 |  215   XORX = 316 << 1,    // Exclusive OR | 
 |  216   MFSPR = 339 <<1,    // Move from Special-Purpose-Register | 
 |  217   STHX = 407 << 1,    // store half-word w/ x-form | 
 |  218   STHUX = 439 << 1,   // store half-word w/ update x-form | 
 |  219   ORX = 444 << 1,     // Or | 
 |  220   MTSPR = 467 <<1,    // Move to Special-Purpose-Register | 
 |  221   DIVD  = 489 << 1,   // Divide Double Word | 
 |  222   DIVW  = 491 << 1,   // Divide Word | 
 |  223  | 
 |  224   // Below represent bits 10-1  (any value >= 512) | 
 |  225   LFSX = 535 << 1,    // load float-single w/ x-form | 
 |  226   SRWX = 536 << 1,    // Shift Right Word | 
 |  227   SRDX = 539 << 1,    // Shift Right Double Word | 
 |  228   LFSUX = 567 << 1,   // load float-single w/ update x-form | 
 |  229   SYNC = 598 << 1,    // Synchronize | 
 |  230   LFDX = 599 << 1,    // load float-double w/ x-form | 
 |  231   LFDUX = 631 << 1,   // load float-double w/ update X-form | 
 |  232   STFSX = 663 << 1,   // store float-single w/ x-form | 
 |  233   STFSUX = 695 << 1,  // store float-single w/ update x-form | 
 |  234   STFDX = 727 << 1,   // store float-double w/ x-form | 
 |  235   STFDUX = 759 << 1,  // store float-double w/ update x-form | 
 |  236   SRAW = 792 << 1,    // Shift Right Algebraic Word | 
 |  237   SRAD = 794 << 1,    // Shift Right Algebraic Double Word | 
 |  238   SRAWIX = 824 << 1,  // Shift Right Algebraic Word Immediate | 
 |  239   SRADIX = 413 << 2,  // Shift Right Algebraic Double Word Immediate | 
 |  240   EXTSH = 922 << 1,   // Extend Sign Halfword | 
 |  241   EXTSB = 954 << 1,   // Extend Sign Byte | 
 |  242   ICBI = 982 << 1,    // Instruction Cache Block Invalidate | 
 |  243   EXTSW = 986 << 1    // Extend Sign Word | 
 |  244 }; | 
 |  245  | 
 |  246 // Some use Bits 10-1 and other only 5-1 for the opcode | 
 |  247 enum OpcodeExt4 { | 
 |  248   // Bits 5-1 | 
 |  249   FDIV   = 18 << 1,   // Floating Divide | 
 |  250   FSUB   = 20 << 1,   // Floating Subtract | 
 |  251   FADD   = 21 << 1,   // Floating Add | 
 |  252   FSQRT  = 22 << 1,   // Floating Square Root | 
 |  253   FSEL   = 23 << 1,   // Floating Select | 
 |  254   FMUL   = 25 << 1,   // Floating Multiply | 
 |  255   FMSUB  = 28 << 1,   // Floating Multiply-Subtract | 
 |  256   FMADD  = 29 << 1,   // Floating Multiply-Add | 
 |  257  | 
 |  258   // Bits 10-1 | 
 |  259   FCMPU  =   0 << 1,  // Floating Compare Unordered | 
 |  260   FRSP   =  12 << 1,  // Floating-Point Rounding | 
 |  261   FCTIW  =  14 << 1,  // Floating Convert to Integer Word X-form | 
 |  262   FCTIWZ =  15 << 1,  // Floating Convert to Integer Word with Round to Zero | 
 |  263   FNEG   =  40 << 1,  // Floating Negate | 
 |  264   MCRFS  =  64 << 1,  // Move to Condition Register from FPSCR | 
 |  265   FMR    =  72 << 1,  // Floating Move Register | 
 |  266   MTFSFI = 134 << 1,  // Move to FPSCR Field Immediate | 
 |  267   FABS   = 264 << 1,  // Floating Absolute Value | 
 |  268   FRIM   = 488 << 1,  // Floating Round to Integer Minus | 
 |  269   MFFS   = 583 << 1,  // move from FPSCR x-form | 
 |  270   MTFSF  = 711 << 1,  // move to FPSCR fields XFL-form | 
 |  271   FCFID  = 846 << 1,  // Floating convert from integer doubleword | 
 |  272   FCTID  = 814 << 1,  // Floating convert from integer doubleword | 
 |  273   FCTIDZ = 815 << 1   // Floating convert from integer doubleword | 
 |  274 }; | 
 |  275  | 
 |  276 enum OpcodeExt5 { | 
 |  277   // Bits 4-2 | 
 |  278   RLDICL = 0 << 1,    // Rotate Left Double Word Immediate then Clear Left | 
 |  279   RLDICR = 2 << 1,    // Rotate Left Double Word Immediate then Clear Right | 
 |  280   RLDIC  = 4 << 1,    // Rotate Left Double Word Immediate then Clear | 
 |  281   RLDIMI = 6 << 1,    // Rotate Left Double Word Immediate then Mask Insert | 
 |  282   // Bits 4-1 | 
 |  283   RLDCL  = 8 << 1,    // Rotate Left Double Word then Clear Left | 
 |  284   RLDCR  = 9 << 1     // Rotate Left Double Word then Clear Right | 
 |  285 }; | 
 |  286  | 
 |  287 // Instruction encoding bits and masks. | 
 |  288 enum { | 
 |  289   // Instruction encoding bit | 
 |  290   B1  = 1 << 1, | 
 |  291   B4  = 1 << 4, | 
 |  292   B5  = 1 << 5, | 
 |  293   B7  = 1 << 7, | 
 |  294   B8  = 1 << 8, | 
 |  295   B9  = 1 << 9, | 
 |  296   B12 = 1 << 12, | 
 |  297   B18 = 1 << 18, | 
 |  298   B19 = 1 << 19, | 
 |  299   B20 = 1 << 20, | 
 |  300   B22 = 1 << 22, | 
 |  301   B23 = 1 << 23, | 
 |  302   B24 = 1 << 24, | 
 |  303   B25 = 1 << 25, | 
 |  304   B26 = 1 << 26, | 
 |  305   B27 = 1 << 27, | 
 |  306   B28 = 1 << 28, | 
 |  307  | 
 |  308   B6  = 1 << 6, | 
 |  309   B10 = 1 << 10, | 
 |  310   B11 = 1 << 11, | 
 |  311   B16 = 1 << 16, | 
 |  312   B17 = 1 << 17, | 
 |  313   B21 = 1 << 21, | 
 |  314  | 
 |  315   // Instruction bit masks | 
 |  316   kCondMask   = 0x1F << 21, | 
 |  317   kOff12Mask  = (1 << 12) - 1, | 
 |  318   kImm24Mask  = (1 << 24) - 1, | 
 |  319   kOff16Mask  = (1 << 16) - 1, | 
 |  320   kImm16Mask  = (1 << 16) - 1, | 
 |  321   kImm26Mask  = (1 << 26) - 1, | 
 |  322   kBOfieldMask = 0x1f << 21, | 
 |  323   kOpcodeMask = 0x3f << 26, | 
 |  324   kExt1OpcodeMask = 0x3ff << 1, | 
 |  325   kExt2OpcodeMask = 0x1f << 1, | 
 |  326   kExt5OpcodeMask = 0x3 << 2, | 
 |  327   kBOMask = 0x1f << 21, | 
 |  328   kBIMask = 0x1F << 16, | 
 |  329   kBDMask = 0x14 << 2, | 
 |  330   kAAMask = 0x01 << 1, | 
 |  331   kLKMask = 0x01, | 
 |  332   kRCMask = 0x01, | 
 |  333   kTOMask = 0x1f << 21 | 
 |  334 }; | 
 |  335  | 
 |  336 // the following is to differentiate different faked opcodes for | 
 |  337 // the BOGUS PPC instruction we invented (when bit 25 is 0) or to mark | 
 |  338 // different stub code (when bit 25 is 1) | 
 |  339 //   - use primary opcode 1 for undefined instruction | 
 |  340 //   - use bit 25 to indicate whether the opcode is for fake-arm | 
 |  341 //     instr or stub-marker | 
 |  342 //   - use the least significant 6-bit to indicate FAKE_OPCODE_T or | 
 |  343 //     MARKER_T | 
 |  344 #define FAKE_OPCODE 1 << 26 | 
 |  345 #define MARKER_SUBOPCODE_BIT 25 | 
 |  346 #define MARKER_SUBOPCODE 1 << MARKER_SUBOPCODE_BIT | 
 |  347 #define FAKER_SUBOPCODE 0 << MARKER_SUBOPCODE_BIT | 
 |  348  | 
 |  349 enum FAKE_OPCODE_T { | 
 |  350   fBKPT = 14, | 
 |  351  | 
 |  352   fLastFaker  // can't be more than 128 (2^^7) | 
 |  353 }; | 
 |  354 #define FAKE_OPCODE_HIGH_BIT 7  // fake opcode has to fall into bit 0~7 | 
 |  355 #define F_NEXT_AVAILABLE_STUB_MARKER 369  // must be less than 2^^9 (512) | 
 |  356 #define STUB_MARKER_HIGH_BIT 9  // stub marker has to fall into bit 0~9 | 
 |  357 // ----------------------------------------------------------------------------- | 
 |  358 // Addressing modes and instruction variants. | 
 |  359  | 
 |  360 // Overflow Exception | 
 |  361 enum OEBit { | 
 |  362   SetOE   = 1 << 10,  // Set overflow exception | 
 |  363   LeaveOE = 0 << 10   // No overflow exception | 
 |  364 }; | 
 |  365  | 
 |  366 // Record bit | 
 |  367 enum RCBit {  // Bit 0 | 
 |  368   SetRC   = 1,  // LT,GT,EQ,SO | 
 |  369   LeaveRC = 0   // None | 
 |  370 }; | 
 |  371  | 
 |  372 // Link bit | 
 |  373 enum LKBit {  // Bit 0 | 
 |  374   SetLK   = 1,  // Load effective address of next instruction | 
 |  375   LeaveLK = 0   // No action | 
 |  376 }; | 
 |  377  | 
 |  378 enum BOfield {  // Bits 25-21 | 
 |  379   DCBNZF =  0 << 21,  // Decrement CTR; branch if CTR != 0 and condition false | 
 |  380   DCBEZF =  2 << 21,  // Decrement CTR; branch if CTR == 0 and condition false | 
 |  381   BF     =  4 << 21,  // Branch if condition false | 
 |  382   DCBNZT =  8 << 21,  // Decrement CTR; branch if CTR != 0 and condition true | 
 |  383   DCBEZT = 10 << 21,  // Decrement CTR; branch if CTR == 0 and condition true | 
 |  384   BT     = 12 << 21,  // Branch if condition true | 
 |  385   DCBNZ  = 16 << 21,  // Decrement CTR; branch if CTR != 0 | 
 |  386   DCBEZ  = 18 << 21,  // Decrement CTR; branch if CTR == 0 | 
 |  387   BA     = 20 << 21   // Branch always | 
 |  388 }; | 
 |  389  | 
 |  390 #if V8_OS_AIX | 
 |  391 #undef CR_LT | 
 |  392 #undef CR_GT | 
 |  393 #undef CR_EQ | 
 |  394 #undef CR_SO | 
 |  395 #endif | 
 |  396  | 
 |  397 enum CRBit { | 
 |  398   CR_LT = 0, | 
 |  399   CR_GT = 1, | 
 |  400   CR_EQ = 2, | 
 |  401   CR_SO = 3, | 
 |  402   CR_FU = 3 | 
 |  403 }; | 
 |  404  | 
 |  405 #define CRWIDTH 4 | 
 |  406  | 
 |  407 // ----------------------------------------------------------------------------- | 
 |  408 // Supervisor Call (svc) specific support. | 
 |  409  | 
 |  410 // Special Software Interrupt codes when used in the presence of the PPC | 
 |  411 // simulator. | 
 |  412 // svc (formerly swi) provides a 24bit immediate value. Use bits 22:0 for | 
 |  413 // standard SoftwareInterrupCode. Bit 23 is reserved for the stop feature. | 
 |  414 enum SoftwareInterruptCodes { | 
 |  415   // transition to C code | 
 |  416   kCallRtRedirected= 0x10, | 
 |  417   // break point | 
 |  418   kBreakpoint= 0x821008,  // bits23-0 of 0x7d821008 = twge r2, r2 | 
 |  419   // stop | 
 |  420   kStopCode = 1 << 23, | 
 |  421   // info | 
 |  422   kInfo     = 0x9ff808    // bits23-0 of 0x7d9ff808 = twge r31, r31 | 
 |  423 }; | 
 |  424 const uint32_t kStopCodeMask = kStopCode - 1; | 
 |  425 const uint32_t kMaxStopCode = kStopCode - 1; | 
 |  426 const int32_t  kDefaultStopCode = -1; | 
 |  427  | 
 |  428 // FP rounding modes. | 
 |  429 enum FPRoundingMode { | 
 |  430   RN = 0,   // Round to Nearest. | 
 |  431   RZ = 1,   // Round towards zero. | 
 |  432   RP = 2,   // Round towards Plus Infinity. | 
 |  433   RM = 3,   // Round towards Minus Infinity. | 
 |  434  | 
 |  435   // Aliases. | 
 |  436   kRoundToNearest = RN, | 
 |  437   kRoundToZero = RZ, | 
 |  438   kRoundToPlusInf = RP, | 
 |  439   kRoundToMinusInf = RM | 
 |  440 }; | 
 |  441  | 
 |  442 const uint32_t kFPRoundingModeMask = 3; | 
 |  443  | 
 |  444 enum CheckForInexactConversion { | 
 |  445   kCheckForInexactConversion, | 
 |  446   kDontCheckForInexactConversion | 
 |  447 }; | 
 |  448  | 
 |  449 // ----------------------------------------------------------------------------- | 
 |  450 // Specific instructions, constants, and masks. | 
 |  451 // These constants are declared in assembler-arm.cc, as they use named registers | 
 |  452 // and other constants. | 
 |  453  | 
 |  454  | 
 |  455 // add(sp, sp, 4) instruction (aka Pop()) | 
 |  456 extern const Instr kPopInstruction; | 
 |  457  | 
 |  458 // str(r, MemOperand(sp, 4, NegPreIndex), al) instruction (aka push(r)) | 
 |  459 // register r is not encoded. | 
 |  460 extern const Instr kPushRegPattern; | 
 |  461  | 
 |  462 // ldr(r, MemOperand(sp, 4, PostIndex), al) instruction (aka pop(r)) | 
 |  463 // register r is not encoded. | 
 |  464 extern const Instr kPopRegPattern; | 
 |  465  | 
 |  466 // use TWI to indicate redirection call for simulation mode | 
 |  467 const Instr rtCallRedirInstr = TWI; | 
 |  468  | 
 |  469 // ----------------------------------------------------------------------------- | 
 |  470 // Instruction abstraction. | 
 |  471  | 
 |  472 // The class Instruction enables access to individual fields defined in the PPC | 
 |  473 // architecture instruction set encoding. | 
 |  474 // Note that the Assembler uses typedef int32_t Instr. | 
 |  475 // | 
 |  476 // Example: Test whether the instruction at ptr does set the condition code | 
 |  477 // bits. | 
 |  478 // | 
 |  479 // bool InstructionSetsConditionCodes(byte* ptr) { | 
 |  480 //   Instruction* instr = Instruction::At(ptr); | 
 |  481 //   int type = instr->TypeValue(); | 
 |  482 //   return ((type == 0) || (type == 1)) && instr->HasS(); | 
 |  483 // } | 
 |  484 // | 
 |  485 class Instruction { | 
 |  486  public: | 
 |  487   enum { | 
 |  488     kInstrSize = 4, | 
 |  489     kInstrSizeLog2 = 2, | 
 |  490     kPCReadOffset = 8 | 
 |  491   }; | 
 |  492  | 
 |  493   // Helper macro to define static accessors. | 
 |  494   // We use the cast to char* trick to bypass the strict anti-aliasing rules. | 
 |  495   #define DECLARE_STATIC_TYPED_ACCESSOR(return_type, Name)                     \ | 
 |  496     static inline return_type Name(Instr instr) {                              \ | 
 |  497       char* temp = reinterpret_cast<char*>(&instr);                            \ | 
 |  498       return reinterpret_cast<Instruction*>(temp)->Name();                     \ | 
 |  499     } | 
 |  500  | 
 |  501   #define DECLARE_STATIC_ACCESSOR(Name) DECLARE_STATIC_TYPED_ACCESSOR(int, Name) | 
 |  502  | 
 |  503   // Get the raw instruction bits. | 
 |  504   inline Instr InstructionBits() const { | 
 |  505     return *reinterpret_cast<const Instr*>(this); | 
 |  506   } | 
 |  507  | 
 |  508   // Set the raw instruction bits to value. | 
 |  509   inline void SetInstructionBits(Instr value) { | 
 |  510     *reinterpret_cast<Instr*>(this) = value; | 
 |  511   } | 
 |  512  | 
 |  513   // Read one particular bit out of the instruction bits. | 
 |  514   inline int Bit(int nr) const { | 
 |  515     return (InstructionBits() >> nr) & 1; | 
 |  516   } | 
 |  517  | 
 |  518   // Read a bit field's value out of the instruction bits. | 
 |  519   inline int Bits(int hi, int lo) const { | 
 |  520     return (InstructionBits() >> lo) & ((2 << (hi - lo)) - 1); | 
 |  521   } | 
 |  522  | 
 |  523   // Read a bit field out of the instruction bits. | 
 |  524   inline int BitField(int hi, int lo) const { | 
 |  525     return InstructionBits() & (((2 << (hi - lo)) - 1) << lo); | 
 |  526   } | 
 |  527  | 
 |  528   // Static support. | 
 |  529  | 
 |  530   // Read one particular bit out of the instruction bits. | 
 |  531   static inline int Bit(Instr instr, int nr) { | 
 |  532     return (instr >> nr) & 1; | 
 |  533   } | 
 |  534  | 
 |  535   // Read the value of a bit field out of the instruction bits. | 
 |  536   static inline int Bits(Instr instr, int hi, int lo) { | 
 |  537     return (instr >> lo) & ((2 << (hi - lo)) - 1); | 
 |  538   } | 
 |  539  | 
 |  540  | 
 |  541   // Read a bit field out of the instruction bits. | 
 |  542   static inline int BitField(Instr instr, int hi, int lo) { | 
 |  543     return instr & (((2 << (hi - lo)) - 1) << lo); | 
 |  544   } | 
 |  545  | 
 |  546   inline int RSValue() const { return Bits(25, 21); } | 
 |  547   inline int RTValue() const { return Bits(25, 21); } | 
 |  548   inline int RAValue() const { return Bits(20, 16); } | 
 |  549   DECLARE_STATIC_ACCESSOR(RAValue); | 
 |  550   inline int RBValue() const { return Bits(15, 11); } | 
 |  551   DECLARE_STATIC_ACCESSOR(RBValue); | 
 |  552   inline int RCValue() const { return Bits(10, 6); } | 
 |  553   DECLARE_STATIC_ACCESSOR(RCValue); | 
 |  554  | 
 |  555   inline int OpcodeValue() const { | 
 |  556     return static_cast<Opcode>(Bits(31, 26)); | 
 |  557   } | 
 |  558   inline Opcode OpcodeField() const { | 
 |  559     return static_cast<Opcode>(BitField(24, 21)); | 
 |  560   } | 
 |  561  | 
 |  562   // Fields used in Software interrupt instructions | 
 |  563   inline SoftwareInterruptCodes SvcValue() const { | 
 |  564     return static_cast<SoftwareInterruptCodes>(Bits(23, 0)); | 
 |  565   } | 
 |  566  | 
 |  567   // Instructions are read of out a code stream. The only way to get a | 
 |  568   // reference to an instruction is to convert a pointer. There is no way | 
 |  569   // to allocate or create instances of class Instruction. | 
 |  570   // Use the At(pc) function to create references to Instruction. | 
 |  571   static Instruction* At(byte* pc) { | 
 |  572     return reinterpret_cast<Instruction*>(pc); | 
 |  573   } | 
 |  574  | 
 |  575  | 
 |  576  private: | 
 |  577   // We need to prevent the creation of instances of class Instruction. | 
 |  578   DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction); | 
 |  579 }; | 
 |  580  | 
 |  581  | 
 |  582 // Helper functions for converting between register numbers and names. | 
 |  583 class Registers { | 
 |  584  public: | 
 |  585   // Return the name of the register. | 
 |  586   static const char* Name(int reg); | 
 |  587  | 
 |  588   // Lookup the register number for the name provided. | 
 |  589   static int Number(const char* name); | 
 |  590  | 
 |  591   struct RegisterAlias { | 
 |  592     int reg; | 
 |  593     const char* name; | 
 |  594   }; | 
 |  595  | 
 |  596  private: | 
 |  597   static const char* names_[kNumRegisters]; | 
 |  598   static const RegisterAlias aliases_[]; | 
 |  599 }; | 
 |  600  | 
 |  601 // Helper functions for converting between FP register numbers and names. | 
 |  602 class FPRegisters { | 
 |  603  public: | 
 |  604   // Return the name of the register. | 
 |  605   static const char* Name(int reg); | 
 |  606  | 
 |  607   // Lookup the register number for the name provided. | 
 |  608   static int Number(const char* name); | 
 |  609  | 
 |  610  private: | 
 |  611   static const char* names_[kNumFPRegisters]; | 
 |  612 }; | 
 |  613  | 
 |  614 } }  // namespace v8::internal | 
 |  615  | 
 |  616 #endif  // V8_PPC_CONSTANTS_PPC_H_ | 
| OLD | NEW |