From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 71A333858C3A; Thu, 4 May 2023 04:37:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71A333858C3A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683175040; bh=jJqcb9FeBbvRCWq/8hlHLjzOeb7rZelM/wLbsmfcKZA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L9cwYvX266oy1ePy9bH99qG+V+8cVFL2Uz6NPsa5YXp8PwUn16cIHke35OjOXQhcZ hwq5UF1qsfYHrOoxHqJCxCXNfU5VXVZEnJJSjC4Lsb+ByMoTXN1lrF+ENWyrqYXR4X +9bq7YMxzScDNjAjDTLC8hHcvBtd7GHaY/Cdya3M= From: "lh_mouse at 126 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/53929] [meta-bug] -masm=intel with global symbol Date: Thu, 04 May 2023 04:37:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 4.6.3 X-Bugzilla-Keywords: assemble-failure, wrong-code X-Bugzilla-Severity: minor X-Bugzilla-Who: lh_mouse at 126 dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D53929 --- Comment #13 from LIU Hao --- dup notwithstanding, I think I had better copy my recommendation here for reference: This is how MSVC handles such names: (https://gcc.godbolt.org/z/TonjYaxqj) ``` static int* volatile rip; static unsigned int volatile eax; int get_value(void) { return rip[eax]; } ``` MSVC outputs: ``` get_value PROC ; COMDAT mov ecx, DWORD PTR eax mov rax, QWORD PTR rip mov eax, DWORD PTR [rax+rcx*4] ret 0 get_value ENDP ``` GCC outputs: ``` get_value: mov rdx, QWORD PTR rip[rip] mov eax, DWORD PTR eax[rip] mov eax, DWORD PTR [rdx+rax*4] ret ``` In the case of MSVC, `DWORD PTR eax` is unambiguously parsed as the label `= eax` and `DWORD PTR [eax]` is unambiguously parsed as the register `eax`. The address of all labels are always relative to RIP, but it is implied, and brackets are not written explicitly. Maybe GCC can follow MSVC to omit the RIP register and brackets. The x86_64 memory reference syntax matches x86 with the only change in semantics of the immediate offset (for x86_64 it is relative to the next instruction, while = for i686 it is absolute), but the opcode is the same.=