| OLD | NEW |
| 1 # ARMv7 Instruction Encodings | 1 # ARMv7 Instruction Encodings |
| 2 # | 2 # |
| 3 # This table is derived from the "ARM Architecture Reference Manual, ARMv7-A | 3 # This table is derived from the "ARM Architecture Reference Manual, ARMv7-A |
| 4 # and ARMv7-R edition" and is used here with the permission of ARM Limited. | 4 # and ARMv7-R edition" and is used here with the permission of ARM Limited. |
| 5 # Reproduction for purposes other than the development and distribution of | 5 # Reproduction for purposes other than the development and distribution of |
| 6 # Native Client may require the explicit permission of ARM Limited. | 6 # Native Client may require the explicit permission of ARM Limited. |
| 7 | 7 |
| 8 # This file defines the Native Client "instruction classes" assigned to every | 8 # This file defines the Native Client "instruction classes" assigned to every |
| 9 # possible ARMv7 instruction encoding. It is organized into a series of tables, | 9 # possible ARMv7 instruction encoding. It is organized into a series of tables, |
| 10 # and directly parallels the ARM Architecture Reference Manual cited above. | 10 # and directly parallels the ARM Architecture Reference Manual cited above. |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 # are not Pc (R15). | 98 # are not Pc (R15). |
| 99 # NotRnIsPcAndRegsNotPc - Parse precondition Rn!=pc and safety | 99 # NotRnIsPcAndRegsNotPc - Parse precondition Rn!=pc and safety |
| 100 # constraint that all registers defined by the instruction | 100 # constraint that all registers defined by the instruction |
| 101 # are not Pc (R15). | 101 # are not Pc (R15). |
| 102 | 102 |
| 103 ############################################################## | 103 ############################################################## |
| 104 # The following define common entries for each (action) row. | 104 # The following define common entries for each (action) row. |
| 105 # | 105 # |
| 106 # base: The register used as the base for the effective address | 106 # base: The register used as the base for the effective address |
| 107 # for reads and writes. | 107 # for reads and writes. |
| 108 # target: The register use to compute an indirect branch, | 108 # clear_bits: True implies that the masked bits are cleared. |
| 109 # if defined (defaults to None). | 109 # (defaults to false). Corresponds to virtual clear_bits. |
| 110 # defs: The set of registers defined. (missing implies {}). | 110 # defs: The set of registers defined. (missing implies {}). |
| 111 # imm_defs: The set of registers that are set through | 111 # imm_defs: The set of registers that are set through |
| 112 # immediate indexed addressing writeback, where the | 112 # immediate indexed addressing writeback, where the |
| 113 # immediate value is "small". (missing implies {}). | 113 # immediate value is "small". (missing implies {}). |
| 114 # immediate: True if the instruction does a read/write | 114 # immediate: True if the instruction does a read/write |
| 115 # as "base + immediate". (missing implies false). | 115 # as "base + immediate". (missing implies false). |
| 116 # pool_head: Defines instruction to start a literal pool. | 116 # pool_head: Defines instruction to start a literal pool. |
| 117 # (missing implies false). | 117 # (missing implies false). |
| 118 # relative: Defines if the instruction is a direct relative | 118 # relative: Defines if the instruction is a direct relative |
| 119 # branch (R15 + constant offset). (missing implies false.) | 119 # branch (R15 + constant offset). (missing implies false.) |
| 120 # relative_offset: Defines the constant offset used in a direct | 120 # relative_offset: Defines the constant offset used in a direct |
| 121 # relative branch. | 121 # relative branch. |
| 122 # safety: How safety is defined for the class (missing implies true). | 122 # safety: How safety is defined for the class (missing implies true). |
| 123 # sets_Z_if_clear_bits: True implies that it sets the Z (condition) |
| 124 # bit if mask bits are cleared. (defaults to false). |
| 125 # Corresponds to defining virtual sets_Z_if_clear_bits. |
| 126 # target: The register use to compute an indirect branch, |
| 127 # if defined (defaults to None). |
| 123 # uses: The set of registers used. (missing imlies {}) | 128 # uses: The set of registers used. (missing imlies {}) |
| 124 # | |
| 125 # TODO(karl): How do we model class decoder virtuals clear_bits | |
| 126 # and sets_Z_if_bits_clear. | |
| 127 ############################################################## | 129 ############################################################## |
| 128 | 130 |
| 129 ############################################################## | 131 ############################################################## |
| 130 # It should be noted that one can define a local dictionary at | 132 # It should be noted that one can define a local dictionary at |
| 131 # the top of each table. The dictionary enties are prefixed by | 133 # the top of each table. The dictionary enties are prefixed by |
| 132 # "*n" which defines entry n. Each entry can be an action template. | 134 # "*n" which defines entry n. Each entry can be an action template. |
| 133 # These templates can then be referred to in actual rows by using | 135 # These templates can then be referred to in actual rows by using |
| 134 # a "*n" in place of the action. When this is done, the action | 136 # a "*n" in place of the action. When this is done, the action |
| 135 # inherits the corresponding action from the table's local dictionary. | 137 # inherits the corresponding action from the table's local dictionary. |
| 136 # Following the "*n" in the row, you can define additional fields. | 138 # Following the "*n" in the row, you can define additional fields. |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 rule := BIC_register_shifted_register_A1; | 384 rule := BIC_register_shifted_register_A1; |
| 383 | 1111x - = *4 pattern := cccc0001111s0000ddddssss0tt1mmmm; | 385 | 1111x - = *4 pattern := cccc0001111s0000ddddssss0tt1mmmm; |
| 384 rule := MVN_register_shifted_register_A1; | 386 rule := MVN_register_shifted_register_A1; |
| 385 +-- | 387 +-- |
| 386 | 388 |
| 387 +-- data_processing_immediate (See Section A5.2.3) | 389 +-- data_processing_immediate (See Section A5.2.3) |
| 388 # Note: The two interesting instructions in this set are | 390 # Note: The two interesting instructions in this set are |
| 389 # TestIfAddressMasked and MaskAddress. These two instructions are the | 391 # TestIfAddressMasked and MaskAddress. These two instructions are the |
| 390 # ones that we allow testing/setting of bits to mask data addresses | 392 # ones that we allow testing/setting of bits to mask data addresses |
| 391 # appropriately. | 393 # appropriately. |
| 394 *B2R Binary2RegisterImmediateOp => Defs12To15 |
| 395 { cond(31:28), S(20), Rn(19:16), Rd(15:12), imm12(11:0) } |
| 396 setflags := S=1; imm32 := ARMExpandImm_C(imm12); |
| 397 defs := {Rd, NZCV if setflags else None}; |
| 398 safety := (Rd=1111 & S=1) => DECODER_ERROR & # ARM |
| 399 Rd=1111 => FORBIDDEN_OPERANDS; # NaCl |
| 400 uses := {Rn}; |
| 401 *B2R_MASK MaskedBinary2RegisterImmediateOp => MaskAddress |
| 402 # Note: This instruction is used to mask memory addresses. Otherwise, |
| 403 # it would be the same as *B2R. |
| 404 { cond(31:28), S(20), Rn(19:16), Rd(15:12), imm12(11:0) } |
| 405 setflags := S=1; imm32 := ARMExpandImm_C(imm12); |
| 406 defs := {Rd, NZCV if setflags else None}; |
| 407 safety := (Rd=1111 & S=1) => DECODER_ERROR & # ARM |
| 408 Rd=1111 => FORBIDDEN_OPERANDS; # NaCl |
| 409 uses := {Rn}; |
| 410 clears_bits := true; |
| 411 *B2R_ADDSUB Binary2RegisterImmediateOp => Defs12To15 |
| 412 # Note: This is a variant of *B2R instructions, that is used |
| 413 # to define add and subtract, and have additional decoding error |
| 414 # safety checks. |
| 415 { cond(31:28), S(20), Rn(19:16), Rd(15:12), imm12(11:0) } |
| 416 setflags := S=1; imm32 := ARMExpandImm_C(imm12); |
| 417 defs := {Rd, NZCV if setflags else None}; |
| 418 safety := (Rd=1111 & S=1) => DECODER_ERROR & # ARM |
| 419 (Rn=1111 & S=0) => DECODER_ERROR & |
| 420 Rd=1111 => FORBIDDEN_OPERANDS; # NaCl |
| 421 uses := {Rn}; |
| 422 *TEST BinaryRegisterImmediateTest => DontCareInst |
| 423 { cond(31:28), Rn(19:16), imm12(11:0) } |
| 424 imm32 := AMRExpandImm_C(imm12); |
| 425 defs := {NZCV}; |
| 426 uses := {Rn}; |
| 427 *TEST_MASK MaskedBinaryRegisterImmediateTest => TestIfAddressMasked |
| 428 # Note: This instruction is used to test if the immediate value |
| 429 # appropriately (data address) masks the value in Rn. Otherwise, |
| 430 # it would be the same as *TEST above. |
| 431 { cond(31:28), Rn(19:16), imm12(11:0) } |
| 432 imm32 := AMRExpandImm_C(imm12); |
| 433 defs := {NZCV}; |
| 434 uses := {Rn}; |
| 435 sets_Z_if_bits_clear := true; |
| 436 *U1R_U Unary1RegisterImmediateOp => Defs12To15 |
| 437 { cond(31:28), U(23), Rd(15:12), imm12(11:0) } |
| 438 # Note: Bit U isn't defined in ARM manual, but adding for simplicity. |
| 439 imm32 := ARMExpandImm(imm12); add := U=1; |
| 440 defs := {Rd}; |
| 441 safety := Rd=1111 => FORBIDDEN_OPERANDS; # NaCl |
| 442 uses := {Pc}; |
| 443 *U1R_S Unary1RegisterImmediateOp => Defs12To15 |
| 444 { cond(31:28), S(20), Rd(15:12), imm12(11:0) } |
| 445 setflags := S=1; imm32 := ARMExpandImm(imm12); |
| 446 defs := {Rd, NZCV if setflags else None}; |
| 447 safety := (Rd=1111 & S=1) => DECODER_ERROR & # ARM |
| 448 Rd=1111 => FORBIDDEN_OPERANDS; # NaCl |
| 449 +-- |
| 392 | op(24:20) Rn(19:16) | 450 | op(24:20) Rn(19:16) |
| 393 | 0000x - = Binary2RegisterImmediateOp | 451 | 0000x - = *B2R pattern := cccc0010000snnnnddddiiiiiiiiiiii; |
| 394 => Defs12To15 | 452 rule := AND_immediate_A1; |
| 395 And_Rule_11_A1_P34 | 453 | 0001x - = *B2R pattern := cccc0010001snnnnddddiiiiiiiiiiii; |
| 396 cccc0010000snnnnddddiiiiiiiiiiii NotRdIsPcAndS | 454 rule := EOR_immediate_A1; |
| 397 | 0001x - = Binary2RegisterImmediateOp | 455 | 0010x ~1111 = *B2R_ADDSUB pattern := cccc0010010snnnnddddiiiiiiiiiiii; |
| 398 => Defs12To15 | 456 rule := SUB_immediate_A1; |
| 399 Eor_Rule_44_A1_P94 | 457 | 0010x 1111 = *U1R_U pattern := cccc001001001111ddddiiiiiiiiiiii; |
| 400 cccc0010001snnnnddddiiiiiiiiiiii NotRdIsPcAndS | 458 rule := ADR_A2; |
| 401 | 0010x ~1111 = Binary2RegisterImmediateOp | 459 | 0011x - = *B2R pattern := cccc0010011snnnnddddiiiiiiiiiiii; |
| 402 => Defs12To15 | 460 rule := RSB_immediate_A1; |
| 403 Sub_Rule_212_A1_P420 | 461 | 0100x ~1111 = *B2R_ADDSUB pattern := cccc0010100snnnnddddiiiiiiiiiiii; |
| 404 cccc0010010snnnnddddiiiiiiiiiiii | 462 rule := ADD_immediate_A1; |
| 405 NeitherRdIsPcAndSNorRnIsPcAndNotS | 463 | 0100x 1111 = *U1R_U pattern := cccc001010001111ddddiiiiiiiiiiii; |
| 406 # Note: Table says that op=0010x for ADR, but | 464 rule := ADR_A1; |
| 407 # patterns for ADR do not match (page A8-32). | 465 | 0101x - = *B2R pattern := cccc0010101snnnnddddiiiiiiiiiiii; |
| 408 # Causes parsing conflicts with SUB (previous | 466 rule := ADC_immediate_A1; |
| 409 # row). Added restriction to ADR that bit 20 | 467 | 0110x - = *B2R pattern := cccc0010110snnnnddddiiiiiiiiiiii; |
| 410 # (updates flags register) must be 0 (rather than | 468 rule := SBC_immediate_A1; |
| 411 # x), to match what is on A8.6.10 (page A8-32). | 469 | 0111x - = *B2R pattern := cccc0010111snnnnddddiiiiiiiiiiii; |
| 412 # Note that this also matches restrictions of | 470 rule := RSC_immediate_A1; |
| 413 # A8.6.212 (page A8-420). | |
| 414 | 00100 1111 = Unary1RegisterImmediateOp | |
| 415 => Defs12To15 | |
| 416 Adr_Rule_10_A2_P32 | |
| 417 cccc001001001111ddddiiiiiiiiiiii | |
| 418 | 00101 1111 = ForbiddenCondDecoder => Forbidden | |
| 419 Subs_Pc_Lr_and_related_instructions_Rule_A1a | |
| 420 cccc00100101nnnn1111iiiiiiiiiiii | |
| 421 | 0011x - = Binary2RegisterImmediateOp | |
| 422 => Defs12To15 | |
| 423 Rsb_Rule_142_A1_P284 | |
| 424 cccc0010011snnnnddddiiiiiiiiiiii NotRdIsPcAndS | |
| 425 | 0100x ~1111 = Binary2RegisterImmediateOp | |
| 426 => Defs12To15 | |
| 427 Add_Rule_5_A1_P22 | |
| 428 cccc0010100snnnnddddiiiiiiiiiiii | |
| 429 NeitherRdIsPcAndSNorRnIsPcAndNotS | |
| 430 # Note: Table says that op=0100x for ADR, but | |
| 431 # patterns for ADR do not match (page A8-32). | |
| 432 # Causes parsing conflicts with ADD (previous | |
| 433 # row). Added restriction to ADR that bit 20 | |
| 434 # (updates flags register) must be 0 (rather than | |
| 435 # x), to match what is on A8.6.10 (page A8-32). | |
| 436 # Note that this also matches restrictions of | |
| 437 # A8.6.5 (page A8-22). | |
| 438 | 01000 1111 = Unary1RegisterImmediateOp | |
| 439 => Defs12To15 | |
| 440 Adr_Rule_10_A1_P32 | |
| 441 cccc001010001111ddddiiiiiiiiiiii | |
| 442 | 01001 1111 = ForbiddenCondDecoder => Forbidden | |
| 443 Subs_Pc_Lr_and_related_instructions_Rule_A1b | |
| 444 cccc00101001nnnn1111iiiiiiiiiiii | |
| 445 | 0101x - = Binary2RegisterImmediateOp | |
| 446 => Defs12To15 | |
| 447 Adc_Rule_6_A1_P14 | |
| 448 cccc0010101snnnnddddiiiiiiiiiiii NotRdIsPcAndS | |
| 449 | 0110x - = Binary2RegisterImmediateOp | |
| 450 => Defs12To15 | |
| 451 Sbc_Rule_151_A1_P302 | |
| 452 cccc0010110snnnnddddiiiiiiiiiiii NotRdIsPcAndS | |
| 453 | 0111x - = Binary2RegisterImmediateOp | |
| 454 => Defs12To15 | |
| 455 Rsc_Rule_145_A1_P290 | |
| 456 cccc0010111snnnnddddiiiiiiiiiiii NotRdIsPcAndS | |
| 457 # TODO(jfb) op==10xx0 should be unreachable from here: | 471 # TODO(jfb) op==10xx0 should be unreachable from here: |
| 458 # the previous table should handle it. | 472 # the previous table should handle it. |
| 459 # Note: Following instruction is used to test | 473 | 10001 - = *TEST_MASK pattern := cccc00110001nnnn0000iiiiiiiiiiii; |
| 460 # if the immediate value appropriately (data address) | 474 rule := TST_immediate_A1; |
| 461 # masks the value in Rn. | 475 | 10011 - = *TEST pattern := cccc00110011nnnn0000iiiiiiiiiiii; |
| 462 | 10001 - = MaskedBinaryRegisterImmediateTest | 476 rule := TEQ_immediate_A1; |
| 463 => TestIfAddressMasked | 477 | 10101 - = *TEST pattern := cccc00110101nnnn0000iiiiiiiiiiii; |
| 464 Tst_Rule_230_A1_P454 | 478 rule := CMP_immediate_A1; |
| 465 cccc00110001nnnn0000iiiiiiiiiiii | 479 | 10111 - = *TEST pattern := cccc00110111nnnn0000iiiiiiiiiiii; |
| 466 | 10011 - = BinaryRegisterImmediateTest | 480 rule := CMN_immediate_A1; |
| 467 => DontCareInst | 481 | 1100x - = *B2R pattern := cccc0011100snnnnddddiiiiiiiiiiii |
| 468 Teq_Rule_227_A1_P448 | 482 & not (Rd=1111 & S=1); |
| 469 cccc00110011nnnn0000iiiiiiiiiiii | 483 rule := ORR_immediate_A1; |
| 470 | 10101 - = BinaryRegisterImmediateTest | 484 | 1101x - = *U1R_S pattern := cccc0011101s0000ddddiiiiiiiiiiii; |
| 471 => DontCareInst | 485 rule := MOV_immediate_A1; |
| 472 Cmp_Rule_35_A1_P80 | 486 | 1110x - = *B2R_MASK pattern := cccc0011110snnnnddddiiiiiiiiiiii; |
| 473 cccc00110101nnnn0000iiiiiiiiiiii | 487 rule := BIC_immediate_A1; |
| 474 | 10111 - = BinaryRegisterImmediateTest | 488 | 1111x - = *U1R_S pattern := cccc0011111s0000ddddiiiiiiiiiiii; |
| 475 => DontCareInst | 489 rule := MVN_immediate_A1; |
| 476 Cmn_Rule_32_A1_P74 | |
| 477 cccc00110111nnnn0000iiiiiiiiiiii | |
| 478 | 1100x - = Binary2RegisterImmediateOp | |
| 479 => Defs12To15 | |
| 480 Orr_Rule_113_A1_P228 | |
| 481 cccc0011100snnnnddddiiiiiiiiiiii NotRdIsPcAndS | |
| 482 | 1101x - = Unary1RegisterImmediateOp | |
| 483 => Defs12To15 | |
| 484 Mov_Rule_96_A1_P194 | |
| 485 cccc0011101s0000ddddiiiiiiiiiiii NotRdIsPcAndS | |
| 486 # Note: The following instruction is used to mask | |
| 487 # memory addresses. | |
| 488 | 1110x - = MaskedBinary2RegisterImmediateOp | |
| 489 => MaskAddress | |
| 490 Bic_Rule_19_A1_P50 | |
| 491 cccc0011110snnnnddddiiiiiiiiiiii NotRdIsPcAndS | |
| 492 | 1111x - = Unary1RegisterImmediateOp | |
| 493 => Defs12To15 | |
| 494 Mvn_Rule_106_A1_P214 | |
| 495 cccc0011111s0000ddddiiiiiiiiiiii NotRdIsPcAndS | |
| 496 +-- | 490 +-- |
| 497 | 491 |
| 498 # Note: in all of these cases there's a currently unhandled restriction: | 492 # Note: in all of these cases there's a currently unhandled restriction: |
| 499 # if ArchVersion() < 6 && d == n then Unpredictable. | 493 # if ArchVersion() < 6 && d == n then Unpredictable. |
| 500 # And for long versions: | 494 # And for long versions: |
| 501 # if ArchVersion() < 6 && ((dhi == n) || (dlo == n)) then Unpredictable. | 495 # if ArchVersion() < 6 && ((dhi == n) || (dlo == n)) then Unpredictable. |
| 502 # Revisit if we want to support chips before v6. | 496 # Revisit if we want to support chips before v6. |
| 503 +-- multiply_and_multiply_accumulate (See Section A5.2.5) | 497 +-- multiply_and_multiply_accumulate (See Section A5.2.5) |
| 504 | op(23:20) | 498 | op(23:20) |
| 505 | 000x = Binary3RegisterOpAltA | 499 | 000x = Binary3RegisterOpAltA |
| (...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1932 | " 1001 " | 1926 | " 1001 " |
| 1933 | " 1101 =VectorLoad # VLD2(single, all lanes) | 1927 | " 1101 =VectorLoad # VLD2(single, all lanes) |
| 1934 | " 0x10 =VectorLoad # VLD3(single) | 1928 | " 0x10 =VectorLoad # VLD3(single) |
| 1935 | " 1010 " | 1929 | " 1010 " |
| 1936 | " 1110 =VectorLoad # VLD3(single, all lanes) | 1930 | " 1110 =VectorLoad # VLD3(single, all lanes) |
| 1937 | " 0x11 =VectorLoad # VLD4(single) | 1931 | " 0x11 =VectorLoad # VLD4(single) |
| 1938 | " 1011 " | 1932 | " 1011 " |
| 1939 | " 1111 =VectorLoad # VLD4(single, all lanes) | 1933 | " 1111 =VectorLoad # VLD4(single, all lanes) |
| 1940 | else: =Undefined # Note on page A7-27 | 1934 | else: =Undefined # Note on page A7-27 |
| 1941 +-- | 1935 +-- |
| OLD | NEW |