diff options
author | Ian Romanick <[email protected]> | 2015-04-15 17:50:57 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2016-08-30 16:28:00 -0700 |
commit | fb44f69779ed7497768421ccd60e73cc707ffe69 (patch) | |
tree | 7e648f9de8724ff264ce60800fae8083540b4ba0 /src/compiler/glsl/ir_expression_operation.py | |
parent | 90781eee4dfc101199ea557003f28126abe86912 (diff) |
glsl: Generate ir_expression_operation_strings.h from Python
'diff -ud' is clean.
v2: Massive rebase.
v3: With much help from José Fonseca, fix the SCons build.
Signed-off-by: Ian Romanick <[email protected]>
Reviewed-by: Matt Turner <[email protected]>
Acked-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/compiler/glsl/ir_expression_operation.py')
-rw-r--r-- | src/compiler/glsl/ir_expression_operation.py | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/src/compiler/glsl/ir_expression_operation.py b/src/compiler/glsl/ir_expression_operation.py index 743ca915f1f..8b55c282cff 100644 --- a/src/compiler/glsl/ir_expression_operation.py +++ b/src/compiler/glsl/ir_expression_operation.py @@ -22,6 +22,7 @@ # IN THE SOFTWARE. import mako.template +import sys ir_expression_operation = [ # Name operands string comment @@ -318,7 +319,7 @@ def name_from_item(item): return "ir_{}op_{}".format(("un", "bin", "tri", "quad")[item[1]-1], item[0]) if __name__ == "__main__": - enum_template = mako.template.Template("""/* + copyright = """/* * Copyright (C) 2010 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a @@ -340,7 +341,8 @@ if __name__ == "__main__": * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ - +""" + enum_template = mako.template.Template(copyright + """ /* Update ir_expression::get_num_operands() and operator_strs when * updating this list. */ @@ -362,15 +364,28 @@ ${item} ir_last_opcode = ir_quadop_${lasts[3][0]} };""") - lasts = [None, None, None, None] - for item in reversed(ir_expression_operation): - if isinstance(item, str): - continue + strings_template = mako.template.Template(copyright + """ +static const char *const operator_strs[] = { +% for item in values: +% if not isinstance(item, str): + "${item[2] if item[2] is not None else item[0]}", +% endif +% endfor +};""") + + if sys.argv[1] == "enum": + lasts = [None, None, None, None] + for item in reversed(ir_expression_operation): + if isinstance(item, str): + continue - i = item[1] - 1 - if lasts[i] is None: - lasts[i] = (item[0], i) + i = item[1] - 1 + if lasts[i] is None: + lasts[i] = (item[0], i) - print(enum_template.render(values=ir_expression_operation, - lasts=lasts, - name_from_item=name_from_item)) + print(enum_template.render(values=ir_expression_operation, + lasts=lasts, + name_from_item=name_from_item)) + elif sys.argv[1] == "strings": + print(strings_template.render(values=ir_expression_operation, + name_from_item=name_from_item)) |