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

Side by Side Diff: src/trusted/validator_arm/dgen_test_output.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/trusted/validator_arm/dgen_input.py ('k') | src/trusted/validator_arm/gen/arm32_decode.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2012 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 be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 # 6 #
7 7
8 """ 8 """
9 Responsible for generating the testing decoders based on 9 Responsible for generating the testing decoders based on
10 parsed table representations. 10 parsed table representations.
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 # Note: DECODER will be replaced by 'actual' and 'baseline', defining 176 # Note: DECODER will be replaced by 'actual' and 'baseline', defining
177 # how both types of symbols are generated. 177 # how both types of symbols are generated.
178 178
179 CLASS = '%(DECODER)s_%(rule)s' 179 CLASS = '%(DECODER)s_%(rule)s'
180 NAMED_CLASS = 'Named%(DECODER)s_%(rule)s' 180 NAMED_CLASS = 'Named%(DECODER)s_%(rule)s'
181 INSTANCE = '%(DECODER_class)s_instance_' 181 INSTANCE = '%(DECODER_class)s_instance_'
182 BASE_TESTER='%(decoder_base)sTester%(base_test_case)s' 182 BASE_TESTER='%(decoder_base)sTester%(base_test_case)s'
183 BASE_BASE_TESTER='%(decoder_base)sTester%(qualifier)s' 183 BASE_BASE_TESTER='%(decoder_base)sTester%(qualifier)s'
184 DECODER_TESTER='%(baseline)sTester_%(test_case)s' 184 DECODER_TESTER='%(baseline)sTester_%(test_case)s'
185 185
186 def _negated_constraint(constraint):
187 """Returns the negated pattern for the pattern text passed in."""
188 if constraint[0] == '~':
189 return constraint[1:]
190 else:
191 return '~' + constraint
192
193 def _safety_to_check(safety): 186 def _safety_to_check(safety):
194 return [s for s in safety if not isinstance(s, str)] 187 return [s for s in safety if not isinstance(s, str)]
195 188
196 def _interesting_patterns(patterns): 189 def _interesting_patterns(patterns):
197 """ Filters out non-interesting patterns.""" 190 """ Filters out non-interesting patterns."""
198 # Only include rows not corresponding to rule pattern, 191 # Only include rows not corresponding to rule pattern,
199 # and not always true. 192 # and not always true.
200 return [ p for p in patterns if ( 193 return [ p for p in patterns if (
201 (not p.column or p.column.name() != '$pattern') 194 (not p.column or p.column.name() != '$pattern')
202 and not p.matches_any())] 195 and not p.matches_any())]
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 return row.copy_with_action( 817 return row.copy_with_action(
825 _filter_test_action(row.action, with_patterns, with_rules)) 818 _filter_test_action(row.action, with_patterns, with_rules))
826 819
827 def _install_row_cases(row, values): 820 def _install_row_cases(row, values):
828 """Installs row case names, based on values entries.""" 821 """Installs row case names, based on values entries."""
829 822
830 # First define base testers that add row constraints and safety checks. 823 # First define base testers that add row constraints and safety checks.
831 constraint_rows_map = values.get('constraint_rows') 824 constraint_rows_map = values.get('constraint_rows')
832 if constraint_rows_map: 825 if constraint_rows_map:
833 base_row = _filter_test_row(row, with_rules=False) 826 base_row = _filter_test_row(row, with_rules=False)
834 base_index = constraint_rows_map[dgen_core.neutral_repr(base_row)]
835 values['base_test_case'] = ( 827 values['base_test_case'] = (
836 'Case%s' % constraint_rows_map[dgen_core.neutral_repr(base_row)]) 828 'Case%s' % constraint_rows_map[dgen_core.neutral_repr(base_row)])
837 else: 829 else:
838 values['base_test_case'] = '' 830 values['base_test_case'] = ''
839 831
840 # Add test decoders associated with the row in the table. 832 # Add test decoders associated with the row in the table.
841 decoder_rows_map = values.get('decoder_rows') 833 decoder_rows_map = values.get('decoder_rows')
842 if decoder_rows_map: 834 if decoder_rows_map:
843 decoder_row = _filter_test_row(row) 835 decoder_row = _filter_test_row(row)
844 values['test_case'] = ( 836 values['test_case'] = (
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 if row.patterns or action.constraints().restrictions: 906 if row.patterns or action.constraints().restrictions:
915 out.write(CONSTRAINT_TESTER_PARSE_HEADER % values) 907 out.write(CONSTRAINT_TESTER_PARSE_HEADER % values)
916 if row.patterns: 908 if row.patterns:
917 out.write(ROW_CONSTRAINTS_HEADER % values); 909 out.write(ROW_CONSTRAINTS_HEADER % values);
918 for p in row.patterns: 910 for p in row.patterns:
919 out.write(CONSTRAINT_CHECK % p.negate().to_commented_bool()) 911 out.write(CONSTRAINT_CHECK % p.negate().to_commented_bool())
920 if action.constraints().restrictions: 912 if action.constraints().restrictions:
921 out.write(PATTERN_CONSTRAINT_RESTRICTIONS_HEADER) 913 out.write(PATTERN_CONSTRAINT_RESTRICTIONS_HEADER)
922 for c in action.constraints().restrictions: 914 for c in action.constraints().restrictions:
923 out.write(CONSTRAINT_CHECK % 915 out.write(CONSTRAINT_CHECK %
924 dgen_core.BitPattern.parse( 916 c.negate().to_commented_bool())
925 _negated_constraint(c),
926 dgen_core.BitField('constraint', 31, 0))
927 .to_commented_bool())
928 out.write(CONSTRAINT_TESTER_CLASS_FOOTER % values) 917 out.write(CONSTRAINT_TESTER_CLASS_FOOTER % values)
929 if safety_to_check: 918 if safety_to_check:
930 out.write(SAFETY_TESTER_HEADER % values) 919 out.write(SAFETY_TESTER_HEADER % values)
931 for check in safety_to_check: 920 for check in safety_to_check:
932 out.write(SAFETY_TESTER_CHECK % 921 out.write(SAFETY_TESTER_CHECK %
933 check.to_commented_bool()); 922 check.to_commented_bool());
934 out.write(SAFETY_TESTER_FOOTER % values) 923 out.write(SAFETY_TESTER_FOOTER % values)
935 924
936 def _generate_rule_testers(decoder, values, out): 925 def _generate_rule_testers(decoder, values, out):
937 """Generates the testers that tests the rule associated with 926 """Generates the testers that tests the rule associated with
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
972 out.write(TEST_FUNCTION_BASELINE % values) 961 out.write(TEST_FUNCTION_BASELINE % values)
973 else: 962 else:
974 out.write(TEST_FUNCTION_ACTUAL_VS_BASELINE % values) 963 out.write(TEST_FUNCTION_ACTUAL_VS_BASELINE % values)
975 964
976 def _index_neutral_map(values): 965 def _index_neutral_map(values):
977 """Returns a dictionary from each neutral_repr(value) in list 966 """Returns a dictionary from each neutral_repr(value) in list
978 values, to its corresponding index. This is done to reduce the 967 values, to its corresponding index. This is done to reduce the
979 number of compares to find the index, speeding up code 968 number of compares to find the index, speeding up code
980 generation. 969 generation.
981 """ 970 """
982 map = {} 971 lookup_map = {}
983 index = 0 972 index = 0
984 for v in values: 973 for v in values:
985 map[dgen_core.neutral_repr(v)] = index 974 lookup_map[dgen_core.neutral_repr(v)] = index
986 index += 1 975 index += 1
987 return map 976 return map
OLDNEW
« no previous file with comments | « src/trusted/validator_arm/dgen_input.py ('k') | src/trusted/validator_arm/gen/arm32_decode.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698