From patchwork Fri Feb 10 08:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 55325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp837173wrn; Fri, 10 Feb 2023 00:54:02 -0800 (PST) X-Google-Smtp-Source: AK7set+BPzzGb8A4Mejxh7peYdQsbctGuD/ADjO7J/LxlLGgK46Xl3hOWRh7aoJzUw14hVSDvSoq X-Received: by 2002:a50:c30d:0:b0:4ab:4411:2f71 with SMTP id a13-20020a50c30d000000b004ab44112f71mr2051954edb.37.1676019242287; Fri, 10 Feb 2023 00:54:02 -0800 (PST) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s12-20020a056402164c00b004ab1eb44d0asi4377833edx.487.2023.02.10.00.54.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Feb 2023 00:54:02 -0800 (PST) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=v9KLlhrH; arc=fail (signature failed); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43DF93858C2D for ; Fri, 10 Feb 2023 08:54:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43DF93858C2D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1676019241; bh=iln8YjrI6PNE96ZX5a4Qc8cejPBITZiH5Cl16znOnpU=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=v9KLlhrHhKqtTSqHZeTQXAehRUO0R/weQkxrtUsvtulqvKxTQsWFAcbh4OqfrEo4O iHLiDS1Y0O927Fc4vkGZIpY62e/aA1AIeGyjVPNZw69XPy65tniby2ltzPyXizT4v+ waVmTK4XISSJPiURApDzdvKaHncDFlXOpdZAmz6g= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2054.outbound.protection.outlook.com [40.107.8.54]) by sourceware.org (Postfix) with ESMTPS id D88CE3858C31 for ; Fri, 10 Feb 2023 08:53:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D88CE3858C31 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n4OIdVCbXEv+Wry3LTHEesnQzh28A/dCDI7ncCbMDx2ftkul1s6HLmLW2cqBeVLRhxwlRXsC9clcCjR0CHAZmlatxdD0q/UvvyoEeyP72iorCYOhpfyJ51xDjvB71H3ada6N7kdJ+JAM5AlfQXe8WWv7MzmNhk7bs9uAyPSBjU1TMseVrdyhir3KKwfdQ1Eby1p1HDEg/3+zUSYGaZ09VIOhGgQ5cU49/ZRDT3Vcp7el3LRyEB6/x7xeunlei2I6PW/R6Q2X2Sfm7w/lq0RTgB9pi536gSFG6Qiagej0Jac1KGNnUkOy+/aIuuj4dO+ceAyRUSOTs+bYMGbOPseqwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iln8YjrI6PNE96ZX5a4Qc8cejPBITZiH5Cl16znOnpU=; b=EpIuGu3En/encKW2XWokNwDFET2+OJ1YHGfuciFAasfRmr2QG04XTYvWP/XVFqu84NngeUHlrsqCeE10o1UXrP+gWmpYvp5h0wPflk6tZQLjJL6ZK57CiGIHSnXJ9y6nM0dM1Mk5F5CuhEtelFtx6e/1GiySw79mo6OM2cNApXnelXgeLJBxRCoRwq0jZ234OeKakdwZ19H9tDSlV7xWHmzqy3FCjmKuMEFt9GFkzJ9/HHov2oTCoAuLouGOEBbabqk7cWmMCzjmt3qdtVtpqS6bl/qxjy7/QnXEQVvKiVV7fr75aeOSrFvYUtFTEcWUc+L8SxS3QaDoqL9K7ALO7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Received: from VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) by AM9PR04MB8507.eurprd04.prod.outlook.com (2603:10a6:20b:432::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.21; Fri, 10 Feb 2023 08:53:49 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::e138:4fc3:705c:d178]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::e138:4fc3:705c:d178%7]) with mapi id 15.20.6086.019; Fri, 10 Feb 2023 08:53:49 +0000 Message-ID: Date: Fri, 10 Feb 2023 09:53:47 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US To: Binutils Cc: "H.J. Lu" Subject: [PATCH] x86: allow to request ModR/M encoding X-ClientProxiedBy: FR2P281CA0014.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a::24) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|AM9PR04MB8507:EE_ X-MS-Office365-Filtering-Correlation-Id: 46aeaa59-f93d-4fd1-755f-08db0b4453eb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E7Hc8lOow7uLQqu4i84+AuTxFgrRD0m3tKk6+Xaqh6XTX/226IbKlB7QH6IFu9Ecou1bbx9PRoov9GmrZsuqomxbt460MUHhlPdBdHhXIVyoP6eEmKVKwIU8FLiLsGgcxMYnp8DrmPTKVT0ZyV4B90lxPrg2ofQvc9Vhs+Erk0nY0PHTOJtez0BtkwDBxgh5mVQK1og53Y5sHETaEpbsLcsav5zjn1PqPM85Es4Hw9YgnYNxDTPRuq2l1hKirJZWvvhwTd2AAFNkqp8YNdZDuCTQjipxESCD7HGNT5kA5zHrQuPRCQh3v3rfmsZdGsLCTPpd2SdjYSGUKNnzrzhBruJ4GMrlfmKZHmomTytriAMAKfQ/SHx5BkWOg9wdz3dTsWJdA5n3Sw2MvycV76ZxqxGB6pUbGKYaArESnOdR7ESz8X1Wd+TCelRb3I1Xl82eErewGBHv7omIzykaQ1/A2wjqzBMLQxPAAl+eLXNdp/1fG79o1oVDNxo9ohm0FAXUtT6BAK4S+OF2KnPciOBEZg7yj0n2NWd9xisCXYmCPuILXybfp3sXngfgZxzZSedbo+HIwlvLFkmM7DWtKA4G2u1iExRS2N9kqlbXpHkddCy0MasFhTFfvzH2BUHWneTqXzRCPQsDkBFP7D/nDgtINEGrPQfsZrG5ja+Wyh6C78IpVlwTBvX0l3S51QSZbRv6xSQcXody3dmNgB5tUGOQEJ2N+w0AZuZ5mDgS/QAZjjY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6560.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230025)(376002)(396003)(136003)(346002)(39860400002)(366004)(451199018)(36756003)(2906002)(6486002)(478600001)(26005)(6506007)(186003)(2616005)(6512007)(83380400001)(6916009)(4326008)(8676002)(41300700001)(66556008)(66476007)(30864003)(66946007)(31696002)(8936002)(5660300002)(38100700002)(316002)(86362001)(31686004)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?iaj7cCXoiCn4GavDNiGfSjRw+zKU?= =?utf-8?q?qIstIGKvWKSqFMhFLWsdYRocG0yMhAvtfb+g+VwDqElxJvtJ9/mF+z4peX1vjZSay?= =?utf-8?q?WuEAcrSDha0SdxgH6cmaI2nLTE3F1OHVd++Yc0G3gY5JHRlbytjKwPYO5EY0jTz+A?= =?utf-8?q?RDOihpkYwrgj/4iSOZR1Y4EwgjHbnqcWm8b6bVo1ZJj/IiR8k4xWBMxWyFyU5Hjp/?= =?utf-8?q?hnJ9PlZCC3q/BEXJpB9kfpAOjq/WkXJjnCwNCp5+ZrICqRsf7ZQSjcRSseAVs8Mms?= =?utf-8?q?CPxmTAjSFbrslXVsGZp2Shf4/7Z3ReFHZox8CA8NySnB1dIH++C0gYXuzMCoXZFuq?= =?utf-8?q?bTOAiPOi81Zf9nYyDFf9k7G3FWlSylSoxkD7CrFX5BCpS0SixO0F/y2JDzTyFa/MG?= =?utf-8?q?rOY528PQ2YUt0zMwzPnwgDjEUoKSHEu4rST0R228C1ubyxjT4DQUuLf2ns7oIILlN?= =?utf-8?q?XUx7tCSZ48CO0xo6nr0rcLcvXLiwRnlv4PTCt0PO1Y92ANtFL6HeKAfcKxLIVv7Gy?= =?utf-8?q?CM8QN1hhf+CGCLPjw1ZVaua0zXe2kNYc6GtvM3Z7aFUOJ5dvy0i8b7tZdFqKmWJXv?= =?utf-8?q?ZsK2kF/4w2SaWSJrtq9m/7lFsB06gqIw4CO569HVFYu3Com9xP0x9T1f/tzED2Co4?= =?utf-8?q?KJ5T4cZFJBYe8OfKKXmZkUk8GLpsymOT/aYfmy2ESwRqRnsIvIcAkU3ZC/aX+0BOe?= =?utf-8?q?4bP2/hWU/DR7cQ+6XTpu0QcoOjRH5oTqB8HCawQXMGkS53SmaK0MPL1J3S9+knTeN?= =?utf-8?q?7XCkOdGw1HlKcinxkMOywZXi7yLjElX7N4kYY9Ee7+ZAB9crH3syTQeereTMdg/54?= =?utf-8?q?IElL1Eh9H1gz4KC1UFln+RHo5JydAJLDaY1p5/6EpgQMSV5WGbhfMGsHU8Y7YlCkc?= =?utf-8?q?bNWlCgURQqg9pkDJiep1EC7sEm4IIz4ptK6uppu47o2fnSvxhkiamx/q0nIawbwt1?= =?utf-8?q?9xnh7fUOfx49sAXhXCZ7arHuGlBh5lFObeC4VTHSWr3vDl8Inj35BCakEV/4/QUdR?= =?utf-8?q?3FXmxbNhN0BQ6cvO+/PCTBvqS2373yjFcS9uNvogZr5MHWTg8JfeALJbL80KgLu+z?= =?utf-8?q?tuRawW1ObN9RCP2wwukzZZUi8cSz04M2LicZsxWL+LbfMwo34iW/Ubs7q2QpKqOui?= =?utf-8?q?Q5221vt+p+Mwz0RYBGiEKj8WkCnWL96mZzP5mX56mi9DwgQGAks9vI+gZZjdToqwT?= =?utf-8?q?sKY4hD4y2GGaXPLouZT2R0RCQiMQ2GcZ8ajelTU/oxBo7prlLS9ejYXmAsxMS/b1h?= =?utf-8?q?M5F3cVn75+Qa1IotOQvumfzFSSIHA5EbpKzdKvf6FdOsgRluw0TtwhM5+H4o0k4bP?= =?utf-8?q?7V5MHVgYP3IJitroABOWsjaNNUKliqTu49mdhQHdyLLcOPNIjk/jjInPqmumHhKHx?= =?utf-8?q?DHJQWH6CG7Ts9+CvLeuTqt+trVRu3ReloUPgfPymFFa1RoVo6/+yZM2LHxnEGlqUT?= =?utf-8?q?66fzMTnPZg7aEjQmXJjJAAFuY+HymN6cA0YETDuOKJIYgIXRyOfNRyIWFCiDJvAtl?= =?utf-8?q?8NPECsFVUJHP?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 46aeaa59-f93d-4fd1-755f-08db0b4453eb X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Feb 2023 08:53:49.8241 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Yy+KTl/rcXYTAjHcJ3WxxWFKPEHH7LN0FKHAMakkzVXHtvgct0HkzfjRkVvxkBgtu2BkqmuuuMa/2l0wLhCJBQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8507 X-Spam-Status: No, score=-3028.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, 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.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jan Beulich via Binutils From: Jan Beulich Reply-To: Jan Beulich Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757433553066051329?= X-GMAIL-MSGID: =?utf-8?q?1757433553066051329?= Several insns have a (typically shorter) non-ModR/M and a (typically longer) ModR/M encoding. In most cases the former is used by default. This isn't too dissimilar from register-only insns sometimes having two encoding forms. In those cases {load} or {store} can be used to control the encoding used. Extend this to ModR/M-less encodings which have a ModR/M counterpart (note that BSWAP hasn't). For insn reading and writing their (explicit) memory operand, both prefixes are honored; otherwise only the applicable one is. Note that for some forms of XCHG, {store} has already been performing this function, apparently as an unnoticed side effect of adding D to the template. --- There are further cases where alternative encodings cannot be requested, e.g. the various shift/rotate insns with an immediate operand of 1, or {,V}MOVQ to/from memory. For now I don't have a good idea how to make those work (preferably without introducing yet another pseudo prefix). --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -6883,19 +6883,40 @@ match_template (char mnem_suffix) case 1: if (!operand_type_match (overlap0, i.types[0])) continue; + + /* Allow the ModR/M encoding to be requested by using the {load} or + {store} pseudo prefix on an applicable insn. */ + if (!t->opcode_modifier.modrm + && i.reg_operands == 1 + && ((i.dir_encoding == dir_encoding_load + && t->mnem_off != MN_pop) + || (i.dir_encoding == dir_encoding_store + && t->mnem_off != MN_push)) + /* Avoid BSWAP. */ + && t->mnem_off != MN_bswap) + continue; break; + case 2: /* xchg %eax, %eax is a special case. It is an alias for nop only in 32bit mode and we can use opcode 0x90. In 64bit mode, we can't use 0x90 for xchg %eax, %eax since it should zero-extend %eax to %rax. */ - if (flag_code == CODE_64BIT - && t->base_opcode == 0x90 - && t->opcode_space == SPACE_BASE - && i.types[0].bitfield.instance == Accum - && i.types[0].bitfield.dword - && i.types[1].bitfield.instance == Accum) - continue; + if (t->base_opcode == 0x90 + && t->opcode_space == SPACE_BASE) + { + if (flag_code == CODE_64BIT + && i.types[0].bitfield.instance == Accum + && i.types[0].bitfield.dword + && i.types[1].bitfield.instance == Accum) + continue; + + /* Allow the ModR/M encoding to be requested by using the + {load} or {store} pseudo prefix. */ + if (i.dir_encoding == dir_encoding_load + || i.dir_encoding == dir_encoding_store) + continue; + } if (t->base_opcode == MOV_AX_DISP32 && t->opcode_space == SPACE_BASE @@ -6909,6 +6930,38 @@ match_template (char mnem_suffix) match the accumulator-only encoding of mov. */ if (i.hle_prefix) continue; + + /* Allow the ModR/M encoding to be requested by using a suitable + {load} or {store} pseudo prefix. */ + if (i.dir_encoding == (i.types[0].bitfield.instance == Accum + ? dir_encoding_store + : dir_encoding_load) + && !i.types[0].bitfield.disp64 + && !i.types[1].bitfield.disp64) + continue; + } + + /* Allow the ModR/M encoding to be requested by using the {load} or + {store} pseudo prefix on an applicable insn. */ + if (!t->opcode_modifier.modrm + && i.reg_operands == 1 + && i.imm_operands == 1 + && (i.dir_encoding == dir_encoding_load + || i.dir_encoding == dir_encoding_store) + && t->opcode_space == SPACE_BASE) + { + if (t->base_opcode == 0xb0 /* mov $imm, %reg */ + && i.dir_encoding == dir_encoding_store) + continue; + + if ((t->base_opcode | 0x38) == 0x3c /* $imm, %acc */ + && (t->base_opcode != 0x3c /* cmp $imm, %acc */ + || i.dir_encoding == dir_encoding_load)) + continue; + + if (t->base_opcode == 0xa8 /* test $imm, %acc */ + && i.dir_encoding == dir_encoding_load) + continue; } /* Fall through. */ --- a/gas/testsuite/gas/i386/pseudos.d +++ b/gas/testsuite/gas/i386/pseudos.d @@ -54,10 +54,10 @@ Disassembly of section .text: +[a-f0-9]+: 31 c8 xor %ecx,%eax +[a-f0-9]+: 33 c1 xor %ecx,%eax +[a-f0-9]+: 31 c8 xor %ecx,%eax - +[a-f0-9]+: a1 78 56 34 12 mov 0x12345678,%eax + +[a-f0-9]+: 8b 05 78 56 34 12 mov 0x12345678,%eax +[a-f0-9]+: a3 78 56 34 12 mov %eax,0x12345678 +[a-f0-9]+: a1 78 56 34 12 mov 0x12345678,%eax - +[a-f0-9]+: a3 78 56 34 12 mov %eax,0x12345678 + +[a-f0-9]+: 89 05 78 56 34 12 mov %eax,0x12345678 +[a-f0-9]+: 89 07 mov %eax,\(%edi\) +[a-f0-9]+: 8b 07 mov \(%edi\),%eax +[a-f0-9]+: 89 07 mov %eax,\(%edi\) @@ -126,6 +126,91 @@ Disassembly of section .text: +[a-f0-9]+: 33 07 xor \(%edi\),%eax +[a-f0-9]+: 31 07 xor %eax,\(%edi\) +[a-f0-9]+: 33 07 xor \(%edi\),%eax + +[a-f0-9]+: b0 12 mov \$0x12,%al + +[a-f0-9]+: b8 45 03 00 00 mov \$0x345,%eax + +[a-f0-9]+: b0 12 mov \$0x12,%al + +[a-f0-9]+: b8 45 03 00 00 mov \$0x345,%eax + +[a-f0-9]+: c6 c0 12 mov \$0x12,%al + +[a-f0-9]+: c7 c0 45 03 00 00 mov \$0x345,%eax + +[a-f0-9]+: 14 12 adc \$0x12,%al + +[a-f0-9]+: 15 45 03 00 00 adc \$0x345,%eax + +[a-f0-9]+: 80 d0 12 adc \$0x12,%al + +[a-f0-9]+: 81 d0 45 03 00 00 adc \$0x345,%eax + +[a-f0-9]+: 80 d0 12 adc \$0x12,%al + +[a-f0-9]+: 81 d0 45 03 00 00 adc \$0x345,%eax + +[a-f0-9]+: 04 12 add \$0x12,%al + +[a-f0-9]+: 05 45 03 00 00 add \$0x345,%eax + +[a-f0-9]+: 80 c0 12 add \$0x12,%al + +[a-f0-9]+: 81 c0 45 03 00 00 add \$0x345,%eax + +[a-f0-9]+: 80 c0 12 add \$0x12,%al + +[a-f0-9]+: 81 c0 45 03 00 00 add \$0x345,%eax + +[a-f0-9]+: 24 12 and \$0x12,%al + +[a-f0-9]+: 25 45 03 00 00 and \$0x345,%eax + +[a-f0-9]+: 80 e0 12 and \$0x12,%al + +[a-f0-9]+: 81 e0 45 03 00 00 and \$0x345,%eax + +[a-f0-9]+: 80 e0 12 and \$0x12,%al + +[a-f0-9]+: 81 e0 45 03 00 00 and \$0x345,%eax + +[a-f0-9]+: 3c 12 cmp \$0x12,%al + +[a-f0-9]+: 3d 45 03 00 00 cmp \$0x345,%eax + +[a-f0-9]+: 80 f8 12 cmp \$0x12,%al + +[a-f0-9]+: 81 f8 45 03 00 00 cmp \$0x345,%eax + +[a-f0-9]+: 3c 12 cmp \$0x12,%al + +[a-f0-9]+: 3d 45 03 00 00 cmp \$0x345,%eax + +[a-f0-9]+: 0c 12 or \$0x12,%al + +[a-f0-9]+: 0d 45 03 00 00 or \$0x345,%eax + +[a-f0-9]+: 80 c8 12 or \$0x12,%al + +[a-f0-9]+: 81 c8 45 03 00 00 or \$0x345,%eax + +[a-f0-9]+: 80 c8 12 or \$0x12,%al + +[a-f0-9]+: 81 c8 45 03 00 00 or \$0x345,%eax + +[a-f0-9]+: 1c 12 sbb \$0x12,%al + +[a-f0-9]+: 1d 45 03 00 00 sbb \$0x345,%eax + +[a-f0-9]+: 80 d8 12 sbb \$0x12,%al + +[a-f0-9]+: 81 d8 45 03 00 00 sbb \$0x345,%eax + +[a-f0-9]+: 80 d8 12 sbb \$0x12,%al + +[a-f0-9]+: 81 d8 45 03 00 00 sbb \$0x345,%eax + +[a-f0-9]+: 2c 12 sub \$0x12,%al + +[a-f0-9]+: 2d 45 03 00 00 sub \$0x345,%eax + +[a-f0-9]+: 80 e8 12 sub \$0x12,%al + +[a-f0-9]+: 81 e8 45 03 00 00 sub \$0x345,%eax + +[a-f0-9]+: 80 e8 12 sub \$0x12,%al + +[a-f0-9]+: 81 e8 45 03 00 00 sub \$0x345,%eax + +[a-f0-9]+: a8 12 test \$0x12,%al + +[a-f0-9]+: a9 45 03 00 00 test \$0x345,%eax + +[a-f0-9]+: f6 c0 12 test \$0x12,%al + +[a-f0-9]+: f7 c0 45 03 00 00 test \$0x345,%eax + +[a-f0-9]+: a8 12 test \$0x12,%al + +[a-f0-9]+: a9 45 03 00 00 test \$0x345,%eax + +[a-f0-9]+: 34 12 xor \$0x12,%al + +[a-f0-9]+: 35 45 03 00 00 xor \$0x345,%eax + +[a-f0-9]+: 80 f0 12 xor \$0x12,%al + +[a-f0-9]+: 81 f0 45 03 00 00 xor \$0x345,%eax + +[a-f0-9]+: 80 f0 12 xor \$0x12,%al + +[a-f0-9]+: 81 f0 45 03 00 00 xor \$0x345,%eax + +[a-f0-9]+: 41 inc %ecx + +[a-f0-9]+: ff c1 inc %ecx + +[a-f0-9]+: ff c1 inc %ecx + +[a-f0-9]+: 49 dec %ecx + +[a-f0-9]+: ff c9 dec %ecx + +[a-f0-9]+: ff c9 dec %ecx + +[a-f0-9]+: 51 push %ecx + +[a-f0-9]+: ff f1 push %ecx + +[a-f0-9]+: 51 push %ecx + +[a-f0-9]+: 59 pop %ecx + +[a-f0-9]+: 59 pop %ecx + +[a-f0-9]+: 8f c1 pop %ecx + +[a-f0-9]+: 0f c9 bswap %ecx + +[a-f0-9]+: 0f c9 bswap %ecx + +[a-f0-9]+: 0f c9 bswap %ecx + +[a-f0-9]+: 87 ce xchg %ecx,%esi + +[a-f0-9]+: 87 f1 xchg %esi,%ecx + +[a-f0-9]+: 87 f1 xchg %esi,%ecx + +[a-f0-9]+: 87 ce xchg %ecx,%esi + +[a-f0-9]+: 96 xchg %eax,%esi + +[a-f0-9]+: 87 f0 xchg %esi,%eax + +[a-f0-9]+: 87 c6 xchg %eax,%esi + +[a-f0-9]+: 91 xchg %eax,%ecx + +[a-f0-9]+: 87 c1 xchg %eax,%ecx + +[a-f0-9]+: 87 c8 xchg %ecx,%eax +[a-f0-9]+: d8 c0 fadd %st\(0\),%st +[a-f0-9]+: d8 c0 fadd %st\(0\),%st +[a-f0-9]+: dc c0 fadd %st,%st\(0\) --- a/gas/testsuite/gas/i386/pseudos.s +++ b/gas/testsuite/gas/i386/pseudos.s @@ -124,6 +124,34 @@ _start: {store} xor %eax, (%edi) {store} xor (%edi), %eax + .irp m, mov, adc, add, and, cmp, or, sbb, sub, test, xor + \m $0x12, %al + \m $0x345, %eax + {load} \m $0x12, %al # bogus for MOV + {load} \m $0x345, %eax # bogus for MOV + {store} \m $0x12, %al + {store} \m $0x345, %eax + .endr + + .irp m, inc, dec, push, pop, bswap + \m %ecx + {load} \m %ecx # bogus for POP + {store} \m %ecx # bogus for PUSH + .endr + + xchg %ecx, %esi + xchg %esi, %ecx + {load} xchg %ecx, %esi + {store} xchg %ecx, %esi + + xchg %eax, %esi + {load} xchg %eax, %esi + {store} xchg %eax, %esi + + xchg %ecx, %eax + {load} xchg %ecx, %eax + {store} xchg %ecx, %eax + fadd %st, %st {load} fadd %st, %st {store} fadd %st, %st --- a/gas/testsuite/gas/i386/x86-64-pseudos.d +++ b/gas/testsuite/gas/i386/x86-64-pseudos.d @@ -137,6 +137,91 @@ Disassembly of section .text: +[a-f0-9]+: 33 07 xor \(%rdi\),%eax +[a-f0-9]+: 31 07 xor %eax,\(%rdi\) +[a-f0-9]+: 33 07 xor \(%rdi\),%eax + +[a-f0-9]+: b0 12 mov \$0x12,%al + +[a-f0-9]+: b8 45 03 00 00 mov \$0x345,%eax + +[a-f0-9]+: b0 12 mov \$0x12,%al + +[a-f0-9]+: b8 45 03 00 00 mov \$0x345,%eax + +[a-f0-9]+: c6 c0 12 mov \$0x12,%al + +[a-f0-9]+: c7 c0 45 03 00 00 mov \$0x345,%eax + +[a-f0-9]+: 14 12 adc \$0x12,%al + +[a-f0-9]+: 15 45 03 00 00 adc \$0x345,%eax + +[a-f0-9]+: 80 d0 12 adc \$0x12,%al + +[a-f0-9]+: 81 d0 45 03 00 00 adc \$0x345,%eax + +[a-f0-9]+: 80 d0 12 adc \$0x12,%al + +[a-f0-9]+: 81 d0 45 03 00 00 adc \$0x345,%eax + +[a-f0-9]+: 04 12 add \$0x12,%al + +[a-f0-9]+: 05 45 03 00 00 add \$0x345,%eax + +[a-f0-9]+: 80 c0 12 add \$0x12,%al + +[a-f0-9]+: 81 c0 45 03 00 00 add \$0x345,%eax + +[a-f0-9]+: 80 c0 12 add \$0x12,%al + +[a-f0-9]+: 81 c0 45 03 00 00 add \$0x345,%eax + +[a-f0-9]+: 24 12 and \$0x12,%al + +[a-f0-9]+: 25 45 03 00 00 and \$0x345,%eax + +[a-f0-9]+: 80 e0 12 and \$0x12,%al + +[a-f0-9]+: 81 e0 45 03 00 00 and \$0x345,%eax + +[a-f0-9]+: 80 e0 12 and \$0x12,%al + +[a-f0-9]+: 81 e0 45 03 00 00 and \$0x345,%eax + +[a-f0-9]+: 3c 12 cmp \$0x12,%al + +[a-f0-9]+: 3d 45 03 00 00 cmp \$0x345,%eax + +[a-f0-9]+: 80 f8 12 cmp \$0x12,%al + +[a-f0-9]+: 81 f8 45 03 00 00 cmp \$0x345,%eax + +[a-f0-9]+: 3c 12 cmp \$0x12,%al + +[a-f0-9]+: 3d 45 03 00 00 cmp \$0x345,%eax + +[a-f0-9]+: 0c 12 or \$0x12,%al + +[a-f0-9]+: 0d 45 03 00 00 or \$0x345,%eax + +[a-f0-9]+: 80 c8 12 or \$0x12,%al + +[a-f0-9]+: 81 c8 45 03 00 00 or \$0x345,%eax + +[a-f0-9]+: 80 c8 12 or \$0x12,%al + +[a-f0-9]+: 81 c8 45 03 00 00 or \$0x345,%eax + +[a-f0-9]+: 1c 12 sbb \$0x12,%al + +[a-f0-9]+: 1d 45 03 00 00 sbb \$0x345,%eax + +[a-f0-9]+: 80 d8 12 sbb \$0x12,%al + +[a-f0-9]+: 81 d8 45 03 00 00 sbb \$0x345,%eax + +[a-f0-9]+: 80 d8 12 sbb \$0x12,%al + +[a-f0-9]+: 81 d8 45 03 00 00 sbb \$0x345,%eax + +[a-f0-9]+: 2c 12 sub \$0x12,%al + +[a-f0-9]+: 2d 45 03 00 00 sub \$0x345,%eax + +[a-f0-9]+: 80 e8 12 sub \$0x12,%al + +[a-f0-9]+: 81 e8 45 03 00 00 sub \$0x345,%eax + +[a-f0-9]+: 80 e8 12 sub \$0x12,%al + +[a-f0-9]+: 81 e8 45 03 00 00 sub \$0x345,%eax + +[a-f0-9]+: a8 12 test \$0x12,%al + +[a-f0-9]+: a9 45 03 00 00 test \$0x345,%eax + +[a-f0-9]+: f6 c0 12 test \$0x12,%al + +[a-f0-9]+: f7 c0 45 03 00 00 test \$0x345,%eax + +[a-f0-9]+: a8 12 test \$0x12,%al + +[a-f0-9]+: a9 45 03 00 00 test \$0x345,%eax + +[a-f0-9]+: 34 12 xor \$0x12,%al + +[a-f0-9]+: 35 45 03 00 00 xor \$0x345,%eax + +[a-f0-9]+: 80 f0 12 xor \$0x12,%al + +[a-f0-9]+: 81 f0 45 03 00 00 xor \$0x345,%eax + +[a-f0-9]+: 80 f0 12 xor \$0x12,%al + +[a-f0-9]+: 81 f0 45 03 00 00 xor \$0x345,%eax + +[a-f0-9]+: 48 b9 89 67 45 23 01 00 00 00 movabs \$0x123456789,%rcx + +[a-f0-9]+: 48 b9 89 67 45 23 01 00 00 00 movabs \$0x123456789,%rcx + +[a-f0-9]+: 48 b9 89 67 45 23 01 00 00 00 movabs \$0x123456789,%rcx + +[a-f0-9]+: 48 b9 78 56 34 12 00 00 00 00 movabs \$0x12345678,%rcx + +[a-f0-9]+: 48 b9 78 56 34 12 00 00 00 00 movabs \$0x12345678,%rcx + +[a-f0-9]+: 48 b9 78 56 34 12 00 00 00 00 movabs \$0x12345678,%rcx + +[a-f0-9]+: 51 push %rcx + +[a-f0-9]+: ff f1 push %rcx + +[a-f0-9]+: 51 push %rcx + +[a-f0-9]+: 59 pop %rcx + +[a-f0-9]+: 59 pop %rcx + +[a-f0-9]+: 8f c1 pop %rcx + +[a-f0-9]+: 48 0f c9 bswap %rcx + +[a-f0-9]+: 48 0f c9 bswap %rcx + +[a-f0-9]+: 48 0f c9 bswap %rcx + +[a-f0-9]+: 87 ce xchg %ecx,%esi + +[a-f0-9]+: 87 f1 xchg %esi,%ecx + +[a-f0-9]+: 87 f1 xchg %esi,%ecx + +[a-f0-9]+: 87 ce xchg %ecx,%esi + +[a-f0-9]+: 96 xchg %eax,%esi + +[a-f0-9]+: 87 f0 xchg %esi,%eax + +[a-f0-9]+: 87 c6 xchg %eax,%esi + +[a-f0-9]+: 91 xchg %eax,%ecx + +[a-f0-9]+: 87 c1 xchg %eax,%ecx + +[a-f0-9]+: 87 c8 xchg %ecx,%eax +[a-f0-9]+: d8 c0 fadd %st\(0\),%st +[a-f0-9]+: d8 c0 fadd %st\(0\),%st +[a-f0-9]+: dc c0 fadd %st,%st\(0\) --- a/gas/testsuite/gas/i386/x86-64-pseudos.s +++ b/gas/testsuite/gas/i386/x86-64-pseudos.s @@ -135,6 +135,42 @@ _start: {store} xor %eax, (%rdi) {store} xor (%rdi), %eax + .irp m, mov, adc, add, and, cmp, or, sbb, sub, test, xor + \m $0x12, %al + \m $0x345, %eax + {load} \m $0x12, %al # bogus for MOV + {load} \m $0x345, %eax # bogus for MOV + {store} \m $0x12, %al + {store} \m $0x345, %eax + .endr + + # There should be no effect of the pseudo-prefixes on any of these. + mov $0x123456789, %rcx + {load} mov $0x123456789, %rcx + {store} mov $0x123456789, %rcx + movabs $0x12345678, %rcx + {load} movabs $0x12345678, %rcx + {store} movabs $0x12345678, %rcx + + .irp m, push, pop, bswap + \m %rcx + {load} \m %rcx # bogus for POP + {store} \m %rcx # bogus for PUSH + .endr + + xchg %ecx, %esi + xchg %esi, %ecx + {load} xchg %ecx, %esi + {store} xchg %ecx, %esi + + xchg %eax, %esi + {load} xchg %eax, %esi + {store} xchg %eax, %esi + + xchg %ecx, %eax + {load} xchg %ecx, %eax + {store} xchg %ecx, %eax + fadd %st, %st {load} fadd %st, %st {store} fadd %st, %st