Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Side by Side Diff: src/trusted/validator_ragel/unreviewed/gen-dfa.cc

Issue 10392066: validator_ragel: Use different actions for different types of commands (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <getopt.h> 8 #include <getopt.h>
9 #include <libgen.h> 9 #include <libgen.h>
10 #include <stdio.h> 10 #include <stdio.h>
(...skipping 1673 matching lines...) Expand 10 before | Expand all | Expand 10 after
1684 print_legacy_prefixes(); 1684 print_legacy_prefixes();
1685 print_rex_prefix(); 1685 print_rex_prefix();
1686 print_opcode_nomodrm(); 1686 print_opcode_nomodrm();
1687 if (opcode_in_imm) { 1687 if (opcode_in_imm) {
1688 print_immediate_opcode(); 1688 print_immediate_opcode();
1689 print_opcode_recognition(false); 1689 print_opcode_recognition(false);
1690 } else { 1690 } else {
1691 print_opcode_recognition(false); 1691 print_opcode_recognition(false);
1692 print_immediate_arguments(); 1692 print_immediate_arguments();
1693 } 1693 }
1694 print_inst_end_actions(false);
1694 } 1695 }
1695 1696
1696 void print_one_size_definition_modrm_register(void) { 1697 void print_one_size_definition_modrm_register(void) {
1697 print_operator_delimiter(); 1698 print_operator_delimiter();
1698 if (mod_reg_is_used()) { 1699 if (mod_reg_is_used()) {
1699 rex.r = true; 1700 rex.r = true;
1700 } 1701 }
1701 if (mod_rm_is_used()) { 1702 if (mod_rm_is_used()) {
1702 rex.b = true; 1703 rex.b = true;
1703 } 1704 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 } 1743 }
1743 if (opcode_in_modrm) { 1744 if (opcode_in_modrm) {
1744 fprintf(out_file, ")"); 1745 fprintf(out_file, ")");
1745 } 1746 }
1746 if (opcode_in_imm) { 1747 if (opcode_in_imm) {
1747 print_immediate_opcode(); 1748 print_immediate_opcode();
1748 print_opcode_recognition(false); 1749 print_opcode_recognition(false);
1749 } else { 1750 } else {
1750 print_immediate_arguments(); 1751 print_immediate_arguments();
1751 } 1752 }
1753 print_inst_end_actions(false);
1752 } 1754 }
1753 1755
1754 void print_one_size_definition_modrm_memory(void) { 1756 void print_one_size_definition_modrm_memory(void) {
1755 typedef std::tuple<const char *, bool, bool> T; 1757 typedef std::tuple<const char *, bool, bool> T;
1756 static const T modes[] = { 1758 static const T modes[] = {
1757 T { " operand_disp", false, true }, 1759 T { " operand_disp", false, true },
1758 T { " operand_rip", false, false }, 1760 T { " operand_rip", false, false },
1759 T { " single_register_memory", false, true }, 1761 T { " single_register_memory", false, true },
1760 T { " operand_sib_pure_index", true, false }, 1762 T { " operand_sib_pure_index", true, false },
1761 T { " operand_sib_base_index", true, true } 1763 T { " operand_sib_base_index", true, true }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1818 if (enabled(Actions::kCheckAccess) && !has_flag("no_memory_access")) { 1820 if (enabled(Actions::kCheckAccess) && !has_flag("no_memory_access")) {
1819 fprintf(out_file, " @check_access"); 1821 fprintf(out_file, " @check_access");
1820 } 1822 }
1821 fprintf(out_file, ")"); 1823 fprintf(out_file, ")");
1822 if (opcode_in_imm) { 1824 if (opcode_in_imm) {
1823 print_immediate_opcode(); 1825 print_immediate_opcode();
1824 print_opcode_recognition(true); 1826 print_opcode_recognition(true);
1825 } else { 1827 } else {
1826 print_immediate_arguments(); 1828 print_immediate_arguments();
1827 } 1829 }
1830 print_inst_end_actions(true);
1828 } 1831 }
1829 } 1832 }
1830 1833
1831 static bool first_delimiter; 1834 static bool first_delimiter;
1832 void print_operator_delimiter(void) { 1835 void print_operator_delimiter(void) {
1833 if (first_delimiter) { 1836 if (first_delimiter) {
1834 fprintf(out_file, "\n ("); 1837 fprintf(out_file, "\n (");
1835 } else { 1838 } else {
1836 fprintf(out_file, ") |\n ("); 1839 fprintf(out_file, ") |\n (");
1837 } 1840 }
1838 first_delimiter = false; 1841 first_delimiter = false;
1839 } 1842 }
1840 1843
1844 void print_inst_end_actions(bool memory_access) {
1845 if (enabled(Actions::kParseOperands)) {
1846 if (!enabled(Actions::kParseOperandPositions)) {
1847 int operands_count = 0;
1848 for (auto operand_it = operands.begin();
1849 operand_it != operands.end(); ++operand_it) {
1850 auto &operand = *operand_it;
1851 if (operand.enabled) {
1852 ++operands_count;
1853 if (memory_access) {
1854 static const char cc[] = { 'E', 'M', 'N', 'Q', 'R', 'U', 'W' };
1855 for (size_t c_it = 0; c_it < arraysize(cc); ++c_it) {
1856 auto c = cc[c_it];
1857 if (operand.source == c) {
1858 --operands_count;
pasko-google - do not use 2012/05/12 15:16:06 /* Memory operand is processed with action @check_
khim 2012/05/12 15:19:53 Done.
1859 break;
1860 }
1861 }
1862 }
1863
1864 }
1865 }
1866 fprintf(out_file, " @process_%d_operands", operands_count);
1867 }
1868 }
1869 }
1870
1841 bool mod_reg_is_used() { 1871 bool mod_reg_is_used() {
1842 for (auto operand_it = operands.begin(); 1872 for (auto operand_it = operands.begin();
1843 operand_it != operands.end(); ++operand_it) { 1873 operand_it != operands.end(); ++operand_it) {
1844 auto &operand = *operand_it; 1874 auto &operand = *operand_it;
1845 if (operand.source == 'C' && 1875 if (operand.source == 'C' &&
1846 required_prefixes.find("0xf0") == required_prefixes.end()) { 1876 required_prefixes.find("0xf0") == required_prefixes.end()) {
1847 return true; 1877 return true;
1848 } 1878 }
1849 static const char cc[] = { 'G', 'P', 'V' }; 1879 static const char cc[] = { 'G', 'P', 'V' };
1850 for (size_t c_it = 0; c_it < arraysize(cc); ++c_it) { 1880 for (size_t c_it = 0; c_it < arraysize(cc); ++c_it) {
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
2660 2690
2661 fprintf(out_file, "\n one_instruction ="); 2691 fprintf(out_file, "\n one_instruction =");
2662 2692
2663 print_one_instruction_definition(); 2693 print_one_instruction_definition();
2664 2694
2665 fprintf(out_file, ");\n" 2695 fprintf(out_file, ");\n"
2666 "}%%%%\n" 2696 "}%%%%\n"
2667 ""); 2697 "");
2668 return 0; 2698 return 0;
2669 } 2699 }
OLDNEW
« no previous file with comments | « src/trusted/validator_ragel/gen/validator-x86_64_table.c ('k') | src/trusted/validator_ragel/unreviewed/validator-x86_64.rl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698