[Mesa-dev] [PATCH 3/9] glsl: Make is_16bit_constant from i965 an ir_constant method.

Kenneth Graunke kenneth at whitecape.org
Mon Apr 7 23:56:17 PDT 2014


On 04/07/2014 05:41 AM, Ilia Mirkin wrote:
> On Mon, Apr 7, 2014 at 2:49 AM, Kenneth Graunke <kenneth at whitecape.org> wrote:
>> 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.
>>
>> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
>> ---
>>  src/glsl/ir.cpp                                |  9 +++++++++
>>  src/glsl/ir.h                                  | 11 +++++++++++
>>  src/mesa/drivers/dri/i965/brw_vec4_visitor.cpp | 18 ++----------------
>>  3 files changed, 22 insertions(+), 16 deletions(-)
>>
>> diff --git a/src/glsl/ir.cpp b/src/glsl/ir.cpp
>> index a41eddf..07c0a9b 100644
>> --- a/src/glsl/ir.cpp
>> +++ b/src/glsl/ir.cpp
>> @@ -1223,6 +1223,15 @@ ir_constant::is_basis() const
>>     return ones == 1;
>>  }
>>
>> +bool
>> +ir_constant::is_16bit_integer_constant() const
> 
> Perhaps make this is_uint16_constant? Otherwise one might assume based
> on the name that it would return true for a value like -1.

I like that.  I've renamed it to is_uint16_constant and updated the
comments to clarify that it can return true for signed values, as long
as those values are non-negative and fit in 16-bits.

--Ken


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140407/ca5a2432/attachment.sig>


More information about the mesa-dev mailing list