From patchwork Fri May 17 10:48:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 90367 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 D09CB384AB72 for ; Fri, 17 May 2024 10:48:41 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 3B4253858D20 for ; Fri, 17 May 2024 10:48:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3B4253858D20 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 3B4253858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::531 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715942893; cv=none; b=k7hOA6cCocAlfRi1s4xL7YoEKXW7vwxiwf7DpEPDj2OdfYEj20q/l7+AEdAwZ7FOuTuzx6cwL9N50gYBEj1QuJq9qKFiAKQS3IrUsVz8bCf1PeZCQvtzeOjeHX/e2qZbsCWMJM5c3qaWzIsK+8BKIdkM7MAQwiP1a1P0Ra+jvLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715942893; c=relaxed/simple; bh=ooGuV3aTIQYfN5aplwwJyi0MHjTm1dPWzbYOq5rN2Vc=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=O8lQM0vctIuulq7ZVIQZROkOqnAXpVabkf3QzjS3uIhRQ4tlHWi89SBkkxde5AR3IknRLcVdpUn5j3eyUYtFlqPR7eQcyznPJG6kwIZXrKx1UOkTZQRGxmU06UBZTxX9RRUrX4nQMHUe3PSAaivcszVp1w9XVfjGXgLSxw30t3Q= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-572669fd9f9so4794194a12.0 for ; Fri, 17 May 2024 03:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1715942890; x=1716547690; 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=0Ez4pdrjnvnZHgeBqzIDjjAS/AhwganxZ4702HqVGMQ=; b=TKJWPIshZN39/v2qDZQ5eJKbkVfJvbNyLo8sWbtl3eVMlKYkGXzJeHGJD4AypeeC+N VEH5zW/2j7iz3EtOLre2TirCFp8asWEESyzeaNG0gGsQgvPZxPZPu7kO/az/OBEYl9Rg 0wNO9mA1K9+TlhgInn+sjzNR0RL6jAdJbWDgqvEs+xEQqzCOCMYQesgPnqbOzuRYpvNT 07Oem/j0X4k/p7jWdLHJPJVF5DHjPd/372Ql40fJAwdoCk3Xkzou6z3Q8j7ipBt4uayR M92eTF1EN818Ki5BCGB8OxBvbIenfoKuOG1zfEw3EnPXX6CLpu4/wtP9l7Qnp45dW5r2 q4Yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715942890; x=1716547690; 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=0Ez4pdrjnvnZHgeBqzIDjjAS/AhwganxZ4702HqVGMQ=; b=FhcLCTR0ITUjqdgj4kFMJwMVgsiTtRPVnmXsujCp0ft0uOiDEWIALaV9z2E6/hR0ua f9op4Phkq63Yz3PhcXebrRiCbedncvDdAR49R3Yn1FC2vW+FrEFQvOT1MvW03HNGEmBI NlUSTygi6vi1JxP4V0pxr9/p3vkOUKNU5sfwJV5QKJQ8W03njkTLxqx85OfLek7axf2y atGnSiBmAuSpUvI2XiKAAe1JqxJZMvbVYCzkSG2DHJ4iVgQ97wJnqZ0gQm5XGmFwUpWu GVuiqk7As2xlxS0ESf2of92j6fcYfwhezLVFMRIIbOx6tWogSotSnCx1fbUeC7NCXoGs F16Q== X-Gm-Message-State: AOJu0Yw49jaNaBUUvZjoJkfcIGdRl01uMbYDojd2Yux8TaqNdsr9Dyme k7/MjieliuB8E8TMuGd+JjBizha2zQcFv1dm9K7/5heI0WzD49gkKVxC/xaOj4ju32FNosYBpbo = X-Google-Smtp-Source: AGHT+IE7f1STo3qnky2BZG4h4tXP35bIPDwyVJOGebDPBfpnCogCqzQtAT1U9vmpR+1T7tfBhyCtAQ== X-Received: by 2002:a17:907:6d02:b0:a5d:d35:7228 with SMTP id a640c23a62f3a-a5d0d3572c4mr82734266b.30.1715942889967; Fri, 17 May 2024 03:48:09 -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 a640c23a62f3a-a5d0edb7922sm51066566b.94.2024.05.17.03.48.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 May 2024 03:48:09 -0700 (PDT) Message-ID: <3f5f4eb7-d448-4bf5-aa35-bf93cc9ca180@suse.com> Date: Fri, 17 May 2024 12:48:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH v2 1/2] x86/Intel: SHLD/SHRD have dual meaning From: Jan Beulich To: Binutils Cc: "H.J. Lu" References: Content-Language: en-US Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/Br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VSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: 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 Since we uniformly permit D suffixes in Intel mode whenever in AT&T mode an L suffix may be used, we need to be consistent with this. Take the easy route, despite that still leading to an anomaly which is also visible from the new testcase: shld eax, ecx, 1 shld eax, ecx, cl can mean two things with APX: SHL with a D suffix in NDD EVEX encoding, or the traditional SHLD in legacy encoding. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -5392,7 +5392,7 @@ static void init_globals (void) } /* Helper for md_assemble() to decide whether to prepare for a possible 2nd - parsing pass. Instead of introducing a rarely use new insn attribute this + parsing pass. Instead of introducing a rarely used new insn attribute this utilizes a common pattern between affected templates. It is deemed acceptable that this will lead to unnecessary pass 2 preparations in a limited set of cases. */ @@ -5404,7 +5404,10 @@ static INLINE bool may_need_pass2 (const : (t->opcode_space == SPACE_0F && (t->base_opcode | 1) == 0xbf) || (t->opcode_space == SPACE_BASE - && t->base_opcode == 0x63); + && t->base_opcode == 0x63) + || (intel_syntax /* shld / shrd may mean suffixed shl / shr. */ + && t->opcode_space == SPACE_EVEXMAP4 + && (t->base_opcode | 8) == 0x2c); } #if defined (OBJ_MAYBE_ELF) || defined (OBJ_ELF) --- /dev/null +++ b/gas/testsuite/gas/i386/intel-suffix.d @@ -0,0 +1,34 @@ +#objdump: -dw +#name: Intel syntax w/ suffixes + +.*: +file format .* + +Disassembly of section \.text: +0+0 <.*>: +[ ]*[a-f0-9]+: 0f a4 c8 01[ ]+shld \$0x1,%ecx,%eax +[ ]*[a-f0-9]+: 0f a5 c8[ ]+shld %cl,%ecx,%eax +[ ]*[a-f0-9]+: d1 e1[ ]+shl \$1,%ecx +[ ]*[a-f0-9]+: d3 e1[ ]+shl %cl,%ecx +[ ]*[a-f0-9]+: 62 f4 7c 18 d1 e1[ ]+shl \$1,%ecx,%eax +[ ]*[a-f0-9]+: 62 f4 7c 18 d3 e1[ ]+shl %cl,%ecx,%eax +[ ]*[a-f0-9]+: d1 e1[ ]+shl \$1,%ecx +[ ]*[a-f0-9]+: d3 e1[ ]+shl %cl,%ecx +[ ]*[a-f0-9]+: 62 f4 7c 18 d1 c1[ ]+rol \$1,%ecx,%eax +[ ]*[a-f0-9]+: 62 f4 7c 18 d3 c1[ ]+rol %cl,%ecx,%eax +[ ]*[a-f0-9]+: d1 c1[ ]+rol \$1,%ecx +[ ]*[a-f0-9]+: d3 c1[ ]+rol %cl,%ecx + +0+[0-9a-f]+ <.*>: +[ ]*[a-f0-9]+: 0f ac c8 01[ ]+shrd \$0x1,%ecx,%eax +[ ]*[a-f0-9]+: 0f ad c8[ ]+shrd %cl,%ecx,%eax +[ ]*[a-f0-9]+: d1 e9[ ]+shr \$1,%ecx +[ ]*[a-f0-9]+: d3 e9[ ]+shr %cl,%ecx +[ ]*[a-f0-9]+: 62 f4 7c 18 d1 f9[ ]+sar \$1,%ecx,%eax +[ ]*[a-f0-9]+: 62 f4 7c 18 d3 f9[ ]+sar %cl,%ecx,%eax +[ ]*[a-f0-9]+: d1 f9[ ]+sar \$1,%ecx +[ ]*[a-f0-9]+: d3 f9[ ]+sar %cl,%ecx +[ ]*[a-f0-9]+: 62 f4 7c 18 d1 c9[ ]+ror \$1,%ecx,%eax +[ ]*[a-f0-9]+: 62 f4 7c 18 d3 c9[ ]+ror %cl,%ecx,%eax +[ ]*[a-f0-9]+: d1 c9[ ]+ror \$1,%ecx +[ ]*[a-f0-9]+: d3 c9[ ]+ror %cl,%ecx +#pass --- /dev/null +++ b/gas/testsuite/gas/i386/intel-suffix.s @@ -0,0 +1,39 @@ + .intel_syntax noprefix + .text +left: + shld eax, ecx, 1 + shld eax, ecx, cl + + shld ecx, 1 + shld ecx, cl + + sald eax, ecx, 1 + sald eax, ecx, cl + + sald ecx, 1 + sald ecx, cl + + rold eax, ecx, 1 + rold eax, ecx, cl + + rold ecx, 1 + rold ecx, cl + +right: + shrd eax, ecx, 1 + shrd eax, ecx, cl + + shrd ecx, 1 + shrd ecx, cl + + sard eax, ecx, 1 + sard eax, ecx, cl + + sard ecx, 1 + sard ecx, cl + + rord eax, ecx, 1 + rord eax, ecx, cl + + rord ecx, 1 + rord ecx, cl --- a/gas/testsuite/gas/i386/x86-64.exp +++ b/gas/testsuite/gas/i386/x86-64.exp @@ -160,6 +160,7 @@ run_dump_test "x86-64-disp-intel" run_list_test "disp-imm-64" run_dump_test "intel-movs64" run_dump_test "intel-cmps64" +run_dump_test "intel-suffix" run_dump_test "x86-64-disp32" run_dump_test "rexw" run_list_test "x86-64-specific-reg"