summaryrefslogtreecommitdiffstats
path: root/src/glsl/nir/nir.h
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2014-12-16 12:22:01 -0800
committerJason Ekstrand <[email protected]>2015-01-15 07:20:22 -0800
commit46f3e1ab504f016ab900c045f165a8376cf3fc0c (patch)
treecb1afd74eeed6f431d061e9edf629df8d727b89c /src/glsl/nir/nir.h
parent2c7da78805175f36879111306ac37c12d33bf65b (diff)
nir/opcodes: Add algebraic properties metadata
This commit adds some algebraic properties to the metadata of each opcode in NIR. In particular, you now know, just from the metadata, if a given opcode is commutative or associative. This will be useful for algebraic transformation passes that want to be able to match a + b as well as b + a in one go. v2: Make algebraic properties all caps. This was more consistent with the intrinsics flags and seems better for flags in general. Also, the enums are now declared with (1 << n) rather then hex values. v3: fmin and fmax technically aren't commutative or associative. Things get funny when one of the arguments is a NaN. Reviewed-by: Connor Abbott <[email protected]>
Diffstat (limited to 'src/glsl/nir/nir.h')
-rw-r--r--src/glsl/nir/nir.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 8ff4087c240..61cdfdf8b1a 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -534,7 +534,7 @@ typedef struct {
} nir_alu_dest;
#define OPCODE(name, num_inputs, per_component, output_size, output_type, \
- input_sizes, input_types) \
+ input_sizes, input_types, algebraic_props) \
nir_op_##name,
#define LAST_OPCODE(name) nir_last_opcode = nir_op_##name,
@@ -554,6 +554,11 @@ typedef enum {
nir_type_bool
} nir_alu_type;
+typedef enum {
+ NIR_OP_IS_COMMUTATIVE = (1 << 0),
+ NIR_OP_IS_ASSOCIATIVE = (1 << 1),
+} nir_op_algebraic_property;
+
typedef struct {
const char *name;
@@ -599,6 +604,8 @@ typedef struct {
* two, and absolute value is only allowed on float type inputs.
*/
nir_alu_type input_types[4];
+
+ nir_op_algebraic_property algebraic_properties;
} nir_op_info;
extern const nir_op_info nir_op_infos[nir_num_opcodes];