| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 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 # Creates byte_machines.rl file. Each machine accepts exactly one byte. | 6 # Creates byte_machines.rl file. Each machine accepts exactly one byte. |
| 7 # | 7 # |
| 8 # In the name of a machine "0" means "unset bit", "1" means "set bit", "x" or | 8 # In the name of a machine "0" means "unset bit", "1" means "set bit", "x" or |
| 9 # "X" mean "any bit", other letters are ignored. Prefix "b_" is used as | 9 # "X" mean "any bit", other letters are ignored. Prefix "b_" is used as |
| 10 # convention to distinguish these autogenerated machines from the hand-written | 10 # convention to distinguish these autogenerated machines from the hand-written |
| 11 # ones, underscores are used to separate bitfields in a byte. | 11 # ones, underscores are used to separate bitfields in a byte. |
| 12 # | 12 # |
| 13 # For example: | 13 # For example: |
| 14 # b_00_xxx_100 = 0x04 | 0x0c | 0x14 | 0x1c | 0x24 | 0x2c | 0x34 | 0x3c; | 14 # b_00_xxx_100 = 0x04 | 0x0c | 0x14 | 0x1c | 0x24 | 0x2c | 0x34 | 0x3c; |
| 15 | 15 |
| 16 from __future__ import print_function | 16 from __future__ import print_function |
| 17 | 17 |
| 18 import optparse | 18 import optparse |
| 19 import sys | 19 import sys |
| 20 | 20 |
| 21 byte_machines = [ | 21 byte_machines = [ |
| 22 # ModR/M parsing | 22 # ModR/M parsing |
| 23 'b_00_xxx_100', | 23 'b_00_xxx_100', |
| 24 'b_00_xxx_101', |
| 24 'b_01_xxx_100', | 25 'b_01_xxx_100', |
| 25 'b_10_xxx_100', | 26 'b_10_xxx_100', |
| 26 'b_00_xxx_101', | 27 'b_00_xxx_xxx', |
| 28 'b_11_010_xxx', |
| 29 'b_01_xxx_xxx', |
| 30 'b_10_xxx_xxx', |
| 31 'b_11_010_111', |
| 32 'b_11_100_111', |
| 33 'b_11_100_xxx', |
| 34 'b_11_111_111', |
| 35 'b_11_111_xxx', |
| 36 'b_11_xxx_111', |
| 37 'b_11_xxx_xxx', |
| 27 'b_xx_xxx_100', | 38 'b_xx_xxx_100', |
| 28 'b_xx_xxx_101', | 39 'b_xx_xxx_101', |
| 29 'b_00_xxx_xxx', | |
| 30 'b_01_xxx_xxx', | |
| 31 'b_10_xxx_xxx', | |
| 32 'b_11_xxx_xxx', | |
| 33 | 40 |
| 34 # Opcodes | 41 # Opcodes |
| 35 'b_xx_000_xxx', | 42 'b_xx_000_xxx', |
| 36 'b_xx_001_xxx', | 43 'b_xx_001_xxx', |
| 37 'b_xx_010_xxx', | 44 'b_xx_010_xxx', |
| 38 'b_xx_011_xxx', | 45 'b_xx_011_xxx', |
| 39 'b_xx_100_xxx', | 46 'b_xx_100_xxx', |
| 40 'b_xx_101_xxx', | 47 'b_xx_101_xxx', |
| 41 'b_xx_110_xxx', | 48 'b_xx_110_xxx', |
| 42 'b_xx_111_xxx', | 49 'b_xx_111_xxx', |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 help='write output to FILE', metavar='FILE') | 215 help='write output to FILE', metavar='FILE') |
| 209 (options, args) = parser.parse_args() | 216 (options, args) = parser.parse_args() |
| 210 if options.filename is None: | 217 if options.filename is None: |
| 211 GenerateByteMachines(sys.stdout) | 218 GenerateByteMachines(sys.stdout) |
| 212 else: | 219 else: |
| 213 with open(options.filename, 'w') as f: | 220 with open(options.filename, 'w') as f: |
| 214 GenerateByteMachines(f, options.filename) | 221 GenerateByteMachines(f, options.filename) |
| 215 | 222 |
| 216 if __name__ == '__main__': | 223 if __name__ == '__main__': |
| 217 Main() | 224 Main() |
| OLD | NEW |