From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by sourceware.org (Postfix) with ESMTPS id A55833858C20 for ; Tue, 23 Jan 2024 10:15:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A55833858C20 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 A55833858C20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::231 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706004915; cv=none; b=I0i3dVR+BGS3XEypkZFpXfo+Ytf97gq4TCKII4CH6GqqknCaqQ+iy9QZ85qchcnLRLcRqxVx7STzi/BwhlISoa/GnoWeYQlY+LDJQoM46s+9oTKA2gnJtMTvzlFYANCHs6Tf3UXAORfVTqdfYsu3jW9cO8maPb8RwjYjaM11elI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706004915; c=relaxed/simple; bh=FI+zt71mtSS4EK5ANK1QHMrEVYxEbd4R+PkxQhqLRFE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=ag2OcZGspgpuAYyMYVd1fYDnr1o0LFrmJBHUVUfZHX0qhVDmnKHNabXo90AbgNkReP/y3k/X8sLxYKt5yQM8izhj/fPJfGerpFxE3NweCskw8B9uH5WbkXWZdBeROyBi8dUC+KfKZtLRBmLwI8InQhT7TozU2coa0NfMsr5FRSw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2cdb50d8982so46901201fa.2 for ; Tue, 23 Jan 2024 02:15:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1706004911; x=1706609711; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:cc:references :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=MDc2YGf8fXcO2Ok1B3sLiDPkz3b1SCGhz/kJzQd7FaI=; b=KIp+mtqKHyYT+u6R35MBerV9/GzMgwk2za1Juq33Vf7cMLsZk0waAWBw0hKp7hUanV 3mvQAA0RJugyxvwbncfhvtll8PRgqn9vfjfHvQh5digbXreNXn+Zx6W3B6QNz0tm0v1m PxCoGQS3P9NForGkoJv6wtYkCBdBPA5TwNVjC7nUo0PPUamqDiit8fJYmWig3zAEhOt6 ASJiMzG71jON87DdyCGkCTfTbOn+0cp7VNKnE0znLaJa0zq46cvwrBAPHI1rT34dTozX KfUch4nbanMJZIEAHEgiWS97K/nK5exrtpWGq87vi7OeN7fKv5YomTUFQ7DJhsN07E5p w2lA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706004911; x=1706609711; h=content-transfer-encoding:in-reply-to:autocrypt:from:cc:references :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MDc2YGf8fXcO2Ok1B3sLiDPkz3b1SCGhz/kJzQd7FaI=; b=cnRyHUOUzc11bR7BV8h518rloGtKskw5WFx5FRV6ADAGoxmt1Xgp7hEfyiKsz6mwXT O1NljfrvFbaQuIreI3+QdJy+ACgNiYTOmwJIqxjATMHJbXXRkl47DqCEwzk0adZGTgBj v16o3P/gP5oJA0ej78iqjS4woQx3uioEreVz3498dywsyhxdSLCPIOcP58tcncXv8joW gYMGppzxRw29f0Ep1NWp0B02qE5JCY4lTpXQCKSfUtc1RjzXcGhNfvn70SU14CtkS+dQ 57L3U9gn2XIGwJvbh7gnV+ecBGvqVk4tGcQyql7v56O9utmsETTfXFs6es02tF5xNohL JU4Q== X-Gm-Message-State: AOJu0Yy+EWvrJGIY9yuDsKtJ6QnllH2augfA1pWJ/W1zKBXTArR57dZF tHFGiI/J98SkJHSE1HHxFONrfSw5sby4fvnABzgzY4qAMUDXNuJ8/i4R+7JiuCdzv081U0VVgIA = X-Google-Smtp-Source: AGHT+IFsGxYyWUrgc2lfv1r6TzsohQNT4laW8+k4N8CBFkc+4iNbvVwXitDFhW8ztwnXhKetXuvKVA== X-Received: by 2002:a2e:8415:0:b0:2cd:fa9b:a584 with SMTP id z21-20020a2e8415000000b002cdfa9ba584mr2360436ljg.90.1706004911144; Tue, 23 Jan 2024 02:15:11 -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 h12-20020a92c26c000000b003629046b337sm75702ild.80.2024.01.23.02.15.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jan 2024 02:15:10 -0800 (PST) Message-ID: <0156c3fa-61a0-4e93-ac20-b3fcc8f4a279@suse.com> Date: Tue, 23 Jan 2024 11:15:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] gas: x86: ginsn: adjust ginsns for certain lea ops Content-Language: en-US To: Indu Bhagat References: <20240123093855.3617792-1-indu.bhagat@oracle.com> Cc: binutils@sourceware.org From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5Cl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AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <20240123093855.3617792-1-indu.bhagat@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3025.7 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 List-Id: On 23.01.2024 10:38, Indu Bhagat wrote: > @@ -5678,47 +5680,7 @@ x86_ginsn_lea (const symbolS *insn_end_sym) > GINSN_SRC_IMM, 0xf /* arbitrary const. */, 0, > GINSN_DST_REG, dst_reg, 0); > } > - else if (i.base_reg && !i.index_reg) > - { > - /* lea -0x2(%base),%dst. */ > - base_reg = ginsn_dw2_regnum (i.base_reg); > - dst_reg = ginsn_dw2_regnum (i.op[1].regs); > - > - if (i.disp_operands) > - src_disp = i.op[0].disps->X_add_number; > - > - if (src_disp) > - /* Generate an ADD ginsn. */ > - ginsn = ginsn_new_add (insn_end_sym, true, > - GINSN_SRC_REG, base_reg, 0, > - GINSN_SRC_IMM, 0, src_disp, > - GINSN_DST_REG, dst_reg, 0); > - else > - /* Generate a MOV ginsn. */ > - ginsn = ginsn_new_mov (insn_end_sym, true, > - GINSN_SRC_REG, base_reg, 0, > - GINSN_DST_REG, dst_reg, 0); > - } > - else if (!i.base_reg && i.index_reg) > - { > - /* lea (,%index,imm), %dst. */ > - /* TBD_GINSN_INFO_LOSS - There is no explicit ginsn multiply operation, > - instead use GINSN_TYPE_OTHER. Also, note that info about displacement > - is not carried forward either. But this is fine because > - GINSN_TYPE_OTHER will cause SCFI pass to bail out any which way if > - dest reg is interesting. */ > - index_scale = i.log2_scale_factor; > - index_reg = ginsn_dw2_regnum (i.index_reg); > - dst_reg = ginsn_dw2_regnum (i.op[1].regs); > - ginsn = ginsn_new_other (insn_end_sym, true, > - GINSN_SRC_REG, index_reg, > - GINSN_SRC_IMM, index_scale, > - GINSN_DST_REG, dst_reg); > - /* FIXME - It seems to make sense to represent a scale factor of 1 > - correctly here (i.e. not as "other", but rather similar to the > - base-without- index case above)? */ > - } > - else > + else if (i.index_reg && i.base_reg) > { > /* lea disp(%base,%index,imm) %dst. */ > /* TBD_GINSN_INFO_LOSS - Skip adding information about the disp and imm > @@ -5732,6 +5694,50 @@ x86_ginsn_lea (const symbolS *insn_end_sym) > GINSN_SRC_REG, index_reg, > GINSN_DST_REG, dst_reg); > } > + else > + { > + /* lea disp(%base) %dst or lea disp(,%index,imm) %dst. */ > + gas_assert ((i.base_reg && !i.index_reg) > + || (!i.base_reg && i.index_reg)); > + > + index_scale = i.log2_scale_factor; > + src1 = (i.base_reg) ? i.base_reg : i.index_reg; > + src1_reg = ginsn_dw2_regnum (src1); > + dst_reg = ginsn_dw2_regnum (i.op[1].regs); > + /* It makes sense to represent a scale factor of 1 correctly here > + (i.e., not using GINSN_TYPE_OTHER, but rather similar to the > + base-without-index case). */ > + if (!index_scale) > + { > + if (i.disp_operands) > + src_disp = i.op[0].disps->X_add_number; > + > + if (src_disp) > + /* Generate an ADD ginsn. */ > + ginsn = ginsn_new_add (insn_end_sym, true, > + GINSN_SRC_REG, src1_reg, 0, > + GINSN_SRC_IMM, 0, src_disp, > + GINSN_DST_REG, dst_reg, 0); > + else > + /* Generate a MOV ginsn. */ > + ginsn = ginsn_new_mov (insn_end_sym, true, > + GINSN_SRC_REG, src1_reg, 0, > + GINSN_DST_REG, dst_reg, 0); You're still losing symbol information if "disp" involves one. Perhaps worth a comment. > + } > + /* TBD_GINSN_INFO_LOSS - There is no explicit ginsn multiply operation, > + instead use GINSN_TYPE_OTHER. Also, note that info about displacement > + is not carried forward either. But this is fine because > + GINSN_TYPE_OTHER will cause SCFI pass to bail out any which way if > + dest reg is interesting. */ This comment would better move ... > + else > + { ... here. I also have to admit that I have trouble parsing the last sentence. > + gas_assert (i.index_reg); > + ginsn = ginsn_new_other (insn_end_sym, true, > + GINSN_SRC_REG, src1_reg, > + GINSN_SRC_IMM, index_scale, > + GINSN_DST_REG, dst_reg); > + } > + } > > ginsn_set_where (ginsn); > Since overall this is an improvement: Okay with the comment adjustments. Jan