From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by sourceware.org (Postfix) with ESMTPS id 326473858D35 for ; Wed, 15 May 2024 05:59:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 326473858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=maskray.me Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 326473858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.85.128.170 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715752767; cv=none; b=FEcXpSsmMRkUyimlU4j3idLsLoQZPr+I32GeNm8rN1fGZAsjYzvu8rDRZ2VXoeUq6c7/PI5ua05aB6utVkyjPLSigSdNuHzEb2cYK6Y+gdiQL857G7qmC3rN2IPj1wObSA4soKre06yDXaiy+CnKhVNkEvQPJVGQCPDL3PpEdXc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715752767; c=relaxed/simple; bh=jCcDOefRYhe8MXDCyTGajBAjG3xE1P4yqdpPrv/ChnU=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=oSm6D5V5IxnVlYIZtI36/yjsX5QVjqcnepiiYmtJWh8Nxes/ov/f6T8qiFyw0mzMzj5ZWlwSDgul9Jbq13G+Gygtvl7qhIQjoDvnf1OOshkz3n+k7DAz2PP/YBkIaRXgzMHBPSYr4S6GDEgmIroxMksac6mmjIf3X8VsOTeJwcQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-61e01d5ea74so67552667b3.2 for ; Tue, 14 May 2024 22:59:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715752764; x=1716357564; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KGNf8QD17ymaKVqD6yL1o8+2R/1romj1tptbFE4ESlM=; b=nuKXUJttHGA4pAiLOoWWVewUeIj3MRRK4fLq/7fRzebLCWHDn7/2Sqw0UC6rONy8Ku kRacMFTw7RnrT5FN+f9q/yCzTXr+hLkG3B0RXAN04suHBJomgodE9ErUfqvr0EThpJrF zyC9aDSLBjCIauh0Vpz2yzzYEIlag1eEAQAtnoU7Ks053QGOyC4tHW3JriXHYh3ejVKs eb0ALwmFpg5qH+ADsHvvwJQjlsuLa1nclbhFX9haaJchHVl00LJFqbgev8YJsbmvkTLZ JLte2q6L5ulDN/GXYK+DrQAp0xSEphVYbmipy0HHbxs5y2PA6OR89d/OC34138PFrAjF sdAg== X-Gm-Message-State: AOJu0YwaLmBv6En1H07X/tR1Nt2oiUjITyrN/71AjsVK/FXX9cJ1VmhI Izv9yWN78440CTDkHvAP3MbYNcoZ+n1zr3PC0J1rF/ZJo3LEhK7NgMg1rQ== X-Google-Smtp-Source: AGHT+IE2hySMJPSOpXB7xwka5Sjs6ATwO7ay0d2iSNxwbtclH+TCKBcpIHXy+MhO3wHhMFYgWQsZUQ== X-Received: by 2002:a0d:cb05:0:b0:617:fbaa:1d91 with SMTP id 00721157ae682-622aff774a8mr148760237b3.11.1715752764514; Tue, 14 May 2024 22:59:24 -0700 (PDT) Received: from localhost ([2600:1700:5b70:4260:afcf:7fae:162e:628b]) by smtp.gmail.com with ESMTPSA id 00721157ae682-6209e2514bbsm28560727b3.42.2024.05.14.22.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 22:59:24 -0700 (PDT) Date: Tue, 14 May 2024 22:59:23 -0700 From: Fangrui Song To: Nick Clifton Cc: binutils@sourceware.org Subject: Re: RFC: Maintaining a per-macro invocation count Message-ID: <20240515055923.7jlccxxbl574bf5w@google.com> References: <87pltw9qku.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87pltw9qku.fsf@redhat.com> X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,KAM_INFOUSMEBIZ,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no 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 2024-05-08, Nick Clifton wrote: >Hi Guys, > > The attached patch implements a extension to the assembler's macro > syntax, allowing a macro to access a count of the number of times that > it has been executed via the \+ pseudo-variable. ie like this: > > .macro foo > .print "I have been invoked \+ times" > .endm > > This syntax is similar to the already supported \@ pseudo-variable, > except that the count is maintained on a per-macro basis. > > The drive for this extension is that I want to be able to generate > N references to unique symbols in file A and then N definitions of > those symbols in file B. Using assembler macros makes this easy, > providing that I can ensure that the names in file A will match those > in file B. ie: > > fileA.s: > .macro gen_refs count > .dc.a ref_\+ > .if \count > 1 > gen_refs \count-1 > .endif > .endm > > gen_refs 1000 > > fileB.s: > .macro gen_defs count > .global ref_\+ > ref_\+ : > .if \count > 1 > gen_defs \count-1 > .endif > .endm > > gen_defs 1000 > > (This is part of a larger exercise to generate some micro benchmarks > for the assembler that exercise various different features. In this > case I am looking into relocation processing). ( I am curious how intrusive it would be to support a new relocation format https://maskray.me/blog/2024-03-09-a-compact-relocation-format-for-elf#crel-relocation-format ) > Comments, suggestions ? > >Cheers > Nick > >PS. In the course of creating this patch I noticed that the altmacto >test (gas/testsuite/gas/macros/altmacro.d) does not appear to be run. >So I have fixed that as well. > Thanks for the patch https://sourceware.org/cgit/binutils-gdb/commit/?id=83b972fc272db31ab48aa5cde84f47c98868d7c8 and the test fix! This feature looks very useful, which resembles https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Special-format-strings > ‘%=’ > > Outputs a number that is unique to each instance of the asm statement in > the entire compilation. This option is useful when creating local labels > and referring to them multiple times in a single template that generates > multiple assembler instructions.