From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: ** X-Spam-Status: No, score=2.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56388C433ED for ; Wed, 28 Apr 2021 13:02:11 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A584613B8 for ; Wed, 28 Apr 2021 13:02:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A584613B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:60544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbjpO-0005kY-UI for qemu-devel@archiver.kernel.org; Wed, 28 Apr 2021 09:02:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbhcu-0000oO-LM for qemu-devel@nongnu.org; Wed, 28 Apr 2021 06:41:04 -0400 Received: from mail-yb1-xb31.google.com ([2607:f8b0:4864:20::b31]:36642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lbhcs-0001JL-QW for qemu-devel@nongnu.org; Wed, 28 Apr 2021 06:41:04 -0400 Received: by mail-yb1-xb31.google.com with SMTP id t94so20019504ybi.3 for ; Wed, 28 Apr 2021 03:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ORjwMFQcKcBoCagVHz+qegsxCqDGel6Rd1J1Urh9NYE=; b=ONfMcLrHIonOQPknP0Ls4nnuCFlkIPyzlwlC9AhJp7KeVWa2nz6RtZqkkyfJtMMV5O rmEn2icH9R5YgU/j+LYRP3H2xBzViHre+KljIjqzqufL5lx8cYKvVZL1bWHResnw3q0o jsWgHhr50I10WOze2X9Pq4NzW1nFIiW54lHFTrV8ELxwdSWmXNxqUpbwdKnuTxDBNnc1 mPxeAU8tZhZJFQd+CRiiW2JvOYRY7tIv0DUthlW0OaZlQTumoYVHL6R7EZGXitzAi4uX sOTihUGidBSbbQWkwgly5s1aEyl7g7cogtZtoSmSbkBF8ZUiG5j4eVW/W2f5pBqKsB2Z vm4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ORjwMFQcKcBoCagVHz+qegsxCqDGel6Rd1J1Urh9NYE=; b=HqQ7Wn1ed7Rr9kcPDFJG274bW8M9g/bi6OrfqM+Fio9wtzLmjPOvfIdmvhIRDTd2M9 OQEfjQ84E/Ge9yCTuD1RbNMAY6Jsa2jHQcfQeJQkHsiw4JwVoyY46qORQy289gJUQUzS ditvCx1HUUl76nhTwFLFUTwXS81Aqej69FcL4+LKCYSGVlqujeNZN8UDl4cHUk2+hRoI uvVbuC0Um9Vk5TbhDBKF1L++AX411EwAn2VMzE838lc2r4DkGxrBisnpx15Thv5PNB3h 27DbnHVvJ8k7BH9FcYD+6DwB1gB1zoNi2SQ5pbYFnnHTbVCAe/TT8xGYTdpa8EYld+YN cX6A== X-Gm-Message-State: AOAM531l9QrbK8e490RUfLc/8EjM6YQKAVMZ16qX2aTv2ypRI4BjAJPM swcnY1eUXU5+wx85is4IxxUrNWl2bMkL+k3o28o= X-Google-Smtp-Source: ABdhPJxl0kvUPv7ejPEoCyoGiMBHHQFWo3GHf97NTBsKZiAo1tpjSQ+gx7GBoKgP0t6M5NFvFa9kEzch3fGWd38Pddg= X-Received: by 2002:a05:6902:703:: with SMTP id k3mr35206032ybt.382.1619606457981; Wed, 28 Apr 2021 03:40:57 -0700 (PDT) MIME-Version: 1.0 References: <20210330143750.3037824-1-ale.qemu@rev.ng> <20210330143750.3037824-10-ale.qemu@rev.ng> In-Reply-To: From: Paolo Montesel Date: Wed, 28 Apr 2021 12:40:47 +0200 Message-ID: Subject: Re: [PATCH v3 09/12] target/hexagon: import lexer for idef-parser To: Taylor Simpson Content-Type: multipart/alternative; boundary="0000000000009a9daf05c106033f" Received-SPF: pass client-ip=2607:f8b0:4864:20::b31; envelope-from=paolo.montesel.revng@gmail.com; helo=mail-yb1-xb31.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 28 Apr 2021 08:57:40 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alessandro Di Federico , Brian Cain , "richard.henderson@linaro.org" , "qemu-devel@nongnu.org" , Alessandro Di Federico , "nizzo@rev.ng" , "philmd@redhat.com" Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000009a9daf05c106033f Content-Type: text/plain; charset="UTF-8" > > > +"fLSBNEW(P"{LOWER_PRE}"N)" { yylval->rvalue.type = PREDICATE; > > + yylval->rvalue.pre.id = yytext[9]; > > + yylval->rvalue.bit_width = 32; > > + yylval->rvalue.is_dotnew = true; > > + return PRE; } > > +"fLSBNEW0" { yylval->rvalue.type = PREDICATE; > > + yylval->rvalue.pre.id = '0'; > > + yylval->rvalue.bit_width = 32; > > + yylval->rvalue.is_dotnew = true; > > + return PRE; } > > +"fLSBNEW1" { yylval->rvalue.type = PREDICATE; > > + yylval->rvalue.pre.id = '1'; > > + yylval->rvalue.bit_width = 32; > > + yylval->rvalue.is_dotnew = true; > > + return PRE; } > > +"fLSBNEW1NOT" { yylval->rvalue.type = PREDICATE; > > + yylval->rvalue.pre.id = '1'; > > + yylval->rvalue.bit_width = 32; > > + yylval->rvalue.is_dotnew = true; > > + return PRE; } > > These represent the least significant bit of the operand. Perhaps you > should set the bit_width to 1? Or do tcg_gen_andi_tl(..., 1)? > What I ended up doing is reworking how LSB* are handled. Now there's a special token `LSBNEW` that's implemented as a `tcg_gen_andi` in the parser, and it's used only for `fLSBNEW`. The other cases are expanded in the preprocessing part like this: /* Least significant bit operations */ #define fLSBNEW0 fLSBNEW(P0N) #define fLSBNEW1 fLSBNEW(P1N) #define fLSBOLDNOT(VAL) fGETBIT(0, ~VAL) #define fLSBNEWNOT(PRED) (fLSBNEW(~PRED)) #define fLSBNEW0NOT fLSBNEW(~P0N) #define fLSBNEW1NOT fLSBNEW(~P1N) Let me know what you think. ~Paolo --0000000000009a9daf05c106033f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> +"fLSBNEW(P"{LOWER_PRE}"N)" { yylval->rvalue.ty= pe =3D PREDICATE;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.pre.id =3D yytext[9];
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.bit_width =3D 32;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.is_dotnew =3D true;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0return PRE; }
> +"fLSBNEW0"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0{ yylval->rvalue.type =3D PREDICATE;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.pre.id =3D '0';
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.bit_width =3D 32;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.is_dotnew =3D true;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0return PRE; }
> +"fLSBNEW1"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0{ yylval->rvalue.type =3D PREDICATE;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.pre.id =3D '1';
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.bit_width =3D 32;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.is_dotnew =3D true;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0return PRE; }
> +"fLSBNEW1NOT"=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 { yy= lval->rvalue.type =3D PREDICATE;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.pre.id =3D '1';
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.bit_width =3D 32;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0yylval->rvalue.is_dotnew =3D true;
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0return PRE; }

These represent the least significant bit of the operand.=C2=A0 Perhaps you= should set the bit_width to 1?=C2=A0 Or do tcg_gen_andi_tl(..., 1)?

What I ended up doing is reworking how LSB* a= re handled.
Now there's a special token `LSBNEW` that's i= mplemented as a `tcg_gen_andi` in the parser, and it's used only for `f= LSBNEW`.
The other cases are expanded in the preprocessing part l= ike this:

/* Least significant bit operations */#define fLSBNEW0 fLSBNEW(P0N)
#define fLSBNEW1 fLSBNEW(P1N)
#define= fLSBOLDNOT(VAL) fGETBIT(0, ~VAL)
#define fLSBNEWNOT(PRED) (fLSBNEW(~PRE= D))
#define fLSBNEW0NOT fLSBNEW(~P0N)
#define fLSBNEW1NOT fLSBNEW(~P1= N)

Let me know what you think.

~Paolo
--0000000000009a9daf05c106033f--