summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/ir_expression_operation.py
Commit message (Collapse)AuthorAgeFilesLines
* glsl: Add positional argument specifiers.Vinson Lee2016-09-061-5/+5
| | | | | | | | | | | Fix build with Python < 2.7. File "./glsl/ir_expression_operation.py", line 360, in get_enum_name return "ir_{}op_{}".format(("un", "bin", "tri", "quad")[self.num_operands-1], self.name) ValueError: zero length field name in format Fixes: e31c72a331b1 ("glsl: Convert tuple into a class") Signed-off-by: Vinson Lee <vlee@freedesktop.org>
* glsl: Replace most assertions with unreachable()Ian Romanick2016-08-301-10/+9
| | | | | | | | | | | | | | text data bss dec hex filename 7669233 277176 28624 7975033 79b079 i965_dri.so before generated code 7647081 277176 28624 7952881 7959f1 i965_dri.so before this commit 7669289 277176 28624 7975089 79b0b1 i965_dri.so with this commit Looking at the generated assembly, it appears that some of changes made in the generated code prevent some loops from being unrolled. Removing the default cases (via unreachable()) allows these loops to unroll again. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
* glsl: Refactor handling of horizontal operationsIan Romanick2016-08-301-8/+7
| | | | | | Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Use constant_template_horizontal instead of ↵Ian Romanick2016-08-301-1/+1
| | | | | | | | | | | constant_template_horizontal_single_implementation for unops This changes the "shape" of all the pack and unpack operators, but they should function the same. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Eliminate constant_template2Ian Romanick2016-08-301-11/+0
| | | | | | | | | constant_template_common can now handle the case where the result type is different from the input type by using type_signature_iter. This changes the "shape" of all the cast-style operators, but they should function the same. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
* glsl: Eliminate constant_template5Ian Romanick2016-08-301-22/+1
| | | | | | | | constant_template_common can now handle the case where the result type is different from the input type by using type_signature_iter. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
* glsl: Eliminate constant_template0Ian Romanick2016-08-301-34/+4
| | | | | | | | | This template is mostly an artefact of the development of the original patch series and to minimize the differences between the original code and the generated code. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
* glsl: Eliminate one of the templates for simpler operationsIan Romanick2016-08-301-21/+3
| | | | | | | | | | The difference between these two templates were mostly an artefact of the development of the original patch series and to minimize the differences between the original code and the generated code. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_triop_csel expressionsIan Romanick2016-08-301-1/+23
| | | | | | | | v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_triop_lrp expressionsIan Romanick2016-08-301-1/+28
| | | | | | | | v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_quadop_vector expressionsIan Romanick2016-08-301-2/+20
| | | | | | | | v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_quadop_bitfield_insert expressionsIan Romanick2016-08-301-4/+21
| | | | | | | | v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_triop_vector_insert expressionsIan Romanick2016-08-301-2/+25
| | | | | | | | v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_binop_vector_extract expressionsIan Romanick2016-08-301-1/+21
| | | | | | | | v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_binop_mul expressionsIan Romanick2016-08-301-2/+54
| | | | | | | | v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_triop_fma and ir_triop_bitfield_extract ↵Ian Romanick2016-08-301-5/+13
| | | | | | | | | | | | expressions ir_triop_bitfield_extract is a little weird because the second and third operand and aways int, so they may differ in type from the first operand. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_binop_dot expressionsIan Romanick2016-08-301-1/+18
| | | | | | | | v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_binop_lshift and ir_binop_rshift expressionsIan Romanick2016-08-301-2/+13
| | | | | | | | | | | | | | | | The code generated is quite different from what was previously used. I believe that it is still correct by the GLSL spec, and I believe, due to C rules about shifts, the behavior will be the same. Section 5.9 (Expressions) of the GLSL 4.50 spec says: The result is undefined if the right operand is negative, or greater than or equal to the number of bits in the left expression's base type. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant ir_binop_ldexp expressionsIan Romanick2016-08-301-4/+19
| | | | | | | | | | | | ldexp is weird because its two operands have different types. Add support for directly specifying the exact signatures of all the possible variations of an operation. v2: Use tuple() instead of () for clarity. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant unary expressions that don't assign the ↵Ian Romanick2016-08-301-8/+18
| | | | | | | | | | | | | | destination These are operations like the pack functions that have separate functions that assign multiple outputs from a single input. v2: Correct the source and destination types. They were previously transposed. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for some constant binary expression that are horizontalIan Romanick2016-08-301-3/+7
| | | | | | | | | | Only operations where the implementation is identical code regardless of type. The only such operations are ir_binop_all_equal and ir_binop_any_nequal. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant unary expression that are horizontalIan Romanick2016-08-301-6/+16
| | | | | | Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant expressions that have an output type the ↵Ian Romanick2016-08-301-11/+33
| | | | | | | | | | | differs from the input types v2: Remove extra int() cast in find_lsb. Suggested by Matt. 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant binary expressions that combine vector and ↵Ian Romanick2016-08-301-15/+51
| | | | | | | | | | scalar operands v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant binary expressions that have one operand typeIan Romanick2016-08-301-6/+10
| | | | | | Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant unary expression that have different ↵Ian Romanick2016-08-301-12/+33
| | | | | | | | | | implementations for each source type v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate code for constant unary expression that map one type to anotherIan Romanick2016-08-301-24/+57
| | | | | | | | | ir_unop_i2b is omitted because its source can either be int or uint. That makes it special. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Begin generating code for the most basic constant expressionsIan Romanick2016-08-301-17/+158
| | | | | | | | | | | Unary operations where all of the supported types use the same C expression to evaluate them. v2: 'for (a, b) in d' => 'for a, b in d'. Suggested by Dylan. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Convert tuple into a classIan Romanick2016-08-301-127/+138
| | | | | | | | | This makes things a little more clear now, and it will make future changes... possible. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Delete spurious comment about mod not taking integer operandsIan Romanick2016-08-301-6/+1
| | | | | | | This hasn't been true since we added support for GLSL 1.30. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
* glsl: Delete spurious comment about updating ir_expression::get_num_operandsIan Romanick2016-08-301-3/+0
| | | | | | | This hasn't been necessary since 007f48815. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
* glsl: Do not generate comments or extra whitespace in expression filesIan Romanick2016-08-301-301/+216
| | | | | | | | The comments and whitespace can live in the Python code. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Just access the ir_expression_operation strings table directlyIan Romanick2016-08-301-1/+1
| | | | | | | | | | | | | | The operator_string functions gave us some protection against a malformed table. Now that the table is generated from the same data that generates the enum, this is not a concern. Just cut out the middle man. text data bss dec hex filename 7531892 273992 28584 7834468 778b64 i965_dri-64bit-before.so 7531828 273992 28584 7834404 778b24 i965_dri-64bit-after.so Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com>
* glsl: Generate ir_expression_operation_strings.h from PythonIan Romanick2016-08-301-12/+27
| | | | | | | | | | | | 'diff -ud' is clean. v2: Massive rebase. v3: With much help from José Fonseca, fix the SCons build. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate the ir_last_* valuesIan Romanick2016-08-301-28/+20
| | | | | | | | | | This ensures that they remain correct if the list is rearranged or new opcodes are added. I checked a diff of before and after to ensure that each ir_last_ had the same value. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>
* glsl: Generate ir_expression_operation.h from PythonIan Romanick2016-08-301-0/+384
There are differences in where end-of-line comments are placed, but 'diff -wud' is clean. v2: Massive rebase. v3: With much help from José Fonseca, fix SCons build. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Matt Turner <mattst88@gmail.com> Acked-by: Dylan Baker <dylan@pnwbakers.com>