summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-04-25 11:36:08 -0700
committerJason Ekstrand <[email protected]>2016-04-27 11:21:06 -0700
commit736ee0bef7ec71370185395aeba443e12b6d3813 (patch)
treeed14e5825f1deb64b94fa6f7db0e6b8b3f953e69 /src
parentb1dcedf393e2464fb70e793b9224c5ad438e2914 (diff)
nir/algebraic: Do better error reporting of bad expressions
Previously, if an exception was encountered anywhere, nir_algebraic would just die in a fire with no indication whatsoever as to where the actual bug is. This commit makes it print out the particular search-and-replace expression that is causing problems along with the exception. Also, it will now report all of the errors it finds and then exit at the end like a standard C compiler would do. Reviewed-by: Dylan Baker <[email protected]> Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/nir/nir_algebraic.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_algebraic.py b/src/compiler/nir/nir_algebraic.py
index 76971714260..921d32b582c 100644
--- a/src/compiler/nir/nir_algebraic.py
+++ b/src/compiler/nir/nir_algebraic.py
@@ -24,11 +24,13 @@
# Authors:
# Jason Ekstrand ([email protected])
+from __future__ import print_function
import itertools
import struct
import sys
import mako.template
import re
+import traceback
# Represents a set of variables, each with a unique id
class VarSet(object):
@@ -311,15 +313,28 @@ class AlgebraicPass(object):
self.xform_dict = {}
self.pass_name = pass_name
+ error = False
+
for xform in transforms:
if not isinstance(xform, SearchAndReplace):
- xform = SearchAndReplace(xform)
+ try:
+ xform = SearchAndReplace(xform)
+ except:
+ print("Failed to parse transformation:", file=sys.stderr)
+ print(" " + str(xform), file=sys.stderr)
+ traceback.print_exc(file=sys.stderr)
+ print('', file=sys.stderr)
+ error = True
+ continue
if xform.search.opcode not in self.xform_dict:
self.xform_dict[xform.search.opcode] = []
self.xform_dict[xform.search.opcode].append(xform)
+ if error:
+ sys.exit(1)
+
def render(self):
return _algebraic_pass_template.render(pass_name=self.pass_name,
xform_dict=self.xform_dict,