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

Unified Diff: src/trusted/validator_arm/dgen_input.py

Issue 10949006: Change table data_processing_immediate to use the new notation. Also (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 3 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_arm/dgen_core.py ('k') | src/trusted/validator_arm/dgen_test_output.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/validator_arm/dgen_input.py
===================================================================
--- src/trusted/validator_arm/dgen_input.py (revision 9791)
+++ src/trusted/validator_arm/dgen_input.py (working copy)
@@ -20,7 +20,7 @@
action_safety |
action_arch |
action_other) ';'
-action_options_deprecated ::= (id (word (rule_restrict id?)?)?)?
+action_options_deprecated ::= (id (word (rule_restrict_deprecated id?)?)?)?
action_other ::= word ':=' bit_expr
action_pattern ::= 'pattern' ':=' word rule_restrict?
action_safety ::= 'safety' ':=' safety_check ('&' safety_check)*
@@ -52,7 +52,7 @@
decoder ::= id ('=>' id)?
decoder_action ::= '=" (decoder (fields? action_option* |
action_options_deprecated arch?)
- | '*' int action_option*)
+ | '*' (int | id) action_option*)
decoder_method ::= '->' id
default_row ::= 'else' ':' action
fields ::= '{' column (',' column)* '}'
@@ -65,10 +65,11 @@
pat_row ::= pattern+ action
pattern ::= bitpattern | '-' | '"'
row ::= '|' (pat_row | default_row)
-rule_restrict ::= ('&' bitpattern)* ('&' 'other' ':' id)?
+rule_restrict ::= ('&' bit_expr)* ('&' 'other' ':' id)?
+rule_restrict_deprecated ::= ('&' bitpattern)* ('&' 'other' ':' id)?
safety_check ::= id | bit_expr1 ('=>' id)? # note: single id only at end.
table ::= table_desc table_actions header row+ footer
-table_actions ::= ( ('*' int decoder fields? action_options*)+ footer)?
+table_actions ::= ( ('*' (int | id) decoder fields? action_options*)+ footer)?
table_desc ::= '+' '-' '-' id citation?
Note that action_options_deprecated is deprecated, and one should generate
@@ -511,7 +512,7 @@
def _decoder_action(self, starred_actions):
"""decoder_action ::= '=" (decoder (fields? action_option* |
action_options_deprecated arch?)
- | '*' int action_option*)
+ | '*' (int | id) action_option*)
"""
self._read_token('=')
if self._next_token().kind == '*':
@@ -530,7 +531,7 @@
else:
context.define('rule', self._read_id_or_none(True))
context.define('pattern', self._read_id_or_none(False))
- self._rule_restrict(context)
+ self._rule_restrict_deprecated(context)
other_restrictions = self._read_id_or_none(True)
if other_restrictions:
context.define('safety', [other_restrictions])
@@ -539,11 +540,14 @@
return action
def _decoder_action_extend(self, starred_actions):
- """'*' int action_option*
+ """'*' (int | id) action_option*
Helper function to _decoder_action."""
self._read_token('*')
- index = self._int()
+ if self._is_int():
+ index = self._int()
+ else:
+ index = self._id()
indexed_action = starred_actions.get(index)
if not indexed_action:
self._unexpected("Can't find decoder action *%s" % index)
@@ -711,6 +715,22 @@
return self._pat_row(table, starred_actions, last_patterns, last_action)
def _rule_restrict(self, context):
+ """ rule_restrict ::= ('&' bit_expr)* ('&' 'other' ':' id)? """
+
+ restrictions = context.find('constraints')
+ if not restrictions:
+ context.define('constraints', dgen_core.RuleRestrictions())
+ while self._next_token().kind == '&':
+ self._read_token('&')
+ if self._next_token().kind == 'other':
+ self._read_token('other')
+ self._read_token(':')
+ restrictions.safety = self._id()
+ return
+ else:
+ restrictions.add(self._bit_expr(context))
+
+ def _rule_restrict_deprecated(self, context):
""" rule_restrict ::= ('&' bitpattern)* ('&' 'other' ':' id)? """
restrictions = context.find('constraints')
@@ -724,7 +744,9 @@
restrictions.safety = self._id()
return
else:
- restrictions.add(self._bitpattern32())
+ restrictions.add(
+ dgen_core.BitPattern.parse(self._bitpattern32(),
+ dgen_core.BitField('constraint', 31, 0)))
def _safety_check(self, context):
"""safety_check ::= id | bit_expr ('=>' id)?
@@ -756,13 +778,16 @@
self._footer()
def _table_actions(self):
- """table_actions ::= ( ('*' int decoder fields? action_options*)+
+ """table_actions ::= ( ('*' (int | id) decoder fields? action_options*)+
footer)?"""
starred_actions = {}
if self._next_token().kind != '*': return starred_actions
while self._next_token().kind == '*':
self._read_token('*')
- index = self._int()
+ if self._is_int():
+ index = self._int()
+ else:
+ index = self._id()
(baseline, actual) = self._decoder()
action = dgen_core.DecoderAction(baseline, actual)
« no previous file with comments | « src/trusted/validator_arm/dgen_core.py ('k') | src/trusted/validator_arm/dgen_test_output.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698