From: Will Deacon <will.deacon@arm.com>
To: Zi Shen Lim <zlim.lnx@gmail.com>
Cc: Catalin Marinas <Catalin.Marinas@arm.com>,
Jiang Liu <liuj97@gmail.com>,
AKASHI Takahiro <takahiro.akashi@linaro.org>,
"David S. Miller" <davem@davemloft.net>,
Daniel Borkmann <dborkman@redhat.com>,
Alexei Starovoitov <ast@plumgrid.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH RFCv3 08/14] arm64: introduce aarch64_insn_gen_movewide()
Date: Thu, 17 Jul 2014 10:41:02 +0100 [thread overview]
Message-ID: <20140717094101.GD21153@arm.com> (raw)
In-Reply-To: <20140716220422.GB18109@gup76>
On Wed, Jul 16, 2014 at 11:04:22PM +0100, Zi Shen Lim wrote:
> On Wed, Jul 16, 2014 at 05:17:15PM +0100, Will Deacon wrote:
> > On Tue, Jul 15, 2014 at 07:25:06AM +0100, Zi Shen Lim wrote:
> > > Introduce function to generate move wide (immediate) instructions.
> >
> > [...]
> >
> > > +u32 aarch64_insn_gen_movewide(enum aarch64_insn_register dst,
> > > + int imm, int shift,
> > > + enum aarch64_insn_variant variant,
> > > + enum aarch64_insn_movewide_type type)
> > > +{
> > > + u32 insn;
> > > +
> > > + switch (type) {
> > > + case AARCH64_INSN_MOVEWIDE_ZERO:
> > > + insn = aarch64_insn_get_movz_value();
> > > + break;
> > > + case AARCH64_INSN_MOVEWIDE_KEEP:
> > > + insn = aarch64_insn_get_movk_value();
> > > + break;
> > > + case AARCH64_INSN_MOVEWIDE_INVERSE:
> > > + insn = aarch64_insn_get_movn_value();
> > > + break;
> > > + default:
> > > + BUG_ON(1);
> > > + }
> > > +
> > > + BUG_ON(imm < 0 || imm > 65535);
> >
> > Do this check with masking instead?
>
> Ok, if you prefer, I can change it to:
>
> BUG_ON(imm & ~GENMASK(15, 0));
Sure, that or use a named constant for the upper-bound (SZ_64K - 1).
> > > + switch (variant) {
> > > + case AARCH64_INSN_VARIANT_32BIT:
> > > + BUG_ON(shift != 0 && shift != 16);
> > > + break;
> > > + case AARCH64_INSN_VARIANT_64BIT:
> > > + insn |= BIT(31);
> > > + BUG_ON(shift != 0 && shift != 16 && shift != 32 &&
> > > + shift != 48);
> >
> > Would be neater as a nested switch, perhaps? If you reorder the
> > outer-switch, you could probably fall-through too and combine the shift
> > checks.
>
> Not sure I picture what you had in mind... I couldn't come up with a
> neater version with the properties you described.
>
> The alternative I had was using masks instead of integer values, but
> one could argue that while neater, it could also be harder to read:
>
> switch (variant) {
> case AARCH64_INSN_VARIANT_32BIT:
> BUG_ON(shift & ~BIT(4));
> break;
> case AARCH64_INSN_VARIANT_64BIT:
> insn |= BIT(31);
> BUG_ON(shift & ~GENMASK(5, 4));
> ...
I was thinking of using nested switches, but that doesn't fall out like I
hoped. How about:
switch (variant) {
case AARCH64_INSN_VARIANT_64BIT:
BUG_ON(shift != 32 && shift != 48);
case AARCH64_INSN_VARIANT_32BIT:
BUG_ON(shift != 0 && shift != 16);
};
?
Will
next prev parent reply other threads:[~2014-07-17 9:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-15 6:24 [PATCH RFCv3 00/14] arm64: eBPF JIT compiler Zi Shen Lim
2014-07-15 6:24 ` [PATCH RFCv3 01/14] arm64: introduce aarch64_insn_gen_comp_branch_imm() Zi Shen Lim
2014-07-16 16:04 ` Will Deacon
2014-07-16 21:19 ` Zi Shen Lim
2014-07-17 9:19 ` Will Deacon
2014-07-17 15:59 ` Alexei Starovoitov
2014-07-17 17:25 ` Will Deacon
2014-07-18 5:44 ` Z Lim
2014-07-15 6:25 ` [PATCH RFCv3 02/14] arm64: introduce aarch64_insn_gen_branch_reg() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 03/14] arm64: introduce aarch64_insn_gen_cond_branch_imm() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 04/14] arm64: introduce aarch64_insn_gen_load_store_reg() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 05/14] arm64: introduce aarch64_insn_gen_load_store_pair() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 06/14] arm64: introduce aarch64_insn_gen_add_sub_imm() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 07/14] arm64: introduce aarch64_insn_gen_bitfield() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 08/14] arm64: introduce aarch64_insn_gen_movewide() Zi Shen Lim
2014-07-16 16:17 ` Will Deacon
2014-07-16 16:25 ` David Laight
2014-07-16 22:04 ` Zi Shen Lim
2014-07-17 9:41 ` Will Deacon [this message]
2014-07-17 9:51 ` David Laight
2014-07-18 5:47 ` Z Lim
2014-07-18 8:43 ` Will Deacon
2014-07-15 6:25 ` [PATCH RFCv3 09/14] arm64: introduce aarch64_insn_gen_add_sub_shifted_reg() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 10/14] arm64: introduce aarch64_insn_gen_data1() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 11/14] arm64: introduce aarch64_insn_gen_data2() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 12/14] arm64: introduce aarch64_insn_gen_data3() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 13/14] arm64: introduce aarch64_insn_gen_logical_shifted_reg() Zi Shen Lim
2014-07-15 6:25 ` [PATCH RFCv3 14/14] arm64: eBPF JIT compiler Zi Shen Lim
2014-07-16 10:41 ` [PATCH RFCv3 00/14] " Will Deacon
2014-07-16 16:21 ` Will Deacon
2014-07-16 22:18 ` Zi Shen Lim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140717094101.GD21153@arm.com \
--to=will.deacon@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=ast@plumgrid.com \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liuj97@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=takahiro.akashi@linaro.org \
--cc=zlim.lnx@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).