OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * Hand-written Ragel machines and actions used in validator and decoding. | 8 * Hand-written Ragel machines and actions used in validator and decoding. |
9 * | 9 * |
10 * Note: this file includes many different machines which are supposed to be | 10 * Note: this file includes many different machines which are supposed to be |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 701 |
702 action imm2_operand { | 702 action imm2_operand { |
703 SET_IMM_TYPE(IMM2); | 703 SET_IMM_TYPE(IMM2); |
704 SET_IMM_PTR(current_position); | 704 SET_IMM_PTR(current_position); |
705 } | 705 } |
706 action imm8_operand { | 706 action imm8_operand { |
707 SET_IMM_TYPE(IMM8); | 707 SET_IMM_TYPE(IMM8); |
708 SET_IMM_PTR(current_position); | 708 SET_IMM_PTR(current_position); |
709 } | 709 } |
710 action imm8_second_operand { | 710 action imm8_second_operand { |
711 SET_IMM2_TYPE(IMM8); | 711 SET_SECOND_IMM_TYPE(IMM8); |
712 SET_IMM2_PTR(current_position); | 712 SET_IMM2_PTR(current_position); |
713 } | 713 } |
714 action imm16_operand { | 714 action imm16_operand { |
715 SET_IMM_TYPE(IMM16); | 715 SET_IMM_TYPE(IMM16); |
716 SET_IMM_PTR(current_position - 1); | 716 SET_IMM_PTR(current_position - 1); |
717 } | 717 } |
718 action imm16_second_operand { | 718 action imm16_second_operand { |
719 SET_IMM2_TYPE(IMM16); | 719 SET_SECOND_IMM_TYPE(IMM16); |
720 SET_IMM2_PTR(current_position - 1); | 720 SET_IMM2_PTR(current_position - 1); |
721 } | 721 } |
722 action imm32_operand { | 722 action imm32_operand { |
723 SET_IMM_TYPE(IMM32); | 723 SET_IMM_TYPE(IMM32); |
724 SET_IMM_PTR(current_position - 3); | 724 SET_IMM_PTR(current_position - 3); |
725 } | 725 } |
726 action imm32_second_operand { | 726 action imm32_second_operand { |
727 SET_IMM2_TYPE(IMM32); | 727 SET_SECOND_IMM_TYPE(IMM32); |
728 SET_IMM2_PTR(current_position - 3); | 728 SET_IMM2_PTR(current_position - 3); |
729 } | 729 } |
730 action imm64_operand { | 730 action imm64_operand { |
731 SET_IMM_TYPE(IMM64); | 731 SET_IMM_TYPE(IMM64); |
732 SET_IMM_PTR(current_position - 7); | 732 SET_IMM_PTR(current_position - 7); |
733 } | 733 } |
734 action imm64_second_operand { | 734 action imm64_second_operand { |
735 SET_IMM2_TYPE(IMM64); | 735 SET_SECOND_IMM_TYPE(IMM64); |
736 SET_IMM2_PTR(current_position - 7); | 736 SET_IMM2_PTR(current_position - 7); |
737 } | 737 } |
738 }%% | 738 }%% |
739 | 739 |
740 %%{ | 740 %%{ |
741 machine immediate_fields_parsing_common; | 741 machine immediate_fields_parsing_common; |
742 | 742 |
743 imm8 = any @imm8_operand $any_byte; | 743 imm8 = any @imm8_operand $any_byte; |
744 imm16 = any{2} @imm16_operand $any_byte; | 744 imm16 = any{2} @imm16_operand $any_byte; |
745 imm32 = any{4} @imm32_operand $any_byte; | 745 imm32 = any{4} @imm32_operand $any_byte; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 # ragel machine. Ensure compilations error in case of accidental usage. | 803 # ragel machine. Ensure compilations error in case of accidental usage. |
804 action rel16_operand { | 804 action rel16_operand { |
805 #error rel16_operand should never be used in nacl | 805 #error rel16_operand should never be used in nacl |
806 } | 806 } |
807 | 807 |
808 # rel32 actions are used in relative calls and jumps with 32-bit offset. | 808 # rel32 actions are used in relative calls and jumps with 32-bit offset. |
809 action rel32_operand { | 809 action rel32_operand { |
810 Rel32Operand(current_position + 1, data, jump_dests, size, | 810 Rel32Operand(current_position + 1, data, jump_dests, size, |
811 &instruction_info_collected); | 811 &instruction_info_collected); |
812 } | 812 } |
| 813 |
| 814 # Action which marks last byte as not immediate. Most 3DNow! instructions, |
| 815 # some AVX and XOP instructions have this property. |
| 816 # |
| 817 # This action is referenced by decode_x86_32 ragel machine in [autogenerated] |
| 818 # "validator_x86_32_instruction.rl" file. |
| 819 action last_byte_is_not_immediate { |
| 820 instruction_info_collected |= LAST_BYTE_IS_NOT_IMMEDIATE; |
| 821 } |
813 }%% | 822 }%% |
814 | 823 |
815 %%{ | 824 %%{ |
816 machine relative_fields_parsing; | 825 machine relative_fields_parsing; |
817 | 826 |
818 rel8 = any @rel8_operand $any_byte; | 827 rel8 = any @rel8_operand $any_byte; |
819 rel16 = any{2} @rel16_operand $any_byte; | 828 rel16 = any{2} @rel16_operand $any_byte; |
820 rel32 = any{4} @rel32_operand $any_byte; | 829 rel32 = any{4} @rel32_operand $any_byte; |
821 }%% | 830 }%% |
822 | 831 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 | 897 |
889 %%{ | 898 %%{ |
890 machine decoder; | 899 machine decoder; |
891 | 900 |
892 action end_of_instruction_cleanup { | 901 action end_of_instruction_cleanup { |
893 process_instruction(instruction_begin, current_position + 1, &instruction, | 902 process_instruction(instruction_begin, current_position + 1, &instruction, |
894 userdata); | 903 userdata); |
895 instruction_begin = current_position + 1; | 904 instruction_begin = current_position + 1; |
896 SET_DISP_TYPE(DISPNONE); | 905 SET_DISP_TYPE(DISPNONE); |
897 SET_IMM_TYPE(IMMNONE); | 906 SET_IMM_TYPE(IMMNONE); |
898 SET_IMM2_TYPE(IMMNONE); | 907 SET_SECOND_IMM_TYPE(IMMNONE); |
899 SET_REX_PREFIX(FALSE); | 908 SET_REX_PREFIX(FALSE); |
900 SET_DATA16_PREFIX(FALSE); | 909 SET_DATA16_PREFIX(FALSE); |
901 SET_LOCK_PREFIX(FALSE); | 910 SET_LOCK_PREFIX(FALSE); |
902 SET_REPNZ_PREFIX(FALSE); | 911 SET_REPNZ_PREFIX(FALSE); |
903 SET_REPZ_PREFIX(FALSE); | 912 SET_REPZ_PREFIX(FALSE); |
904 SET_BRANCH_NOT_TAKEN(FALSE); | 913 SET_BRANCH_NOT_TAKEN(FALSE); |
905 SET_BRANCH_TAKEN(FALSE); | 914 SET_BRANCH_TAKEN(FALSE); |
906 /* Top three bis of VEX2 are inverted: see AMD/Intel manual. */ | 915 /* Top three bis of VEX2 are inverted: see AMD/Intel manual. */ |
907 SET_VEX_PREFIX2(VEX_R | VEX_X | VEX_B); | 916 SET_VEX_PREFIX2(VEX_R | VEX_X | VEX_B); |
908 SET_VEX_PREFIX3(0x00); | 917 SET_VEX_PREFIX3(0x00); |
909 SET_ATT_INSTRUCTION_SUFFIX(NULL); | 918 SET_ATT_INSTRUCTION_SUFFIX(NULL); |
910 CLEAR_SPURIOUS_REX_B(); | 919 CLEAR_SPURIOUS_REX_B(); |
911 CLEAR_SPURIOUS_REX_X(); | 920 CLEAR_SPURIOUS_REX_X(); |
912 CLEAR_SPURIOUS_REX_R(); | 921 CLEAR_SPURIOUS_REX_R(); |
913 CLEAR_SPURIOUS_REX_W(); | 922 CLEAR_SPURIOUS_REX_W(); |
914 } | 923 } |
915 | 924 |
916 action report_fatal_error { | 925 action report_fatal_error { |
917 process_error(current_position, userdata); | 926 process_error(current_position, userdata); |
918 result = FALSE; | 927 result = FALSE; |
919 goto error_detected; | 928 goto error_detected; |
920 } | 929 } |
921 | 930 |
922 decoder = (one_instruction @end_of_instruction_cleanup)* | 931 decoder = (one_instruction @end_of_instruction_cleanup)* |
923 $!report_fatal_error; | 932 $!report_fatal_error; |
924 }%% | 933 }%% |
OLD | NEW |