nir: add new constant folding infrastructure
Add a required field to the Opcode class, const_expr, that contains an expression or statement that computes the result of the opcode given known constant inputs. Then take those const_expr's and expand them into a function that takes an opcode and an array of constant inputs and spits out the constant result. This means that when adding opcodes, there's one less place to update, and almost all the opcodes are self-documenting since the information on how to compute the result is right next to the definition. The helper functions in nir_constant_expressions.c were taken from ir_constant_expressions.cpp. v3 Jason Ekstrand <jason.ekstrand@iastate.edu> - Use mako to generate one function per opcode instead of doing piles of string splicing v4 Jason Ekstrand <jason.ekstrand@iastate.edu> - More comments and better indentation in the mako - Add a description of the constant expression language in nir_opcodes.py - Added nir_constant_expressions.py to EXTRA_DIST in Makefile.am Signed-off-by:Jason Ekstrand <jason.ekstrand@intel.com> Reviewed-by:
Connor Abbott <cwabbott0@gmail.com>
Showing
- src/glsl/Makefile.am 6 additions, 0 deletionssrc/glsl/Makefile.am
- src/glsl/Makefile.sources 1 addition, 0 deletionssrc/glsl/Makefile.sources
- src/glsl/nir/.gitignore 1 addition, 0 deletionssrc/glsl/nir/.gitignore
- src/glsl/nir/nir_constant_expressions.h 31 additions, 0 deletionssrc/glsl/nir/nir_constant_expressions.h
- src/glsl/nir/nir_constant_expressions.py 352 additions, 0 deletionssrc/glsl/nir/nir_constant_expressions.py
- src/glsl/nir/nir_opcodes.py 396 additions, 184 deletionssrc/glsl/nir/nir_opcodes.py
Loading
Please register or sign in to comment