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

Unified Diff: src/trusted/validator_mips/dgen/dgen_dump.py

Issue 9979025: [MIPS] Adding validator for MIPS architecture. (Closed) Base URL: http://src.chromium.org/native_client/trunk/src/native_client/
Patch Set: Rebased patch, conflict resolved. Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/trusted/validator_mips/dgen/dgen_core.py ('k') | src/trusted/validator_mips/dgen/dgen_input.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/validator_mips/dgen/dgen_dump.py
diff --git a/src/trusted/validator_mips/dgen/dgen_dump.py b/src/trusted/validator_mips/dgen/dgen_dump.py
new file mode 100755
index 0000000000000000000000000000000000000000..8a6c53e7cb57736e72c62d1a5e46f5942e69ef51
--- /dev/null
+++ b/src/trusted/validator_mips/dgen/dgen_dump.py
@@ -0,0 +1,50 @@
+#!/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.
+#
+
+"""
+Produces a table from the in-memory representation. Useful for storing the
+optimized table for later use.
+"""
+
+import dgen_opt
+
+def dump_tables(tables, out):
+ """Dumps the given tables into a text file.
+
+ Args:
+ tables: list of Table objects to process.
+ out: an output stream.
+ """
+ if len(tables) == 0: raise Exception('No tables provided.')
+
+ _generate_header(out)
+ for t in tables:
+ _generate_table(t, out)
+
+def _generate_header(out):
+ # TODO do we need a big ridiculous license banner in generated code?
+ out.write('# DO NOT EDIT: GENERATED CODE\n')
+
+
+def _generate_table(t, out):
+ rows = dgen_opt.optimize_rows(t.rows)
+ print ('Table %s: %d rows minimized to %d.'
+ % (t.name, len(t.rows), len(rows)))
+
+ out.write('\n')
+ out.write('-- %s (%s)\n' % (t.name, t.citation))
+ num_cols = len(rows[0].patterns)
+ headers = ['pat%- 31s' % (str(n) + '(31:0)') for n in range(0, num_cols)]
+ out.write(''.join(headers))
+ out.write('\n')
+ for row in rows:
+ out.write(''.join(['%- 34s' % p for p in row.patterns]))
+ out.write(row.action)
+ if row.arch:
+ out.write('(%s)' % row.arch)
+ out.write('\n')
« no previous file with comments | « src/trusted/validator_mips/dgen/dgen_core.py ('k') | src/trusted/validator_mips/dgen/dgen_input.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698