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

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

Issue 9968039: Add ragel machine generators to SCONS (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 8 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 /* Flags for enabling/disabling based on architecture and validity. */ 182 /* Flags for enabling/disabling based on architecture and validity. */
183 "ia32", 183 "ia32",
184 "amd64", 184 "amd64",
185 "nacl-ia32-forbidden", 185 "nacl-ia32-forbidden",
186 "nacl-amd64-forbidden", 186 "nacl-amd64-forbidden",
187 "nacl-forbidden" 187 "nacl-forbidden"
188 }; 188 };
189 189
190 class Instruction { 190 class Instruction {
191 public: 191 public:
192 static bool check_flag_valid(const std::string &flag) { 192 static void check_flag_valid(const std::string &flag) {
193 if (all_instruction_flags.find(flag) == all_instruction_flags.end()) { 193 if (all_instruction_flags.find(flag) == all_instruction_flags.end()) {
194 fprintf(stderr, "%s: unknown flag: '%s'\n", 194 fprintf(stderr, "%s: unknown flag: '%s'\n",
195 short_program_name, flag.c_str()); 195 short_program_name, flag.c_str());
196 exit(1); 196 exit(1);
197 } 197 }
198 } 198 }
199 199
200 void add_flag(const std::string &flag) { 200 void add_flag(const std::string &flag) {
201 check_flag_valid(flag); 201 check_flag_valid(flag);
202 flags.insert(flag); 202 flags.insert(flag);
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 c_identifier(pair.first).c_str(), pair.second); 1182 c_identifier(pair.first).c_str(), pair.second);
1183 } 1183 }
1184 } 1184 }
1185 1185
1186 class MarkedInstruction : Instruction { 1186 class MarkedInstruction : Instruction {
1187 public: 1187 public:
1188 /* Additional marks are created in the process of parsing. */ 1188 /* Additional marks are created in the process of parsing. */
1189 explicit MarkedInstruction(Instruction instruction_) : 1189 explicit MarkedInstruction(Instruction instruction_) :
1190 Instruction(instruction_), 1190 Instruction(instruction_),
1191 instruction_class(get_instruction_class(instruction_)), 1191 instruction_class(get_instruction_class(instruction_)),
1192 opcode_in_modrm(false), opcode_in_imm(false), rex { } { 1192 rex { }, opcode_in_modrm(false), opcode_in_imm(false) {
1193 if (has_flag("branch_hint")) { 1193 if (has_flag("branch_hint")) {
1194 optional_prefixes.insert("branch_hint"); 1194 optional_prefixes.insert("branch_hint");
1195 } 1195 }
1196 if (has_flag("condrep")) { 1196 if (has_flag("condrep")) {
1197 optional_prefixes.insert("condrep"); 1197 optional_prefixes.insert("condrep");
1198 } 1198 }
1199 if (has_flag("rep")) { 1199 if (has_flag("rep")) {
1200 optional_prefixes.insert("rep"); 1200 optional_prefixes.insert("rep");
1201 } 1201 }
1202 for (auto opcode_it = opcodes.begin(); 1202 for (auto opcode_it = opcodes.begin();
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 } 1541 }
1542 } 1542 }
1543 1543
1544 void print_one_size_definition(void) { 1544 void print_one_size_definition(void) {
1545 /* 64bit commands are not supported in ia32 mode. */ 1545 /* 64bit commands are not supported in ia32 mode. */
1546 if (ia32_mode && rex.w) { 1546 if (ia32_mode && rex.w) {
1547 return; 1547 return;
1548 } 1548 }
1549 bool modrm_memory = false; 1549 bool modrm_memory = false;
1550 bool modrm_register = false; 1550 bool modrm_register = false;
1551 char operand_source; 1551 char operand_source = ' ';
1552 for (auto operand_it = operands.begin(); 1552 for (auto operand_it = operands.begin();
1553 operand_it != operands.end(); ++operand_it) { 1553 operand_it != operands.end(); ++operand_it) {
1554 auto &operand = *operand_it; 1554 auto &operand = *operand_it;
1555 static std::map<char, std::pair<bool, bool> > operand_map { 1555 static std::map<char, std::pair<bool, bool> > operand_map {
1556 { 'E', std::make_pair(true, true) }, 1556 { 'E', std::make_pair(true, true) },
1557 { 'M', std::make_pair(true, false) }, 1557 { 'M', std::make_pair(true, false) },
1558 { 'N', std::make_pair(false, true) }, 1558 { 'N', std::make_pair(false, true) },
1559 { 'Q', std::make_pair(true, true) }, 1559 { 'Q', std::make_pair(true, true) },
1560 { 'R', std::make_pair(false, true) }, 1560 { 'R', std::make_pair(false, true) },
1561 { 'U', std::make_pair(false, true) }, 1561 { 'U', std::make_pair(false, true) },
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
2487 2487
2488 fprintf(out_file, "\n one_instruction ="); 2488 fprintf(out_file, "\n one_instruction =");
2489 2489
2490 print_one_instruction_definition(); 2490 print_one_instruction_definition();
2491 2491
2492 fprintf(out_file, ");\n" 2492 fprintf(out_file, ");\n"
2493 "}%%%%\n" 2493 "}%%%%\n"
2494 ""); 2494 "");
2495 return 0; 2495 return 0;
2496 } 2496 }
OLDNEW
« src/trusted/validator_ragel/build.scons ('K') | « src/trusted/validator_ragel/build.scons ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698