From 89285e4d47a65e52547180dca46ecfd81b2996e9 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 23 Jan 2015 13:38:46 -0800 Subject: 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 - Use mako to generate one function per opcode instead of doing piles of string splicing v4 Jason Ekstrand - 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 Reviewed-by: Connor Abbott --- src/glsl/nir/.gitignore | 1 + 1 file changed, 1 insertion(+) (limited to 'src/glsl/nir/.gitignore') diff --git a/src/glsl/nir/.gitignore b/src/glsl/nir/.gitignore index 4c28193612f..261f64f7188 100644 --- a/src/glsl/nir/.gitignore +++ b/src/glsl/nir/.gitignore @@ -1,3 +1,4 @@ nir_opt_algebraic.c nir_opcodes.c nir_opcodes.h +nir_constant_expressions.c -- cgit v1.2.3