From patchwork Fri May 17 09:56:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 90364 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 39BDD3849AE3 for ; Fri, 17 May 2024 09:57:31 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id E5D37384CB97 for ; Fri, 17 May 2024 09:56:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E5D37384CB97 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 E5D37384CB97 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::535 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715939818; cv=none; b=rFpWqzmajFi4tqt64WdkrZqYlPnLUgOJSqHXOwFm/V2mI1fWglB4Mm+39D322bSH8WuRuI69g6+sDtVyxrkvnOcRL/x9jooRkb8VYj7ubi5RZUWk6Sk7TJalFIvud6WlSnDfSa/l4GwVygvkWRDEN+mMWKzkI33r6ZieIFgeS7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715939818; c=relaxed/simple; bh=M02lNMuJonjm28dTMXCzH6ECeyRaxHC2jrPU36S6avs=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=KZL2s9SL5hDupHocSaexyUU3s9kLmMSfVqspXQFeqoG6VFBnsF/NBDugROnzRlWnvWlitphyepLjhAk1b7SffETZM0FxIR68fM4/s/7GqWLiU4ZPkQoZ+qSOn1LXaD2C6HGm5kmn8ZVvLuPBB+65p4IpWUJ2E97BiGje7Iwpfg8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-572e48f91e9so4962515a12.0 for ; Fri, 17 May 2024 02:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1715939815; x=1716544615; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=A8StMbnHOu/VAs2snZ3E08Frb8Jhg++zOVuxkensfpQ=; b=JNRvOyIq8TnfYzlBHQqRoV5p6PBAYSNPH1XrDkc9Ccu/qf+SRyLQaqdb1NzCNYNht6 c0yh6f4gvTLvc6R/HALE3ctabNNAlInoKOOdR+qcrrxxcZK6d2LpkDWBeyi+BPlTq2Px RhqKCaEtp7no1vAHN4BOo6J7h8XNOh+080vEpWpADXUkuESifLX7T8XXYBJXvD774ZFS k1KXtl7HjEw2frUjTv8kUkZynIwYbyPPzWJegl7JqdMN5Xl+WzQpuSz/efeBf8wQ3ad6 ARVr4w7cPiuZH/xNzWQjMcC5vHH+1pqu84H32fisqLhN9C9h0z426Q3wfVlD4gTDvQjp jKMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715939815; x=1716544615; h=content-transfer-encoding:in-reply-to:autocrypt:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=A8StMbnHOu/VAs2snZ3E08Frb8Jhg++zOVuxkensfpQ=; b=qZerWy6I6VTDbcjx3YTrgM5+s6mz5oBeA/O0PbBXLGC1RHqnwN+oFKoLAVV0Ur0bKy ubDoDr+9X3zLNr+5n5KCieTHUKwMQSl6MIaZM6oOZg0Fd/WQKjDUnzTdAatjgALMMmK4 ShVxFGXukcteRc+lNHaKti8rHNHENu9lnVy6h3/OoNswWUJrasbTK9x7TEDnBt6QS/Tw K6PFkrM/ch2ycFUvZebXxZTYstJIeVXQdrWsf8aRRU4+UF6hUPOiXCNFbOvRAmGI3PtZ JT7JGAvHD7dgZwDQaY9KO4lRDGXuGgqH/4aQWCwXQHwzZavaEatYoCwjxIOYyZ1FvS1s lubw== X-Gm-Message-State: AOJu0YzIbC78NhupMxsymmFvbUEvRuWHm7v4sKnN1LjanQeyt1GiMknd dfyB7dgih9M0mI7gVjnhl5+729jrGJZYPYdrt6W90ikOSXPel4bAb4T0lYVUdRzHqur22qcZedg = X-Google-Smtp-Source: AGHT+IFPIOcHvEINJYHIrRCnQBSmHQsXGuSLvAFs4hCaZebVWjJ70z2ez14Ux/nbPHlMUraJOdDASw== X-Received: by 2002:a50:8d50:0:b0:572:6ae4:a9ac with SMTP id 4fb4d7f45d1cf-5734d5e35d6mr15912656a12.21.1715939815404; Fri, 17 May 2024 02:56:55 -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 4fb4d7f45d1cf-5733becfb83sm11779679a12.46.2024.05.17.02.56.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 May 2024 02:56:55 -0700 (PDT) Message-ID: <08b4693f-c588-4e72-bff9-909a808c80ea@suse.com> Date: Fri, 17 May 2024 11:56:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 2/2] x86: simplify / consolidate check_{word, long, qword}_reg() Content-Language: en-US From: Jan Beulich To: Binutils Cc: "H.J. Lu" References: <0875913a-e23f-4482-b5a0-1e6796fe42d4@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98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XeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <0875913a-e23f-4482-b5a0-1e6796fe42d4@suse.com> X-Spam-Status: No, score=-3024.9 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 These run after template matching. Therefore operands are already known to match the template in use. With the loop bodies skipping anything not a GPR in the actual operands, there's therefore no need to check the template's operand type for permitting Reg or Accum. At the same time bring the three functions in sync for the "byte" part of the logic, as far as checking the template for other sizes (qword specifically) goes. Plus drop a stale comment from check_qword_reg(), when all three are now behaving the same in this regard. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -9867,10 +9867,9 @@ check_long_reg (void) /* Reject eight bit registers, except where the template requires them. (eg. movzb) */ else if (i.types[op].bitfield.byte - && (i.tm.operand_types[op].bitfield.class == Reg - || i.tm.operand_types[op].bitfield.instance == Accum) && (i.tm.operand_types[op].bitfield.word - || i.tm.operand_types[op].bitfield.dword)) + || i.tm.operand_types[op].bitfield.dword + || i.tm.operand_types[op].bitfield.qword)) { as_bad (_("`%s%s' not allowed with `%s%c'"), register_prefix, @@ -9883,8 +9882,6 @@ check_long_reg (void) prefix on a general reg is present. */ else if ((i.types[op].bitfield.word || i.types[op].bitfield.qword) - && (i.tm.operand_types[op].bitfield.class == Reg - || i.tm.operand_types[op].bitfield.instance == Accum) && i.tm.operand_types[op].bitfield.dword) { as_bad (_("incorrect register `%s%s' used with `%c' suffix"), @@ -9907,8 +9904,6 @@ check_qword_reg (void) /* Reject eight bit registers, except where the template requires them. (eg. movzb) */ else if (i.types[op].bitfield.byte - && (i.tm.operand_types[op].bitfield.class == Reg - || i.tm.operand_types[op].bitfield.instance == Accum) && (i.tm.operand_types[op].bitfield.word || i.tm.operand_types[op].bitfield.dword || i.tm.operand_types[op].bitfield.qword)) @@ -9923,12 +9918,8 @@ check_qword_reg (void) /* Error if the r prefix on a general reg is missing. */ else if ((i.types[op].bitfield.word || i.types[op].bitfield.dword) - && (i.tm.operand_types[op].bitfield.class == Reg - || i.tm.operand_types[op].bitfield.instance == Accum) && i.tm.operand_types[op].bitfield.qword) { - /* Prohibit these changes in the 64bit mode, since the - lowering is more complicated. */ as_bad (_("incorrect register `%s%s' used with `%c' suffix"), register_prefix, i.op[op].regs->reg_name, i.suffix); return 0; @@ -9947,10 +9938,9 @@ check_word_reg (void) /* Reject eight bit registers, except where the template requires them. (eg. movzb) */ else if (i.types[op].bitfield.byte - && (i.tm.operand_types[op].bitfield.class == Reg - || i.tm.operand_types[op].bitfield.instance == Accum) && (i.tm.operand_types[op].bitfield.word - || i.tm.operand_types[op].bitfield.dword)) + || i.tm.operand_types[op].bitfield.dword + || i.tm.operand_types[op].bitfield.qword)) { as_bad (_("`%s%s' not allowed with `%s%c'"), register_prefix, @@ -9962,8 +9952,6 @@ check_word_reg (void) /* Error if the e or r prefix on a general reg is present. */ else if ((i.types[op].bitfield.dword || i.types[op].bitfield.qword) - && (i.tm.operand_types[op].bitfield.class == Reg - || i.tm.operand_types[op].bitfield.instance == Accum) && i.tm.operand_types[op].bitfield.word) { as_bad (_("incorrect register `%s%s' used with `%c' suffix"),