From patchwork Mon May 20 06:22:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Cui, Lili" X-Patchwork-Id: 90434 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 375683858C5F for ; Mon, 20 May 2024 06:22:44 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) by sourceware.org (Postfix) with ESMTPS id E42A63858D33 for ; Mon, 20 May 2024 06:22:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E42A63858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=intel.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E42A63858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716186127; cv=none; b=H5zuOeGu8Xrn2TgtKF/TPq/bCMFdyZYtS59n/6wKsk2YM+U+htDk3p+evxI+ECRSaoNOOUMfg7BuR8fIx37oe3zWdrNWvn76RIEloOc+J8PvGMVSSNUT28uuBI4WST4DJgEsJEYTrxLE9dkIYHh9SxNfPdBbwvEQgmR0VPDCKDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716186127; c=relaxed/simple; bh=yqrT9pafZBSbf60ttAudC1eSdTv9iwo0d9HRo4aKLwc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=ep8OAdV/jjn+I6jaBMULcENwND7D+eU/PwQE2+pcn9D6rXMvSBYhQA8FEWzBH2otFPBbizo8rIMlBOFfXet0cLKHFmMHjRw/TjhkUMT4ihg+E+q/ln2ZvB3adl1kquPI7J3uMqvzD9ENuHp5OQ+Gncz+NjR45RORMmnom0UF9/8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716186126; x=1747722126; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yqrT9pafZBSbf60ttAudC1eSdTv9iwo0d9HRo4aKLwc=; b=XFboafJqO7FhmvDuZpxsKn7bUtNaHiQ9furNZ407xfyeZMxR2XJQoAz+ NcKNNMEZVBP5IkAQM18FIjeLH14P1en8mvHGaaKbeAy023tCIeJZ25/El B8IQ8VFhA33MwnLXXSPT6XYDIeSogiXXZ43aFxVMLpTDoR59MrFtiUB0K OuIjb45W7Ud4TNdO2lm4HR1dAM5sQHRgovQ4MJ3oJFkbG086pCCcBLAcB hKUQjlJeKTWM05n6hNSh/BxKgZugInefMnWDSHVxNwrHrqSCGS943TAeR 3z3ZmKSVW0towMlBxaj9uVIHOGQqGvN6qbQY78QRkyL3YVnCpXOpMq7W7 Q==; X-CSE-ConnectionGUID: 6fUDElOqSQ2wSyOH8xilIw== X-CSE-MsgGUID: CGXVTor2Q5ir7Tpjs3/nbg== X-IronPort-AV: E=McAfee;i="6600,9927,11077"; a="12138694" X-IronPort-AV: E=Sophos;i="6.08,174,1712646000"; d="scan'208";a="12138694" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 May 2024 23:22:05 -0700 X-CSE-ConnectionGUID: RdYmIbM0QB2o/CAhj7YsDw== X-CSE-MsgGUID: rM7rPpHQTNG3bWPhRl0CMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,174,1712646000"; d="scan'208";a="37001264" Received: from scymds04.sc.intel.com ([10.82.73.238]) by fmviesa004.fm.intel.com with ESMTP; 19 May 2024 23:22:05 -0700 Received: from shgcc10.sh.intel.com (unknown [10.239.85.189]) by scymds04.sc.intel.com (Postfix) with ESMTP id 1F8272003A60; Sun, 19 May 2024 23:22:03 -0700 (PDT) From: "Cui, Lili" To: binutils@sourceware.org Cc: hjl.tools@gmail.com, jbeulich@suse.com Subject: [PATCH 1/3] x86: Split REX/REX2 old registers judgment. Date: Mon, 20 May 2024 14:22:00 +0800 Message-Id: <20240520062202.1297234-2-lili.cui@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240520062202.1297234-1-lili.cui@intel.com> References: <20240520062202.1297234-1-lili.cui@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 Split "REX/REX2 old register checking" and "add empty rex prefix" into two separate branches. gas/ChangeLog: * config/tc-i386.c (establish_rex): Split the judgments. --- gas/config/tc-i386.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/gas/config/tc-i386.c b/gas/config/tc-i386.c index 339e849a971..2fbd90bedb8 100644 --- a/gas/config/tc-i386.c +++ b/gas/config/tc-i386.c @@ -4303,22 +4303,20 @@ static void establish_rex (void) /* Respect a user-specified REX prefix. */ i.rex |= i.prefix[REX_PREFIX] & REX_OPCODE; - /* For 8 bit registers we need an empty rex prefix. Also if the - instruction already has a prefix, we need to convert old - registers to new ones. */ - - if ((i.types[first].bitfield.class == Reg && i.types[first].bitfield.byte - && ((i.op[first].regs->reg_flags & RegRex64) != 0 || i.rex != 0 - || i.rex2 != 0)) - || (i.types[last].bitfield.class == Reg && i.types[last].bitfield.byte - && ((i.op[last].regs->reg_flags & RegRex64) != 0 || i.rex != 0 - || i.rex2 != 0))) - { - unsigned int x; - - if (!is_apx_rex2_encoding () && !is_any_vex_encoding(&i.tm)) - i.rex |= REX_OPCODE; - for (x = first; x <= last; x++) + /* For 8 bit registers without a prefix, we need an empty rex prefix. */ + if (((i.types[first].bitfield.class == Reg && i.types[first].bitfield.byte + && ((i.op[first].regs->reg_flags & RegRex64) != 0 )) + || (i.types[last].bitfield.class == Reg && i.types[last].bitfield.byte + && (i.op[last].regs->reg_flags & RegRex64) != 0 )) + && !is_apx_rex2_encoding () && !is_any_vex_encoding (&i.tm) && !i.rex) + i.rex |= REX_OPCODE; + + /* For REX/REX2 prefix instructions, we need to convert old registers + (AL, CL, DL and BL) to new ones (AXL, CXL, DXL and BXL) and report bad + for AH, CH, DH and BH. */ + if (i.rex || i.rex2) + { + for (unsigned int x = first; x <= last; x++) { /* Look for 8 bit operand that uses old registers. */ if (i.types[x].bitfield.class == Reg && i.types[x].bitfield.byte