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 #include <assert.h> | 7 #include <assert.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <getopt.h> | 9 #include <getopt.h> |
10 #include <libgen.h> | 10 #include <libgen.h> |
(...skipping 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 prefix_it != required_prefixes.end(); ++prefix_it) { | 2233 prefix_it != required_prefixes.end(); ++prefix_it) { |
2234 auto &prefix = *prefix_it; | 2234 auto &prefix = *prefix_it; |
2235 if (prefix == "0xf3") { | 2235 if (prefix == "0xf3") { |
2236 fprintf(out_file, " @not_repz_prefix"); | 2236 fprintf(out_file, " @not_repz_prefix"); |
2237 break; | 2237 break; |
2238 } | 2238 } |
2239 } | 2239 } |
2240 if (enabled(Actions::kInstructionName)) { | 2240 if (enabled(Actions::kInstructionName)) { |
2241 fprintf(out_file, " @instruction_%s", c_identifier(name).c_str()); | 2241 fprintf(out_file, " @instruction_%s", c_identifier(name).c_str()); |
2242 } else if (opcode_in_imm) { | 2242 } else if (opcode_in_imm) { |
2243 fprintf(out_file, " @opcode_in_imm"); | 2243 fprintf(out_file, " @last_byte_is_not_immediate"); |
2244 } else if (has_flag("nacl-amd64-modifiable") && | 2244 } else if (has_flag("nacl-amd64-modifiable") && |
2245 enabled(Actions::kParseOperands) && | 2245 enabled(Actions::kParseOperands) && |
2246 !enabled(Actions::kParseOperandPositions)) { | 2246 !enabled(Actions::kParseOperandPositions)) { |
2247 fprintf(out_file, " @modifiable_instruction"); | 2247 fprintf(out_file, " @modifiable_instruction"); |
2248 } | 2248 } |
2249 for (auto flag_it = flags.begin(); flag_it != flags.end(); ++flag_it) { | 2249 for (auto flag_it = flags.begin(); flag_it != flags.end(); ++flag_it) { |
2250 auto &flag = *flag_it; | 2250 auto &flag = *flag_it; |
2251 if (!strncmp(flag.c_str(), "CPUFeature_", 11)) { | 2251 if (!strncmp(flag.c_str(), "CPUFeature_", 11)) { |
2252 fprintf(out_file, " @%s", flag.c_str()); | 2252 fprintf(out_file, " @%s", flag.c_str()); |
2253 } | 2253 } |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2426 (operand.source != 'R') && (operand.source != 'U') && | 2426 (operand.source != 'R') && (operand.source != 'U') && |
2427 (operand.source != 'W')) || !memory_access)) { | 2427 (operand.source != 'W')) || !memory_access)) { |
2428 fprintf(out_file, " @operand%zd_%s", operand_index, | 2428 fprintf(out_file, " @operand%zd_%s", operand_index, |
2429 operand_size); | 2429 operand_size); |
2430 } | 2430 } |
2431 } | 2431 } |
2432 } | 2432 } |
2433 static std::map<char, const char*> operand_type { | 2433 static std::map<char, const char*> operand_type { |
2434 { '1', "one" }, | 2434 { '1', "one" }, |
2435 { 'a', "rax" }, | 2435 { 'a', "rax" }, |
2436 { 'b', "ds_rbx" }, | |
2437 { 'c', "rcx" }, | 2436 { 'c', "rcx" }, |
2438 { 'd', "rdx" }, | 2437 { 'd', "rdx" }, |
2439 { 'i', "second_immediate" }, | 2438 { 'i', "second_immediate" }, |
2440 { 'o', "port_dx" }, | 2439 { 'o', "port_dx" }, |
2441 { 't', "st" }, | 2440 { 't', "st" }, |
| 2441 { 'x', "ds_rbx" }, |
2442 { 'B', "from_vex" }, | 2442 { 'B', "from_vex" }, |
2443 { 'H', "from_vex" }, | 2443 { 'H', "from_vex" }, |
2444 { 'I', "immediate" }, | 2444 { 'I', "immediate" }, |
2445 { 'O', "absolute_disp" }, | 2445 { 'O', "absolute_disp" }, |
2446 { 'X', "ds_rsi" }, | 2446 { 'X', "ds_rsi" }, |
2447 { 'Y', "es_rdi" } | 2447 { 'Y', "es_rdi" } |
2448 }; | 2448 }; |
2449 auto it2 = operand_type.find(operand.source); | 2449 auto it2 = operand_type.find(operand.source); |
2450 if (it2 != operand_type.end()) { | 2450 if (it2 != operand_type.end()) { |
2451 if (operand.enabled) { | 2451 if (operand.enabled) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 } | 2565 } |
2566 fprintf(out_file, " %s", it->second); | 2566 fprintf(out_file, " %s", it->second); |
2567 } | 2567 } |
2568 if (operand->source == 'L') { | 2568 if (operand->source == 'L') { |
2569 if (operands.size() == 4) { | 2569 if (operands.size() == 4) { |
2570 if (ia32_mode) { | 2570 if (ia32_mode) { |
2571 fprintf(out_file, " b_0xxx_0000"); | 2571 fprintf(out_file, " b_0xxx_0000"); |
2572 } else { | 2572 } else { |
2573 fprintf(out_file, " b_xxxx_0000"); | 2573 fprintf(out_file, " b_xxxx_0000"); |
2574 } | 2574 } |
| 2575 if (!enabled(Actions::kInstructionName)) |
| 2576 fprintf(out_file, " @last_byte_is_not_immediate"); |
2575 } | 2577 } |
2576 if (operand->enabled && enabled(Actions::kParseOperands)) { | 2578 if (operand->enabled && enabled(Actions::kParseOperands)) { |
2577 fprintf(out_file, " @operand%zd_from_is4", operand_index - 1); | 2579 fprintf(out_file, " @operand%zd_from_is4", operand_index - 1); |
2578 } | 2580 } |
2579 } | 2581 } |
2580 if (operand->source == 'O') { | 2582 if (operand->source == 'O') { |
2581 if (ia32_mode) { | 2583 if (ia32_mode) { |
2582 fprintf(out_file, " disp32"); | 2584 fprintf(out_file, " disp32"); |
2583 } else { | 2585 } else { |
2584 fprintf(out_file, " disp64"); | 2586 fprintf(out_file, " disp64"); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2794 | 2796 |
2795 fprintf(out_file, "\n one_instruction ="); | 2797 fprintf(out_file, "\n one_instruction ="); |
2796 | 2798 |
2797 print_one_instruction_definition(); | 2799 print_one_instruction_definition(); |
2798 | 2800 |
2799 fprintf(out_file, ");\n" | 2801 fprintf(out_file, ");\n" |
2800 "}%%%%\n" | 2802 "}%%%%\n" |
2801 ""); | 2803 ""); |
2802 return 0; | 2804 return 0; |
2803 } | 2805 } |
OLD | NEW |