Index: src/trusted/validator_mips/dgen/generate_decoder.py |
diff --git a/src/trusted/validator_mips/dgen/generate_decoder.py b/src/trusted/validator_mips/dgen/generate_decoder.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..67f7db7d5ba74febe5aa11868c23837ec215989c |
--- /dev/null |
+++ b/src/trusted/validator_mips/dgen/generate_decoder.py |
@@ -0,0 +1,42 @@ |
+#!/usr/bin/python |
+# |
+# Copyright 2012 The Native Client Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can |
+# be found in the LICENSE file. |
+# Copyright 2012, Google Inc. |
+# |
+ |
+"""Decoder Generator script. |
+ |
+Usage: generate-decoder.py <table-file> <output-cc-file> |
+""" |
+ |
+# TODO(petarj): This was copied from the old ARM decoder tablegen. |
+# Once the changes on that tablegen are stable, this will be rewritten to use |
+# the new tablegen. |
+ |
+import sys |
+import dgen_input |
+import dgen_output |
+ |
+def main(argv): |
+ table_filename, output_filename = argv[1], argv[2] |
+ |
+ print "Decoder Generator reading ", table_filename |
+ f = open(table_filename, 'r') |
+ tables = dgen_input.parse_tables(f) |
+ f.close() |
+ |
+ print "Successful - got %d tables." % len(tables) |
+ |
+ print "Generating output to %s..." % output_filename |
+ f = open(output_filename, 'w') |
+ dgen_output.generate_decoder(tables, |
+ dgen_output.COutput(f)) |
+ f.close() |
+ print "Completed." |
+ |
+ return 0 |
+ |
+if __name__ == '__main__': |
+ sys.exit(main(sys.argv)) |