From patchwork Fri Jun 28 13:22:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 93020 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7A9D53826DD6 for ; Fri, 28 Jun 2024 13:22:45 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 5324E382FADF for ; Fri, 28 Jun 2024 13:22:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5324E382FADF Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 5324E382FADF Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::229 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719580933; cv=none; b=lD5/i6GEecLn7xdJ5yWMhRRAuYjWTD+uHOIFFZ+ezW6ZoEJubt4ZNQNsT+foi/ora35v2nsVwwB6FyJuRkQaJvMeSzxYcoQo9tX3TjgJqtB7h73g+3H60Mc8qxQLngurSK/+K6rhOTqLvL98j3kw87NBY/W57nzfRYGxrTvIcTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719580933; c=relaxed/simple; bh=HTD/0k9FXQ4TCpjd7kJonN5YSv/90xqKoZuFuqQIuDU=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=PKBRYEE0tkfWCNqKN1w5zfBS5AQn9xzp5plZdlWOnhURxMraDnFvDsSucn6N/5DXh6k3uKW0AORBj1e1t3/pRmTbHhYin4SJ/GdQmpk2G5ZV17JE3NKmFJXbS8uGBO2Yj/ABUXoMsMffGvonEWxRUWH4H+bCj5jEX8k2kd+3fpM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-2ec50d4e47bso6061841fa.2 for ; Fri, 28 Jun 2024 06:22:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1719580929; x=1720185729; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=ZWiHTfjiTXHo2q2/jE1R9GQT7rlQPzBOaICfwRVY5To=; b=KA4TQ+KtDcAj7VZOZ4C8OyTUjHXU1KYSLeMVrg5ivhJ1qeXnuWCdvXXY5zaP/RF/lt SAbTQY/ldv7AO56i4qjbiCcof9J2quYN4W8x6yxPtPY49XsuJQZHztlgtbKwIs9+owoW doo7DFlIQxxusZ8PYwIeLXfs1olafWvoKB/sKts+Yxa7A7txCIU2nEMhAmXGQH31kSNt 0rNEOZ+AJ9vWZyjjt89TX7SxOiLjk+lT525PMgzedY49fhf0wIv/Hau32MTfh2SC7Nfj 0Tfw/GgyfXTy7G/6l9zltVkpxZC8VOKO1Leb7EgbLix3KVuScuZn5ZWO6ppH6gE/5jlI ztfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719580929; x=1720185729; h=content-transfer-encoding:in-reply-to:autocrypt:content-language :references:cc:to:from:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ZWiHTfjiTXHo2q2/jE1R9GQT7rlQPzBOaICfwRVY5To=; b=um6G+vLWXjJzemCQnhT4hFPkEnensfDeUPv1cq73y1DRJPlq9gYRsR/LNpytyouEOi tsVUrp2lGI2OaYsV6bhLohXrFmM5ZOAOpTgbIg+yX6AUQmhPzYfCOaWLMVWyhHiIrlKH +OkIhd+oR5lpLxBAEUTINie6HY33hCcnVzqwE9XAjDMuadkBHpajPyeIQyGfaJV7rg8t SBA/oMaHLj3caHVyYI/afZkXkNYPjvq8V6B563yFeVtoYq+6UUgBvbH+pnlqtSPyACaC OAT8vdzAi4mu7mMyQiGU6Md/AbCbQfo4A9Gi8rXKybeLJhG1tYHd9ILZN2eecxbMg/Cw imww== X-Gm-Message-State: AOJu0YxXqAYMt+gPAeQEmzZLUB6wzq83h9tJvAv6ZwLK+U8RRQ9D0t+M zYiURYxCXimAHinJpFW5l2hQpxh4B7ZrVvzaZy6cNB+pmjI05aiGZSbqwE38MX3fdpEzMvaBt/c = X-Google-Smtp-Source: AGHT+IEGYuPu073bJFb4xkOyhDfeCvkiDu72/hCEZKtp81nEKpDZw5rdeYcYOQ/emiziFvfjnhVSdw== X-Received: by 2002:a2e:6808:0:b0:2ec:588d:7ecc with SMTP id 38308e7fff4ca-2ec5b27a875mr104727491fa.12.1719580928688; Fri, 28 Jun 2024 06:22:08 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fad4933a80sm2826765ad.289.2024.06.28.06.22.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Jun 2024 06:22:08 -0700 (PDT) Message-ID: <1e5129fb-d94a-4b0a-97d6-c5ec1771bb7b@suse.com> Date: Fri, 28 Jun 2024 15:22:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 07/11] gas: consistently drop trailing whitespace when scrubbing From: Jan Beulich To: Binutils Cc: Chenghua Xu , "Maciej W. Rozycki" References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMN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LujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: X-Spam-Status: No, score=-3024.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org From especially the checks for the two separator forms it appears to follow that the construct being touched is about trailing whitespace. In such a case, considering that for many targets ordinary and line comment chars overlap, take into account that line comment chars override ordinary ones in lex[] (logic elsewhere in do_scrub_chars() actually depends on that ordering, and also accounts for this overriding). Plus of course IS_NEWLINE() would better also be consulted. Note also that the DOUBLESLASH_LINE_COMMENTS change should generally have no effect just yet; it's a prereq for a later change but better fits here. Leave respective comments as well, and update documentation to correct which comment form is actually replaced by a single blank (i.e. neither the ones starting with what {,tc_}comment_chars[] has nor the ones starting with what line_comment_chars[] has). --- In the MIPS testsuite adjustments I wasn't sure how exactly to make the necessary changes: I could also have zapped the two blanks each, but then I wondered why they were part of the expectations in the first place. Why are there both comment_chars[] and tc_comment_chars[]? The former is per-arch anyway, so why would there be a need for an arch override? Is this perhaps merely a historical leftover, which could be eliminated? --- a/gas/app.c +++ b/gas/app.c @@ -87,6 +87,7 @@ static char last_char; #define IS_PARALLEL_SEPARATOR(c) (lex[c] == LEX_IS_PARALLEL_SEPARATOR) #define IS_COMMENT(c) (lex[c] == LEX_IS_COMMENT_START) #define IS_LINE_COMMENT(c) (lex[c] == LEX_IS_LINE_COMMENT_START) +#define IS_TWOCHAR_COMMENT_1ST(c) (lex[c] == LEX_IS_TWOCHAR_COMMENT_1ST) #define IS_NEWLINE(c) (lex[c] == LEX_IS_NEWLINE) static char lex[256] = { @@ -149,6 +150,9 @@ do_scrub_begin (int m68k_mri ATTRIBUTE_U for (p = tc_comment_chars; *p; p++) lex[(unsigned char) *p] = LEX_IS_COMMENT_START; + /* While counter intuitive to have more special purpose line comment chars + override more general purpose ordinary ones, logic in do_scrub_chars() + depends on this ordering. */ for (p = line_comment_chars; *p; p++) lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START; @@ -888,7 +892,12 @@ do_scrub_chars (size_t (*get) (char *, s } } #endif + + /* Prune trailing whitespace. */ if (IS_COMMENT (ch) + || (IS_LINE_COMMENT (ch) + && (state < 1 || strchr (tc_comment_chars, ch))) + || IS_NEWLINE (ch) || IS_LINE_SEPARATOR (ch) || IS_PARALLEL_SEPARATOR (ch)) { @@ -901,6 +910,16 @@ do_scrub_chars (size_t (*get) (char *, s } goto recycle; } +#ifdef DOUBLESLASH_LINE_COMMENTS + if (IS_TWOCHAR_COMMENT_1ST (ch)) + { + ch2 = GET (); + if (ch2 != EOF) + UNGET (ch2); + if (ch2 == '/') + goto recycle; + } +#endif /* If we're in state 2 or 11, we've seen a non-white character followed by whitespace. If the next character --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -2987,11 +2987,11 @@ as exactly one space. @section Comments @cindex comments -There are two ways of rendering comments to @command{@value{AS}}. In both -cases the comment is equivalent to one space. +There are two ways of rendering comments to @command{@value{AS}}. Anything from @samp{/*} through the next @samp{*/} is a comment. -This means you may not nest these comments. +This means you may not nest these comments. Such a comment is equivalent to +one space, plus bumping the line counter accordingly. @smallexample /* --- a/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16-32@mips16-insn-e.l @@ -25,7 +25,7 @@ .*:50: Warning: extended operand requested but not required .*:51: Error: opcode not supported on this processor: mips1 \(mips1\) `restore\.e 128' .*:52: Error: opcode not supported on this processor: mips1 \(mips1\) `save\.e 128' -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ?' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -71,7 +71,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Error: opcode not supported on this processor: mips1 \(mips1\) `dsrl\.e \$16,8' -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ?' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' --- a/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16-64@mips16-insn-e.l @@ -25,7 +25,7 @@ .*:50: Warning: extended operand requested but not required .*:51: Error: opcode not supported on this processor: mips3 \(mips3\) `restore\.e 128' .*:52: Error: opcode not supported on this processor: mips3 \(mips3\) `save\.e 128' -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ?' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -71,7 +71,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Warning: extended operand requested but not required -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ?' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' --- a/gas/testsuite/gas/mips/mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16-insn-e.l @@ -23,7 +23,7 @@ .*:48: Warning: extended operand requested but not required .*:49: Warning: extended operand requested but not required .*:50: Warning: extended operand requested but not required -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ?' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -69,7 +69,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Warning: extended operand requested but not required -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ?' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' --- a/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16e-32@mips16-insn-e.l @@ -23,7 +23,7 @@ .*:48: Warning: extended operand requested but not required .*:49: Warning: extended operand requested but not required .*:50: Warning: extended operand requested but not required -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ?' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -69,7 +69,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Error: opcode not supported on this processor: mips32 \(mips32\) `dsrl\.e \$16,8' -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ?' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' --- a/gas/testsuite/gas/mips/mips16e2-32@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16e2-32@mips16-insn-e.l @@ -23,7 +23,7 @@ .*:48: Warning: extended operand requested but not required .*:49: Warning: extended operand requested but not required .*:50: Warning: extended operand requested but not required -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ?' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -69,7 +69,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Error: opcode not supported on this processor: mips32r2 \(mips32r2\) `dsrl\.e \$16,8' -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ?' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e' --- a/gas/testsuite/gas/mips/mips16e2-interaptiv-mr2@mips16-insn-e.l +++ b/gas/testsuite/gas/mips/mips16e2-interaptiv-mr2@mips16-insn-e.l @@ -23,7 +23,7 @@ .*:48: Warning: extended operand requested but not required .*:49: Warning: extended operand requested but not required .*:50: Warning: extended operand requested but not required -.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ' +.*:53: Error: unrecognized extended version of MIPS16 opcode `nop\.e ?' .*:54: Error: unrecognized extended version of MIPS16 opcode `move\.e \$0,\$16' .*:55: Error: unrecognized extended version of MIPS16 opcode `move\.e \$16,\$0' .*:57: Warning: extended operand requested but not required @@ -69,7 +69,7 @@ .*:123: Error: unrecognized extended version of MIPS16 opcode `srav\.e \$16,\$16' .*:124: Error: operand 2 must be an immediate expression `sra\.e \$16,\$16' .*:125: Error: opcode not supported on this processor: interaptiv-mr2 \(mips32r3\) `dsrl\.e \$16,8' -.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ' +.*:126: Error: unrecognized extended version of MIPS16 opcode `entry\.e ?' .*:127: Error: unrecognized extended version of MIPS16 opcode `entry\.e \$31' .*:128: Error: unrecognized extended version of MIPS16 opcode `exit\.e \$f0' .*:129: Error: unrecognized extended version of MIPS16 opcode `exit\.e'