[PATCH 1/3] [ARC] Add arithmetic and logic instructions for nps
Graham Markall
graham.markall@embecosm.com
Tue Jun 14 08:57:00 GMT 2016
>> +#define
>> MAKE_1BASED_INSERT_EXTRACT_FUNCS(NAME,SHIFT,UPPER,BITS) \
>> +static unsigned \
>> +insert_nps_##NAME (unsigned insn ATTRIBUTE_UNUSED, \
>> + int value ATTRIBUTE_UNUSED, \
>> + const char **errmsg ATTRIBUTE_UNUSED) \
>> +{ \
>> + if (value < 0 || value > UPPER) \
>> + *errmsg = _("Value must be in the range 0 to " #UPPER); \
>> + if (value == UPPER) \
>> + value = 0; \
>> + return insn | (value << SHIFT); \
>> +} \
>> + \
>> +static int \
>> +extract_nps_##NAME (unsigned insn ATTRIBUTE_UNUSED, \
>> + bfd_boolean * invalid ATTRIBUTE_UNUSED) \
>> +{ \
>> + int value = (insn >> SHIFT) & ((1 << BITS) - 1); \
>> + if (value == 0) \
>> + value = UPPER; \
>> + return value; \
>> +}
>
> I am not sure if you need those two functions as the default behavior for insert and extract behaves similarly.
Many thanks for looking at this so quickly.
I think that these functions have slightly different behaviour from the
default case - I have used these for operands which encode e.g. the
values 1-8 in 3 bits, where the values 1-7 are represented in the usual
way, and the value 8 is encoded as 0. If I understand it correctly, the
default behaviour will encode the values 0 to 7 literally. Does my
understanding seem correct?
This has however drawn my attention to the fact that there is an error
in the insert function's check - the condition should have been
if (value < 1 || value > UPPER)
so I will provide a revised patch shortly.
Many thanks,
Graham.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://sourceware.org/pipermail/binutils/attachments/20160614/8dca58ce/attachment.sig>
More information about the Binutils
mailing list