This is the mail archive of the
mailing list for the binutils project.
RE: [PATCH 1/3] [ARC] Add arithmetic and logic instructions for nps
- From: Claudiu Zissulescu <Claudiu dot Zissulescu at synopsys dot com>
- To: Graham Markall <graham dot markall at embecosm dot com>, "binutils at sourceware dot org" <binutils at sourceware dot org>
- Date: Tue, 14 Jun 2016 09:57:03 +0000
- Subject: RE: [PATCH 1/3] [ARC] Add arithmetic and logic instructions for nps
- Authentication-results: sourceware.org; auth=none
- References: <cover dot 1465827288 dot git dot graham dot markall at embecosm dot com> <2c59857dfcfc0b31c69d0f3e2a91ca1ad6720a3b dot 1465827288 dot git dot graham dot markall at embecosm dot com> <098ECE41A0A6114BB2A07F1EC238DE89661AC830 at de02wembxa dot internal dot synopsys dot com> <69dfe050-8f33-6dd8-632e-2f13ef737136 at embecosm dot com>
> 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?
In include/opcode/arc.h for arc_operand we can find:
If it is NULL, execute
i |= (op & ((1 << o->bits) - 1)) << o->shift;
which looks identical like your proposed insert function.
And for extract we have:
If it is NULL, compute
op = ((i) >> o->shift) & ((1 << o->bits) - 1);
if ((o->flags & ARC_OPERAND_SIGNED) != 0
&& (op & (1 << (o->bits - 1))) != 0)
op -= 1 << o->bits;
which looks like your extract function as described by MAKE_1BASED_INSERT_EXTRACT_FUNCS macro.
The range should be checked also based on the number of bits and signees of the operand.
In general, the insert and the extract functions should be used as an exception from the rule.