From patchwork Fri Mar 3 12:57:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 63887 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp392183wrd; Fri, 3 Mar 2023 04:57:35 -0800 (PST) X-Google-Smtp-Source: AK7set8Duq3k2eBI0t85PiRmn8h6Wk85DGr0vF5OckQnJqGMUt/FQUTzT3UJKNSwRbmwqpAUQR9U X-Received: by 2002:a17:906:a412:b0:87b:59d9:5a03 with SMTP id l18-20020a170906a41200b0087b59d95a03mr1481488ejz.36.1677848255804; Fri, 03 Mar 2023 04:57:35 -0800 (PST) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ca24-20020aa7cd78000000b004ad021e0d95si2696708edb.25.2023.03.03.04.57.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 04:57:35 -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=Y4k3+dDa; 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 C354F38582B7 for ; Fri, 3 Mar 2023 12:57:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C354F38582B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1677848254; bh=dThZhXr5+rjvX6aNSDUubbjZgiMihqflt8DYYp89t6A=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Y4k3+dDaiiZlrK7rROsRm+sDcD5kngO6ie3kyqnGj/idAGV3yIbRIPoF58LWhLk50 UCCUC46MhCZc2qvJ2k7x5RRJKvBItRllCELSfM14XuEbmMnFwmNXcvBF5n0Fl+V8pK nPifmLCzrKN9wQw+LJ+J9EeoYiq1hEosSH9A3Kxc= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2084.outbound.protection.outlook.com [40.107.14.84]) by sourceware.org (Postfix) with ESMTPS id C9435385842A for ; Fri, 3 Mar 2023 12:57:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9435385842A ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Rr7DyWqmTKiIKOtpa00D2l42R8BkgI+tVZX0nTbJV+S9OWcy0I85Dkk4M7L7RZpklhPkS8pv6Sj/bDkzx2vVCDuPetLmrgfSFqIG5nb2E4vYCq5H9xXimPXENcVT9klsy85AI287B0vKZ7v/SJFxpfX+t3son0vP+AKVvfWTkikgj7K3g1WzNHBuWhFCoX2q6Ci0XH8hoczF43aeaT3rwDUct68n0pDnfiiD+WrA6QJ+gMVjuwLKDMTdldTGFF3PvyacMyy3Ep/ONwXT+EPko8BR8sCUFegXGjAd5lXLCuFHQuN4HyA2QSaUuIHx+cGAI2o3C3eRkzOvX5jdq8ka+g== 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=dThZhXr5+rjvX6aNSDUubbjZgiMihqflt8DYYp89t6A=; b=j4bdiF8aGFRag52a34YZOZE9rPqjIy9NwyUgyHpteKh9jFEOBr/2BaXkhow+kb/amSMDhrx+Hbd8ldYOa9RjzzZEh5rDsbBkhQZ1oZkKALvhEdQ2EMJHOz4VaGtg8LEsAG7GtBU6nkSBaZU/WcOCcyKmPNTBBqF8ki6oejb14n0xoEuunl+dLFJOscMLi0IU2j+9M6hOoIICAhis5dTbk5/SL+OkzS0g57NLGVEbL+6l3TqtvUHFEzYOMFPz2PVqptZf/Bni5Q27qAPJ3AN6dXJSwlCPx1lSVR6BOYCaxej0KQjptPDhmCWoe6n2RYegeR+H6ZJEToDbygbKIDYleg== 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 PA4PR04MB7725.eurprd04.prod.outlook.com (2603:10a6:102:f1::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.18; Fri, 3 Mar 2023 12:57:02 +0000 Received: from VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b]) by VE1PR04MB6560.eurprd04.prod.outlook.com ([fe80::154e:166d:ec25:531b%7]) with mapi id 15.20.6156.019; Fri, 3 Mar 2023 12:57:02 +0000 Message-ID: <3bab7c05-755b-f494-8d7a-0183ab14563a@suse.com> Date: Fri, 3 Mar 2023 13:57:00 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: [PATCH 02/18] x86: parse VEX and alike specifiers for .insn Content-Language: en-US To: Binutils Cc: "H.J. Lu" , "Jiang, Haochen" References: <764b9e03-18bd-6945-692f-a250522196ca@suse.com> In-Reply-To: <764b9e03-18bd-6945-692f-a250522196ca@suse.com> X-ClientProxiedBy: FR3P281CA0023.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1c::7) To VE1PR04MB6560.eurprd04.prod.outlook.com (2603:10a6:803:122::25) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VE1PR04MB6560:EE_|PA4PR04MB7725:EE_ X-MS-Office365-Filtering-Correlation-Id: 01879e92-ef9b-4bd7-2a90-08db1be6c8a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HKjsZMnATcnXv6LhYxx01qeA0AXH1dmzUTK6NVroY4F2nKxqb8KmuWydipLK2pkYfgts+UQiecZvmFw0XKPouR4U32oKxBGCSJ/aiiXvJAcmca+z1mo/qNSshhNbqGvS74RUVhD16W20121vHp2KoUlCH+OozdMlp35O8aYpbEEY+/DCr9T/BhrJ92u9tfi2Mf3ywR2cq3iu1UP6Q/O4CAuPyHv2yVmkvwPyLiVlK28bYpo2cEA5ISutZVtJxhsJoKydwROqS+qbAhG0HUHGl6LJgD0lsutYPd/hJpqQZm6UIjhWi2jd41Dt6CTYg7e8LHm2jTQackpXJVJ810AftA80m1+5IXLVRBynKA5tPaR2MqCkc+GI95pZ4RkZFD3DXsPgsFaAy8Zu/kxfGHxvHz6wCyNBx5pNZLq2IHkf+0Gil2jkElJ2dHR2m9irAHswl9zB9eleHP5OftlmE5SlrgcMDYCapYZXDDhOxhJVMHigLuN0EER3A4X/WJ0vWbZ8E8ehLVqhp7lRqLcAAPWYYlb9T1l0WFWUDtUg5j9nXKveBag+QsWMRh4Vp1J7ZUplDqoYx2UJid5N/pDzpiycUjv3pBLEjYH8bOmaCKsN3KcUZdGtfuOnW5Z8QFzsRMgV3Tb33Nn5ya2mMGBwKjtsVT9ihLeacyRwpKGVM7xHZ2R9Zqa82MOw5Jz7UtEP2oaopFyYvxbtaZ+0MRqeQeBRq8YxM0MuBReSABMMf6ukwt4VNVfjuYMeEU3EwQBae+tQ 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)(39860400002)(346002)(396003)(136003)(366004)(451199018)(31686004)(66946007)(86362001)(31696002)(66476007)(66556008)(8936002)(6916009)(5660300002)(8676002)(2906002)(41300700001)(4326008)(38100700002)(36756003)(54906003)(6486002)(316002)(478600001)(83380400001)(6512007)(6506007)(26005)(2616005)(186003)(142923001)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?b8A2aX/OlEE8SD2AV02VhhLzaGTI?= =?utf-8?q?egjkVFv0Iv05RBo4vmiURoV+GUyhC6otz5A5C9WKQMllKp0GvjzL83XZNbkoYxW1v?= =?utf-8?q?ySMXmvuBha4JBUJyKFYNMGl2DYk8XmcnoW17quffACf+7Z8/u8qcBa4qwxm9xy424?= =?utf-8?q?9246fconByqtdHgfUP2gDyuv+0JV/+d9wKP1KKhr1/K7+HGs8Snjmv19uCHEc4BuC?= =?utf-8?q?LSKwWkuQQwjgJSDwEivCYurj2pDxHOXbEKknzxKEnNdl6EVdkI66bORzgGZ5OB4nc?= =?utf-8?q?6UuVOn1lSVwokZBroDP8XWPhNHPpP6muk+8eEvfzb/HAG4uZeTgeV5bQtjXUK7xXd?= =?utf-8?q?7D2ZojcCZ0an6RJ676l7lKbSlvIVguchw8k2o+j3ZLvPfncWhr/l3QvIywvx6xeHJ?= =?utf-8?q?XbnOer84SXdtxErtp81b+vX6aM/zEF3RwFZKGYZisucQrL4gozxbqDC1F3pbq8qvm?= =?utf-8?q?9AgYPp5185bkBI7Q924l1d6Odb3Veicp8OrxIpamZttIaLnCvao2YM1d7GpAT6pK1?= =?utf-8?q?ZDZ1tDGE3NEeaHnBF9rTP+ey2cEcrGR2MIZorvRUpQ4QA1uBLfrTWTpVYlBc9t80b?= =?utf-8?q?HMhP0dCvonmHXb4f2GNkeT86U/yTS4Tt30YP2hGbiQ57r9yRVEUF99YwGNXJyfNvN?= =?utf-8?q?lZjBh5dVn15dZo+DaCLH/Z3FyA5qVwiNJO+lwJZfv4KkSKdW/6u1Iu4zG9LKxSuP8?= =?utf-8?q?uDs5M4d66XnatRe2dMoDaR2J7IvBD0bixObhb7ckoU1tSoqY2fKwgHPGWdVXsfpDM?= =?utf-8?q?Lq6VhejeBOpGcTmxXmOJ9dOydGmmeGbuFyjY/vG2O5Q1317qtqNsGRRHnJmET2BGZ?= =?utf-8?q?9p1PDtfvuCYSgDd4hxVFqq7yBCGvGaYhB9QT0Mimwi4HTK23KXvH9wvr8tff7rP4q?= =?utf-8?q?AXiAwnlsKbjVFqq5hSQm/QSC1FMo7ZR1bNWVcBd1aJfwBHu6r2noGrcQ8oJuPQbF8?= =?utf-8?q?mqvrzgMebzPQyZIFM0f5SsZ8yLtbxPs2zTBFa/NFf8Ug+lyEbGwOkS2S38wyWzOqN?= =?utf-8?q?O98ES5py7FUxRIwQ7iEuc4Y+jILbIG7sMLIcDb06bceQJqynHLdbdRxLJagzKzGYE?= =?utf-8?q?Ly61FflWYrGrqDzWkFURbqOCw7wYTlLzbFT1qLEqgiz1PPKSueZuMb6m6jFHy64/d?= =?utf-8?q?Mlg59nhNZOqDKzzGCb9/LmHXTS1eVGUE+A+vg3WqnH7YAgZeiFhVc50SGF/rzJXIJ?= =?utf-8?q?XcUawYwApH+o5Oj6hGax+jh6lwcgQKtzm9w3eZJn8ikGiiaUD1eb9+C2UZTTPPTQf?= =?utf-8?q?NuOamr7HP9wi3Q3mkmB4XGFwpJMB0mjIgQYFwZtnA7EAl7V2/KfFvxXpnN9X6bZ+C?= =?utf-8?q?6jNKnEHrfN9O9zUVyVXpFP88Ht+8Y/VnDYxZAU0LfERnpS1TKE8Y5q3xzlkFukVn1?= =?utf-8?q?zBKBPKLYqjGosgyBqhmHfKU2phgE/Ulo4XN/wxdXC4s7BVzLnM1ABaT6DROuu8olL?= =?utf-8?q?ZdvBXAOLqP00OTu9eeHE6vaDNZvwujJ09PlS8PZUbDYOKzVnouf4jI6wd3Efmko+n?= =?utf-8?q?PFXzWr6NE2wC?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01879e92-ef9b-4bd7-2a90-08db1be6c8a2 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6560.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2023 12:57:02.6806 (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: CbDg8Y3YMt8vhHB2t3Ntbszn4kJAyf0kqrK3KR2icTa17oNzecg8MX/qTXTnr/G6YnKqKx4Xf4Xs4UH+m468Pg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA4PR04MB7725 X-Spam-Status: No, score=-3028.3 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?1759351412595770559?= X-GMAIL-MSGID: =?utf-8?q?1759351412595770559?= All encoding spaces can be used this way; there's a certain risk that the bits presently reserved could be used for other purposes down the road, but people using .insn are expected to know what they're doing anyway. Plus this way there's at least _some_ way to have those bits set. For now this will only allow operand-less insns to be encoded this way. --- For now only numeric parts of the specifiers are handled in a case- insensitive manner. All other parts have to use upper case letters. --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -307,6 +307,9 @@ struct _i386_insn unsigned int prefixes; unsigned char prefix[MAX_PREFIXES]; + /* .insn allows for reserved opcode spaces. */ + unsigned char insn_opcode_space; + /* Register is in low 3 bits of opcode. */ bool short_form; @@ -568,6 +571,9 @@ static expressionS im_expressions[MAX_IM /* Current operand we are working on. */ static int this_operand = -1; +/* Are we processing a .insn directive? */ +#define dot_insn() (i.tm.mnem_off == MN__insn) + /* We support four different modes. FLAG_CODE variable is used to distinguish these. */ @@ -3648,6 +3654,8 @@ build_vex_prefix (const insn_template *t vector_length = avxscalar; else if (i.tm.opcode_modifier.vex == VEX256) vector_length = 1; + else if (dot_insn () && i.tm.opcode_modifier.vex == VEX128) + vector_length = 0; else { unsigned int op; @@ -3715,7 +3723,9 @@ build_vex_prefix (const insn_template *t /* The high 3 bits of the second VEX byte are 1's compliment of RXB bits from REX. */ - i.vex.bytes[1] = (~i.rex & 0x7) << 5 | i.tm.opcode_space; + i.vex.bytes[1] = ((~i.rex & 7) << 5) + | (!dot_insn () ? i.tm.opcode_space + : i.insn_opcode_space); i.vex.bytes[2] = (w << 7 | register_specifier << 3 @@ -3852,7 +3862,9 @@ build_evex_prefix (void) bits from REX. */ gas_assert (i.tm.opcode_space >= SPACE_0F); gas_assert (i.tm.opcode_space <= SPACE_EVEXMAP6); - i.vex.bytes[1] = (~i.rex & 0x7) << 5 | i.tm.opcode_space; + i.vex.bytes[1] = ((~i.rex & 7) << 5) + | (!dot_insn () ? i.tm.opcode_space + : i.insn_opcode_space); /* The fifth bit of the second EVEX byte is 1's compliment of the REX_R bit in VREX. */ @@ -3968,6 +3980,13 @@ build_evex_prefix (void) case EVEX512: vec_length = 2 << 5; break; + case EVEX_L3: + if (dot_insn ()) + { + vec_length = 3 << 5; + break; + } + /* Fall through. */ default: abort (); break; @@ -10739,6 +10758,7 @@ s_insn (int dummy ATTRIBUTE_UNUSED) bad: *saved_ilp = saved_char; ignore_rest_of_line (); + i.tm.mnem_off = 0; return; } line += end - line; @@ -10761,6 +10781,9 @@ s_insn (int dummy ATTRIBUTE_UNUSED) && (*e == '.' || is_space_char (*e))) { xop = true; + /* Arrange for build_vex_prefix() to emit 0x8f. */ + i.tm.opcode_space = SPACE_XOP08; + i.insn_opcode_space = n; line = e; } } @@ -10784,6 +10807,188 @@ s_insn (int dummy ATTRIBUTE_UNUSED) if (line > end && *line == '.') { + /* Length specifier (VEX.L, XOP.L, EVEX.L'L). */ + switch (line[1]) + { + case 'L': + switch (line[2]) + { + case '0': + if (evex) + i.tm.opcode_modifier.evex = EVEX128; + else + i.tm.opcode_modifier.vex = VEX128; + break; + + case '1': + if (evex) + i.tm.opcode_modifier.evex = EVEX256; + else + i.tm.opcode_modifier.vex = VEX256; + break; + + case '2': + if (evex) + i.tm.opcode_modifier.evex = EVEX512; + break; + + case '3': + if (evex) + i.tm.opcode_modifier.evex = EVEX_L3; + break; + + case 'I': + if (line[3] == 'G') + { + if (evex) + i.tm.opcode_modifier.evex = EVEXLIG; + else + i.tm.opcode_modifier.vex = VEXScalar; /* LIG */ + ++line; + } + break; + } + + if (i.tm.opcode_modifier.vex || i.tm.opcode_modifier.evex) + line += 3; + break; + + case '1': + if (line[2] == '2' && line[3] == '8') + { + if (evex) + i.tm.opcode_modifier.evex = EVEX128; + else + i.tm.opcode_modifier.vex = VEX128; + line += 4; + } + break; + + case '2': + if (line[2] == '5' && line[3] == '6') + { + if (evex) + i.tm.opcode_modifier.evex = EVEX256; + else + i.tm.opcode_modifier.vex = VEX256; + line += 4; + } + break; + + case '5': + if (evex && line[2] == '1' && line[3] == '2') + { + i.tm.opcode_modifier.evex = EVEX512; + line += 4; + } + break; + } + } + + if (line > end && *line == '.') + { + /* embedded prefix (VEX.pp, XOP.pp, EVEX.pp). */ + switch (line[1]) + { + case 'N': + if (line[2] == 'P') + line += 3; + break; + + case '6': + if (line[2] == '6') + { + i.tm.opcode_modifier.opcodeprefix = PREFIX_0X66; + line += 3; + } + break; + + case 'F': case 'f': + if (line[2] == '3') + { + i.tm.opcode_modifier.opcodeprefix = PREFIX_0XF3; + line += 3; + } + else if (line[2] == '2') + { + i.tm.opcode_modifier.opcodeprefix = PREFIX_0XF2; + line += 3; + } + break; + } + } + + if (line > end && !xop && *line == '.') + { + /* Encoding space (VEX.mmmmm, EVEX.mmmm). */ + switch (line[1]) + { + case '0': + if (TOUPPER (line[2]) != 'F') + break; + if (line[3] == '.' || is_space_char (line[3])) + { + i.insn_opcode_space = SPACE_0F; + line += 3; + } + else if (line[3] == '3' + && (line[4] == '8' || TOUPPER (line[4]) == 'A') + && (line[5] == '.' || is_space_char (line[5]))) + { + i.insn_opcode_space = line[4] == '8' ? SPACE_0F38 : SPACE_0F3A; + line += 5; + } + break; + + case 'M': + if (ISDIGIT (line[2]) && line[2] != '0') + { + char *e; + unsigned long n = strtoul (line + 2, &e, 10); + + if (n <= (evex ? 15 : 31) + && (*e == '.' || is_space_char (*e))) + { + i.insn_opcode_space = n; + line = e; + } + } + break; + } + } + + if (line > end && *line == '.' && line[1] == 'W') + { + /* VEX.W, XOP.W, EVEX.W */ + switch (line[2]) + { + case '0': + i.tm.opcode_modifier.vexw = VEXW0; + break; + + case '1': + i.tm.opcode_modifier.vexw = VEXW1; + break; + + case 'I': + if (line[3] == 'G') + { + i.tm.opcode_modifier.vexw = VEXWIG; + ++line; + } + break; + } + + if (i.tm.opcode_modifier.vexw) + line += 3; + } + + if (line > end && *line && !is_space_char (*line)) + { + /* Improve diagnostic a little. */ + if (*line == '.' && line[1] && !is_space_char (line[1])) + ++line; + goto done; } input_line_pointer = line; @@ -10812,24 +11017,30 @@ s_insn (int dummy ATTRIBUTE_UNUSED) } /* Trim off encoding space. */ - if (j > 1 && !i.tm.opcode_space && (val >> ((j - 1) * 8)) == 0x0f) + if (j > 1 && !i.insn_opcode_space && (val >> ((j - 1) * 8)) == 0x0f) { uint8_t byte = val >> ((--j - 1) * 8); - i.tm.opcode_space = SPACE_0F; + i.insn_opcode_space = SPACE_0F; switch (byte & -(j > 1)) { case 0x38: - i.tm.opcode_space = SPACE_0F38; + i.insn_opcode_space = SPACE_0F38; --j; break; case 0x3a: - i.tm.opcode_space = SPACE_0F3A; + i.insn_opcode_space = SPACE_0F3A; --j; break; } + i.tm.opcode_space = i.insn_opcode_space; val &= ((uint64_t)1 << (j * 8)) - 1; } + if (!i.tm.opcode_space && (vex || evex)) + /* Arrange for build_vex_prefix() to properly emit 0xC4/0xC5. + Also avoid hitting abort() there or in build_evex_prefix(). */ + i.tm.opcode_space = i.insn_opcode_space == SPACE_0F ? SPACE_0F + : SPACE_0F38; if (j > 2) { @@ -10839,12 +11050,33 @@ s_insn (int dummy ATTRIBUTE_UNUSED) i.opcode_length = j; i.tm.base_opcode = val; + if (vex || xop) + { + if (!i.tm.opcode_modifier.vex) + i.tm.opcode_modifier.vex = VEXScalar; /* LIG */ + + build_vex_prefix (NULL); + i.rex &= REX_OPCODE; + } + else if (evex) + { + if (!i.tm.opcode_modifier.evex) + i.tm.opcode_modifier.evex = EVEXLIG; + + build_evex_prefix (); + i.rex &= REX_OPCODE; + } + output_insn (); + done: *saved_ilp = saved_char; input_line_pointer = line; demand_empty_rest_of_line (); + + /* Make sure dot_insn() won't yield "true" anymore. */ + i.tm.mnem_off = 0; } #ifdef TE_PE --- a/gas/testsuite/gas/i386/insn-32.d +++ b/gas/testsuite/gas/i386/insn-32.d @@ -11,4 +11,6 @@ Disassembly of section .text: [ ]*[a-f0-9]+: f3 90[ ]+pause [ ]*[a-f0-9]+: d9 ee[ ]+fldz [ ]*[a-f0-9]+: f3 0f 01 e8[ ]+setssbsy +[ ]*[a-f0-9]+: c5 fc 77[ ]+vzeroall +[ ]*[a-f0-9]+: c4 e1 7c 77[ ]+vzeroall #pass --- a/gas/testsuite/gas/i386/insn-32.s +++ b/gas/testsuite/gas/i386/insn-32.s @@ -12,3 +12,7 @@ insn: # setssbsy .insn 0xf30f01e8 + + # vzeroall + .insn VEX.256.0F.WIG 0x77 + .insn {vex3} VEX.L1 0x0f77 --- a/gas/testsuite/gas/i386/insn-64.d +++ b/gas/testsuite/gas/i386/insn-64.d @@ -11,4 +11,6 @@ Disassembly of section .text: [ ]*[a-f0-9]+: f3 90[ ]+pause [ ]*[a-f0-9]+: d9 ee[ ]+fldz [ ]*[a-f0-9]+: f3 0f 01 e8[ ]+setssbsy +[ ]*[a-f0-9]+: c5 fc 77[ ]+vzeroall +[ ]*[a-f0-9]+: c4 e1 7c 77[ ]+vzeroall #pass --- a/gas/testsuite/gas/i386/insn-64.s +++ b/gas/testsuite/gas/i386/insn-64.s @@ -12,3 +12,7 @@ insn: # setssbsy .insn 0xf30f01e8 + + # vzeroall + .insn VEX.256.0F.WIG 0x77 + .insn {vex3} VEX.L1 0x0f77 --- a/opcodes/i386-opc.h +++ b/opcodes/i386-opc.h @@ -643,12 +643,14 @@ enum 3: 256bit EVEX prefix. 4: Length-ignored (LIG) EVEX prefix. 5: Length determined from actual operands. + 6: L'L = 3 (reserved, .insn only) */ #define EVEX512 1 #define EVEX128 2 #define EVEX256 3 #define EVEXLIG 4 #define EVEXDYN 5 +#define EVEX_L3 6 EVex, /* AVX512 masking support: