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

Side by Side Diff: src/trusted/validator_arm/dgen_core.py

Issue 9960043: Finish separation of testing from sel_ldr validation. Also, automate (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright 2009 The Native Client Authors. All rights reserved. 3 # Copyright (c) 2012 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 be
5 # be found in the LICENSE file. 5 # found in the LICENSE file.
6 # Copyright 2009, Google Inc.
7 # 6 #
8 7
9 """ 8 """
10 The core object model for the Decoder Generator. The dg_input and dg_output 9 The core object model for the Decoder Generator. The dg_input and dg_output
11 modules both operate in terms of these classes. 10 modules both operate in terms of these classes.
12 """ 11 """
13 12
14 import re 13 import re
15 14
16 def _popcount(int): 15 def _popcount(int):
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 if m: 220 if m:
222 action_string = m.group(1) 221 action_string = m.group(1)
223 arch = m.group(2) 222 arch = m.group(2)
224 223
225 parsed = [] 224 parsed = []
226 for i in range(0, len(col_patterns)): 225 for i in range(0, len(col_patterns)):
227 col = self._columns[i] 226 col = self._columns[i]
228 parsed.append(BitPattern.parse(col_patterns[i], col[1], col[2])) 227 parsed.append(BitPattern.parse(col_patterns[i], col[1], col[2]))
229 self.rows.append(Row(parsed, action_string, arch)) 228 self.rows.append(Row(parsed, action_string, arch))
230 229
230 def rows_filtered(self, num_actions):
231 """Returns rows for building runtime tables. Automatically filters
232 actions down to the specified number of actions. Typically this
233 is done to remove unwanted testing data that would minimize the
234 effect of optimizing the rows of a table.
235 """
236 rows = []
237 for r in self.rows:
238 count = 1
239 reduced_actions = []
240 for a in r.action.split():
robertm 2012/04/11 01:28:43 could this be simplified with array slicing, e.g.
Karl 2012/04/16 23:18:10 This code simplified once I removed parsing from t
241 if count > num_actions: break;
242 reduced_actions.append(a)
243 count += 1
244 rows.append(Row(r.patterns, ' '.join(reduced_actions), r.arch))
245 return rows
231 246
232 class Row(object): 247 class Row(object):
233 """ A row in a Table.""" 248 """ A row in a Table."""
234 def __init__(self, patterns, action, arch): 249 def __init__(self, patterns, action, arch):
235 """Initializes a Row. 250 """Initializes a Row.
236 Args: 251 Args:
237 patterns: a list of BitPatterns that must match for this Row to 252 patterns: a list of BitPatterns that must match for this Row to
238 match. 253 match.
239 action: the action to be taken if this Row matches. 254 action: the action to be taken if this Row matches.
240 arch: the minimum architecture that this Row can match. 255 arch: the minimum architecture that this Row can match.
(...skipping 29 matching lines...) Expand all
270 self.action, self.arch) 285 self.action, self.arch)
271 286
272 def __cmp__(self, other): 287 def __cmp__(self, other):
273 """Compares two rows, so we can order pattern matches by specificity. 288 """Compares two rows, so we can order pattern matches by specificity.
274 """ 289 """
275 return (cmp(self.patterns, other.patterns) 290 return (cmp(self.patterns, other.patterns)
276 or cmp(self.action, other.action)) 291 or cmp(self.action, other.action))
277 292
278 def __repr__(self): 293 def __repr__(self):
279 return 'Row(%s, %s)' % (repr(self.patterns), repr(self.action)) 294 return 'Row(%s, %s)' % (repr(self.patterns), repr(self.action))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698