From patchwork Fri Feb 16 09:58:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 202041 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp406722dyb; Fri, 16 Feb 2024 01:59:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUi6ouEFtCmWGfVGrUN6xkYnLyzpCQx50ZKQ26Ni25mTC7Mf1CB1lHjoHKfsyDDp31rrGjkzUcIuxSkUQkGR9hv7J8t3g== X-Google-Smtp-Source: AGHT+IGb7155gUdTeUMxySeAL/MwZzQoZe/PPUeWM0z/VcwkG+H7kEbboclyTJuesw8nRcEBuUez X-Received: by 2002:a05:620a:1359:b0:787:18cc:722f with SMTP id c25-20020a05620a135900b0078718cc722fmr4811917qkl.32.1708077559397; Fri, 16 Feb 2024 01:59:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708077559; cv=pass; d=google.com; s=arc-20160816; b=UwqWspB/VZEA8rPLF7SNzjoERtGl5uwhp5mlhAIHjr4UbDuLsr5RkzcLgNRE35CrAz NhAm9K+LRTJu2E9YdtULIGQ6gz4dASixl3+VL/w6csJqDUVIrwu79N1TVu4+hAWYObc6 k5AjqpfZniTzYOjWDDZyxu3kCRzrONDTKn7Oryj5aKnftAJxQNvy9qS/GdXmYrSxpKL/ /hC/BYO0D1qVtwTdx7/jsA3G0on5jjQW5+KyBtcLLeyLkq/1stViJoJWXZz+cYKko+Lk qAAc3UpdgZbQLo0uVT5F4pywm2w9JOU/Hu7MsELjlCsb06msN/dI+yIC64ux05Aeq/A7 ca6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:autocrypt:references:cc:to:from:content-language :subject:user-agent:mime-version:date:message-id:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=Bq/G2i5+7+R1+brOwp70SJTznB+bcFSAe4AFR/XaXAY=; fh=2DbSPqOhyO7CNtGa024QKgSiHKlKGVt2h+1rlgWLnZI=; b=dx3urDsPJc3zVD62eKRmy0XgnKRSDfwSR5c45wkXZIf+E26NyGLdtVCw1LDDh99hCC RYF50QXMFPx+LjtZ0AfAniWh+aPKEZiHbM2tYYWfH/7tSakN88vDjSvVLeYREa/OHdCq EQEoEVafDU8hlYbva3jPdfzW23AZGuQMpIVjEaG7N3ZhxrgTuiRaNY782w6KgbV77VMW Cp75NQVRlXXqNVqMoteMK65HuJ2SZ76qxGj+vE2LG8oveV9AEqpXfkxU4C7vaBDsoAYl DSa4sG5u5Lu9O3qKcgcdY0i6cfDPMe5Ji9ZLJkNH/4hesn+PiGRgQLYKk8OY+DUJY2fN 44bw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=JYBNDH1P; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u28-20020a05620a121c00b007873e71b3aesi1812713qkj.501.2024.02.16.01.59.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 01:59:19 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=JYBNDH1P; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 08548385829F for ; Fri, 16 Feb 2024 09:59:19 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by sourceware.org (Postfix) with ESMTPS id 38C053858C54 for ; Fri, 16 Feb 2024 09:58:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38C053858C54 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 38C053858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708077540; cv=none; b=N5p/M6O2Z5HbRaQxlH/+zeTL92R9bLEklLJjaR4PEiglxXKvgltXabABP94IA5CkkKeurvDEud/a9DUbNMQSp3YD4JphXOTHirFkohdVYLQ65PbkSKzUUdcw14xt4/mX5PeXVDA/xb6nuNP+BkOLECm+yxOhHgJVQ/kBR3h+JN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708077540; c=relaxed/simple; bh=lbfG71bhtUTwMkc9w1jP/siyFXtY/Qk5A/e1CQdAxY0=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=Rn3WCGxGM5KOjhfqwGBdexfGSVVHb17Putdfbs+r5FSh+ECCzRYvMcs9GYvoSWNJ+Z2HM316l9q0hrNqfgS1bcGrDSXY3h6tLZs7rB9IoxchQtH9nvly10EVqWFcFh5oRFs+pVypOluHUzh9ktIDt30na7461+FdvlDRtfkzz9o= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-412191ed8aaso11675865e9.2 for ; Fri, 16 Feb 2024 01:58:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1708077537; x=1708682337; 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=Bq/G2i5+7+R1+brOwp70SJTznB+bcFSAe4AFR/XaXAY=; b=JYBNDH1Pi3z5cUMrgJoGoPvg9KIBp7DU0FPIMWrNViilP2Az9+wm9Si+Q09S0RpV+R 42yAqEOfEiXtWPs5IrKE6xjynz/kaojcJ84OYFNRaF0jioWhopbeTo5cmB34AgN7GOzq Xhu+C3YOm6jxVe0apsCBOGm/nYj76lkQIuAm4Oy+pJhfjsYfDHn4BHa1M53BJrwv69FN ukN5lDMMirbbFHGY4vHZXlet8QZuohlWI/BglATWfgV4vDDCS1iEA4a7Fax/KhMkD6s1 qyD58FdHFtP5crkElS/tFQo1vXDL3uKhTrmJWDxCh+o7JN6g/W6YnvcYMHnyKz8e2dhh femQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708077537; x=1708682337; 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=Bq/G2i5+7+R1+brOwp70SJTznB+bcFSAe4AFR/XaXAY=; b=DlfHs2XVAe0g3uFzBDYW6WbPsb9v74fVcOxUbS7sKLPa9JsTIw6o6TwBu408s0IfN+ kux1i1gUECw7Uno+wlXMY7KW1UQAdwDl3Bkx0t9vHtkZmCKVpwfB0YiIqHG8cTdwjkSU poNVkDE4n2sJL5xpgUAFbVri8rrR9t0EuIHX22MYBNdJS/o9XgfwpZ/ZyIz/TCxGjufl IuP3hmJ7yJvzLPqrr8soKRB7fTObGqJO7H6xFJzTdBkwBNQhMMWm//mnrbf0NJFvXhSV LoBEAJtUP/CXG2RVtmbEqIRb+wR1DFv8ME2khNhuaQaiPbSd+VYpYk6Hb+Q6nY0o/Ig0 O8HQ== X-Gm-Message-State: AOJu0YwWWwbwb9M6fONfBYGuT6Xa3gfJ6SEf9/F0X3JtSB1RCCZp7YKP WiUugS87v+n7rx4O33/YW3B0V+k7R/RD+i+gx0M0QXoAFUzPEvtxAYYLVLoaNXFcOeG1qVfdCkA = X-Received: by 2002:a05:600c:4f14:b0:410:cf4f:68e1 with SMTP id l20-20020a05600c4f1400b00410cf4f68e1mr3083514wmq.2.1708077536398; Fri, 16 Feb 2024 01:58:56 -0800 (PST) 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 jv14-20020a05600c570e00b0040fe3147babsm1820618wmb.0.2024.02.16.01.58.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Feb 2024 01:58:56 -0800 (PST) Message-ID: <74cf88e4-5b0d-40a3-9eb5-f0829ed490df@suse.com> Date: Fri, 16 Feb 2024 10:58:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 3/4] x86/APX: correct .insn opcode space determination when REX2 is needed Content-Language: en-US From: Jan Beulich To: Binutils Cc: "H.J. Lu" , Lili Cui References: <3098e797-3749-40ee-802c-ea8a6f63914c@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7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nDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <3098e797-3749-40ee-802c-ea8a6f63914c@suse.com> X-Spam-Status: No, score=-3025.5 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, 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.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791049135193153953 X-GMAIL-MSGID: 1791049135193153953 In this case spaces 0f38 and 0f3a may not be put in place. To achieve the intended effect, operand parsing (but not operand processing) needs pulling ahead, so we know whether eGRP-s are in use. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -12849,13 +12849,43 @@ s_insn (int dummy ATTRIBUTE_UNUSED) } } + /* Parse operands, if any, before evaluating encoding space. */ + if (*line == ',') + { + i.memshift = -1; + + ptr = parse_operands (line + 1, &i386_mnemonics[MN__insn]); + this_operand = -1; + if (!ptr) + goto bad; + line = ptr; + + if (!i.operands) + { + as_bad (_("expecting operand after ','; got nothing")); + goto done; + } + + if (i.mem_operands > 1) + { + as_bad (_("too many memory references for `%s'"), + &i386_mnemonics[MN__insn]); + goto done; + } + + /* No need to distinguish encoding_evex and encoding_evex512. */ + if (i.encoding == encoding_evex512) + i.encoding = encoding_evex; + } + /* Trim off encoding space. */ if (j > 1 && !i.insn_opcode_space && (val >> ((j - 1) * 8)) == 0x0f) { uint8_t byte = val >> ((--j - 1) * 8); i.insn_opcode_space = SPACE_0F; - switch (byte & -(j > 1)) + switch (byte & -(j > 1 && !i.rex2_encoding + && (i.encoding != encoding_egpr || evex))) { case 0x38: i.insn_opcode_space = SPACE_0F38; @@ -12878,42 +12908,17 @@ s_insn (int dummy ATTRIBUTE_UNUSED) if (j > 2) { as_bad (_("opcode residual (%#"PRIx64") too wide"), (uint64_t) val); - goto bad; + goto done; } i.opcode_length = j; /* Handle operands, if any. */ - if (*line == ',') + if (i.operands) { i386_operand_type combined; expressionS *disp_exp = NULL; bool changed; - i.memshift = -1; - - ptr = parse_operands (line + 1, &i386_mnemonics[MN__insn]); - this_operand = -1; - if (!ptr) - goto bad; - line = ptr; - - if (!i.operands) - { - as_bad (_("expecting operand after ','; got nothing")); - goto done; - } - - if (i.mem_operands > 1) - { - as_bad (_("too many memory references for `%s'"), - &i386_mnemonics[MN__insn]); - goto done; - } - - /* No need to distinguish encoding_evex and encoding_evex512. */ - if (i.encoding == encoding_evex512) - i.encoding = encoding_evex; - if (i.encoding == encoding_egpr) { if (vex || xop) --- /dev/null +++ b/gas/testsuite/gas/i386/insn-rex2.l @@ -0,0 +1,38 @@ +[ ]*[0-9]+[ ]+\.text +[ ]*[0-9]+[ ]+insn_rex2: +[ ]*[0-9]+ .... D58001C0[ ]+\.insn \{rex2\} 0x0f01/0, %eax +[ ]*[0-9]+ .... D58038C0[ ]+\.insn \{rex2\} 0x0f38/0, %eax +[ ]*[0-9]+ .... D5803801[ ]+\.insn \{rex2\} 0x0f3801/0, %eax +[ ]*[0-9]+ +C0 +[ ]*[0-9]+ .... D5803901[ ]+\.insn \{rex2\} 0x0f3901/0, %eax +[ ]*[0-9]+ +C0 +[ ]*[0-9]+ .... D5803A01[ ]+\.insn \{rex2\} 0x0f3a01/0, \$0xCC, %eax +[ ]*[0-9]+ +C0CC +[ ]*[0-9]+[ ]+ +[ ]*[0-9]+ .... D58801C0[ ]+\.insn \{rex2\} 0x0f01/0, %rax +[ ]*[0-9]+ .... D58838C0[ ]+\.insn \{rex2\} 0x0f38/0, %rax +[ ]*[0-9]+ .... D5883801[ ]+\.insn \{rex2\} 0x0f3801/0, %rax +[ ]*[0-9]+ +C0 +[ ]*[0-9]+ .... D5883901[ ]+\.insn \{rex2\} 0x0f3901/0, %rax +[ ]*[0-9]+ +C0 +[ ]*[0-9]+ .... D5883A01[ ]+\.insn \{rex2\} 0x0f3a01/0, \$0xCC, %rax +[ ]*[0-9]+ +C0CC +[ ]*[0-9]+[ ]+ +[ ]*[0-9]+ .... D58901C0[ ]+\.insn \{rex2\} 0x0f01/0, %r8 +[ ]*[0-9]+ .... D58938C0[ ]+\.insn \{rex2\} 0x0f38/0, %r8 +[ ]*[0-9]+ .... D5893801[ ]+\.insn \{rex2\} 0x0f3801/0, %r8 +[ ]*[0-9]+ +C0 +[ ]*[0-9]+ .... D5893901[ ]+\.insn \{rex2\} 0x0f3901/0, %r8 +[ ]*[0-9]+ +C0 +[ ]*[0-9]+ .... D5893A01[ ]+\.insn \{rex2\} 0x0f3a01/0, \$0xCC, %r8 +[ ]*[0-9]+ +C0CC +[ ]*[0-9]+[ ]+ +[ ]*[0-9]+ .... D59801C0[ ]+\.insn 0x0f01/0, %r16 +[ ]*[0-9]+ .... D59838C0[ ]+\.insn 0x0f38/0, %r16 +[ ]*[0-9]+ .... D5983801[ ]+\.insn 0x0f3801/0, %r16 +[ ]*[0-9]+ +C0 +[ ]*[0-9]+ .... D5983901[ ]+\.insn 0x0f3901/0, %r16 +[ ]*[0-9]+ +C0 +[ ]*[0-9]+ .... D5983A01[ ]+\.insn 0x0f3a01/0, \$0xCC, %r16 +[ ]*[0-9]+[ ]+C0CC +#pass --- /dev/null +++ b/gas/testsuite/gas/i386/insn-rex2.s @@ -0,0 +1,25 @@ + .text +insn_rex2: + .insn {rex2} 0x0f01/0, %eax + .insn {rex2} 0x0f38/0, %eax + .insn {rex2} 0x0f3801/0, %eax + .insn {rex2} 0x0f3901/0, %eax + .insn {rex2} 0x0f3a01/0, $0xCC, %eax + + .insn {rex2} 0x0f01/0, %rax + .insn {rex2} 0x0f38/0, %rax + .insn {rex2} 0x0f3801/0, %rax + .insn {rex2} 0x0f3901/0, %rax + .insn {rex2} 0x0f3a01/0, $0xCC, %rax + + .insn {rex2} 0x0f01/0, %r8 + .insn {rex2} 0x0f38/0, %r8 + .insn {rex2} 0x0f3801/0, %r8 + .insn {rex2} 0x0f3901/0, %r8 + .insn {rex2} 0x0f3a01/0, $0xCC, %r8 + + .insn 0x0f01/0, %r16 + .insn 0x0f38/0, %r16 + .insn 0x0f3801/0, %r16 + .insn 0x0f3901/0, %r16 + .insn 0x0f3a01/0, $0xCC, %r16 --- a/gas/testsuite/gas/i386/x86-64.exp +++ b/gas/testsuite/gas/i386/x86-64.exp @@ -126,6 +126,7 @@ run_dump_test "x86-64-sysenter-mixed" run_dump_test "x86-64-sysenter-amd" run_list_test "x86-64-sysenter-amd" "-mamd64" run_dump_test "insn-64" +run_list_test "insn-rex2" "-aln" run_dump_test "noreg64" run_list_test "noreg64" run_dump_test "noreg64-data16"