From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id CC34E3858419 for ; Mon, 11 Jul 2022 14:29:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CC34E3858419 Received: by mail-ej1-x636.google.com with SMTP id sz17so9123686ejc.9 for ; Mon, 11 Jul 2022 07:29:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vFlKXMpmL5L2h0Brxwx4YZUs9tmeR4OrLknzecKRU6M=; b=1EQWtu2GaOBzVcrc4U2FUuH+0fa+4vUfMQ9vKw8j8BYSCBu9jIvxn5YGNzYCgi5A1U 1vtwZyjiF56e9psL4Q6Mq24IFDvBCXogNOfbx9LRlRM4k8ms0Dzle5znSL+eSLg9XryN t4rgQ6/Rz0tNt5gy1JR43VvopWbsKtIq3wxkhRy9SFpSShb779p/SPq2g65djmnsdasJ 23O9LtNG38NnWnyOxNOvJ/z74zjIqtOs72ikdSBN7TitmRaLMnoZgWhIgUcnhL3cYgpb +FGtKYSF4tAC7/X5UjrASiljDHN0/DBVb96BG+dyatx3Yi3cNYDBk9JV/9cqPGCoXvUA a/6w== X-Gm-Message-State: AJIora85oxNX3TanSJQHqL72gD/gVQ9w0wG+awb5Py5Y6cHQfBNk3dRp FWQYyrJktsDqNUD2VgbZQ1fuuK7McHHPuz7/i9w0dKMdhK0= X-Google-Smtp-Source: AGRyM1syj57nlLHuTauZ3OlPtSNE+C3d9EjnFVr5PZ8TfBoV9wDEX4/EWpNmBUUdGgFpAieTU6EEctpSqu6qS3Mceu4= X-Received: by 2002:a17:907:28ca:b0:72b:110a:b34e with SMTP id en10-20020a17090728ca00b0072b110ab34emr18804217ejc.113.1657549751551; Mon, 11 Jul 2022 07:29:11 -0700 (PDT) MIME-Version: 1.0 References: <2A99A5EA-C863-465C-A983-244A48D2E3C3@gmail.com> In-Reply-To: From: Dmitry Selyutin Date: Mon, 11 Jul 2022 17:28:35 +0300 Message-ID: Subject: Re: Teaching expression() to treat some operations specially To: Alan Modra Cc: lkcl , Binutils Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2022 14:29:14 -0000 On Mon, Jul 11, 2022 at 6:08 AM Alan Modra wrote: > On Mon, Jul 11, 2022 at 03:33:55AM +0100, lkcl wrote: > > please read then use contents of register r3 as the predicate mask, invert all its bits before passing it on". > > OK, then you'll want ppc_parse_name to continue to create O_register > values. There is another difficulty with statements like "r3" or "~r3" in macros. As such, PPC does not support register names in macros, at all. .set REG, %r0 extsw REG, 2 This code leads to "junk at end of line, first unrecognized character is `r'" error. Also, using "r0" instead of "%r0" also fails due to unknown relocation. >From the code around it looks that we could define a simple md_operand() routine. This _almost_ works, but now I hit checks at tc-ppc.c:3484. I think we're being bitten by some discrepancies between these checks and symbol expansion. Alan, could you, please, help me with understanding these checks? I understand it's been 5 years ago... P.S. I've inlined the patch for a simple md_operand routine here. diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index ac61cd8f12..c04bde0d00 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -3275,8 +3275,14 @@ parse_tls_arg (char **str, const expressionS *exp, struct ppc_fixup *tls_fix) } #endif -/* This routine is called for each instruction to be assembled. */ +void +md_operand (expressionS *exp) +{ + if (!register_name (exp)) + expression (exp); +} +/* This routine is called for each instruction to be assembled. */ void md_assemble (char *str) { diff --git a/gas/config/tc-ppc.h b/gas/config/tc-ppc.h index ed06a29638..a65e51c875 100644 --- a/gas/config/tc-ppc.h +++ b/gas/config/tc-ppc.h @@ -328,8 +328,6 @@ extern int ppc_parse_name (const char *, struct expressionS *); #define md_optimize_expr(left, op, right) ppc_optimize_expr (left, op, right) extern int ppc_optimize_expr (expressionS *, operatorT, expressionS *); -#define md_operand(x) - #define md_cleanup() ppc_cleanup () extern void ppc_cleanup (void); -- Best regards, Dmitry Selyutin