diff options
author | Fabio Rinaldi <fabio.rinaldi@linaro.org> | 2020-02-12 16:18:50 +0000 |
---|---|---|
committer | Roland Levillain <rpl@google.com> | 2020-07-22 10:44:31 +0000 |
commit | 40b0614be3296e163654c4e293793d00bcf36a5a (patch) | |
tree | 5dcd9dd7d93d14b83c82cb90674df9353280189d /tools/checker/file_format/c1visualizer/parser.py | |
parent | 52fe49e87902fb231201874f52c4993e6fe611e9 (diff) |
Checker: Add function isaHasFeature
Developers are now able to use hasIsaFeature("feature_name") to
check if an instruction set feature was used at compile time.
Checker will retrieve the list of features from the .cfg file. It
expects them to be dumped at the beginning of the file as a fake
compilation block in the following form:
begin_compilation
name "isa_features:feature1,-feature2"
method "isa_features:feature1,-feature2"
date 1580721972
end_compilation
Dumping that is optional. hasIsaFeature() will always return False
if that pass is not found.
Author: Fabio Rinaldi
Committer: Artem Serov
Bug: 147876827
Test: ./art/tools/checker/run_unit_tests.py
Test: test.py --target --optimizing
Change-Id: I4ce15d853025f9863d7981b33b761cfc799fed50
Diffstat (limited to 'tools/checker/file_format/c1visualizer/parser.py')
-rw-r--r-- | tools/checker/file_format/c1visualizer/parser.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/tools/checker/file_format/c1visualizer/parser.py b/tools/checker/file_format/c1visualizer/parser.py index bdcde9db51..e16382e3f7 100644 --- a/tools/checker/file_format/c1visualizer/parser.py +++ b/tools/checker/file_format/c1visualizer/parser.py @@ -25,7 +25,7 @@ class C1ParserState: self.currentState = C1ParserState.OutsideBlock self.lastMethodName = None -def __parseC1Line(line, lineNo, state, fileName): +def __parseC1Line(c1File, line, lineNo, state, fileName): """ This function is invoked on each line of the output file and returns a triplet which instructs the parser how the line should be handled. If the line is to be included in the current group, it is returned in the first @@ -58,7 +58,25 @@ def __parseC1Line(line, lineNo, state, fileName): methodName = line.split("\"")[1].strip() if not methodName: Logger.fail("Empty method name in output", fileName, lineNo) - state.lastMethodName = methodName + + m = re.match("isa_features:([\w,-]+)", methodName) + if (m): + rawFeatures = m.group(1).split(",") + # Create a map of features in the form {featureName: isEnabled}. + features = {} + for rf in rawFeatures: + featureName = rf + isEnabled = True + # A '-' in front of the feature name indicates that the feature wasn't enabled at compile + # time. + if rf[0] == '-': + featureName = rf[1:] + isEnabled = False + features[featureName] = isEnabled + + c1File.setISAFeatures(features) + else: + state.lastMethodName = methodName elif line == "end_compilation": state.currentState = C1ParserState.OutsideBlock return (None, None, None) @@ -81,7 +99,7 @@ def __parseC1Line(line, lineNo, state, fileName): def ParseC1visualizerStream(fileName, stream): c1File = C1visualizerFile(fileName) state = C1ParserState() - fnProcessLine = lambda line, lineNo: __parseC1Line(line, lineNo, state, fileName) + fnProcessLine = lambda line, lineNo: __parseC1Line(c1File, line, lineNo, state, fileName) fnLineOutsideChunk = lambda line, lineNo: \ Logger.fail("C1visualizer line not inside a group", fileName, lineNo) for passName, passLines, startLineNo, testArch in \ |