summaryrefslogtreecommitdiffstats
path: root/src/glsl/ir.h
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2014-04-06 18:34:59 -0700
committerKenneth Graunke <[email protected]>2014-04-08 00:01:53 -0700
commit7540be22d16bce68163a6478fa2d7a5aa1d9844d (patch)
tree7fef4ad7c96b68bf1acd7451514151cf905f5f83 /src/glsl/ir.h
parentbd69f65f90ecfa45e43a72504d277cb39f00e1c1 (diff)
glsl: Make is_16bit_constant from i965 an ir_constant method.
The i965 MUL instruction doesn't natively support 32-bit by 32-bit integer multiplication; additional instructions (MACH/MOV) are required. However, we can avoid those if we know one of the operands can be represented in 16 bits or less. The vector backend's is_16bit_constant static helper function checks for this. We want to be able to use it in the scalar backend as well, which means moving the function to a more generally-usable location. Since it isn't i965 specific, I decided to make it an ir_constant method, in case it ends up being useful to other people as well. v2: Rename from is_16bit_integer_constant to is_uint16_constant, as suggested by Ilia Mirkin. Update comments to clarify that it does apply to both int and uint types, as long as the value is non-negative and fits in 16-bits. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src/glsl/ir.h')
-rw-r--r--src/glsl/ir.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index ee276d2be2d..6c7c60a27d9 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -265,6 +265,13 @@ public:
*/
virtual bool is_basis() const;
+ /**
+ * Determine if an r-value is an unsigned integer constant which can be
+ * stored in 16 bits.
+ *
+ * \sa ir_constant::is_uint16_constant.
+ */
+ virtual bool is_uint16_constant() const { return false; }
/**
* Return a generic value of error_type.
@@ -2165,6 +2172,14 @@ public:
virtual bool is_basis() const;
/**
+ * Return true for constants that could be stored as 16-bit unsigned values.
+ *
+ * Note that this will return true even for signed integer ir_constants, as
+ * long as the value is non-negative and fits in 16-bits.
+ */
+ virtual bool is_uint16_constant() const;
+
+ /**
* Value of the constant.
*
* The field used to back the values supplied by the constant is determined