OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # | 2 # |
3 # Copyright 2009 The Native Client Authors. All rights reserved. | 3 # Copyright 2011 The Native Client Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can | 4 # Use of this source code is governed by a BSD-style license that can |
5 # be found in the LICENSE file. | 5 # be found in the LICENSE file. |
6 # Copyright 2009, Google Inc. | 6 # Copyright 2011, Google Inc. |
7 # | 7 # |
8 | 8 |
9 """Decoder Generator script. | 9 """Decoder Generator script. |
10 | 10 |
11 Usage: generate-decoder.py <table-file> <output-cc-file> | 11 Usage: generate-decoder.py <arm-table-file> <thumb-table-file> <output-cc-file> |
Karl
2011/09/19 19:56:05
Again, thumb or thumb2?
jasonwkim
2011/09/26 21:35:52
Decision on whethwe you are in thumb2 (vs old thum
| |
12 """ | 12 """ |
13 | 13 |
14 import sys | 14 import sys |
15 import dgen_input | 15 import dgen_input |
16 import dgen_output | 16 import dgen_output |
17 | 17 |
18 def main(argv): | 18 def get_tables(filename): |
19 table_filename, output_filename = argv[1], argv[2] | 19 print "Decoder Generator reading ", filename |
20 | 20 f = open(filename, 'r') |
21 print "Decoder Generator reading ", table_filename | |
22 f = open(table_filename, 'r') | |
23 tables = dgen_input.parse_tables(f) | 21 tables = dgen_input.parse_tables(f) |
24 f.close() | 22 f.close() |
23 print "Successful - got %d tables." % len (tables) | |
24 return tables | |
25 | 25 |
26 print "Successful - got %d tables." % len(tables) | 26 def main(argv): |
27 arm_filename, thumb_filename, output_filename = argv[1], argv[2], argv[3] | |
28 arm_tables = get_tables(arm_filename) | |
29 thumb_tables = get_tables(thumb_filename) | |
27 | 30 |
28 print "Generating output to %s..." % output_filename | 31 print "Generating output to %s..." % output_filename |
29 f = open(output_filename, 'w') | 32 f = open(output_filename, 'w') |
30 dgen_output.generate_decoder(tables, | 33 dgen_output.generate_decoder(arm_tables, thumb_tables, |
31 dgen_output.COutput(f)) | 34 dgen_output.COutput(f)) |
32 f.close() | 35 f.close() |
36 | |
33 print "Completed." | 37 print "Completed." |
34 | 38 |
35 return 0 | 39 return 0 |
36 | 40 |
37 if __name__ == '__main__': | 41 if __name__ == '__main__': |
38 sys.exit(main(sys.argv)) | 42 sys.exit(main(sys.argv)) |
OLD | NEW |