On Tue, Jun 25, 2024 at 10:03:34AM -0400, Paul Koning wrote: > > > > On Jun 24, 2024, at 1:50 AM, Stefan Schulze Frielinghaus > > <stefa...@linux.ibm.com> wrote: > > > > Ping. > > > > On Mon, Jun 10, 2024 at 07:19:19AM +0200, Stefan Schulze Frielinghaus wrote: > >> Ping. > >> > >> On Fri, May 24, 2024 at 11:13:12AM +0200, Stefan Schulze Frielinghaus > >> wrote: > >>> This implements hard register constraints for inline asm. A hard register > >>> constraint is of the form {regname} where regname is any valid register. > >>> This > >>> basically renders register asm superfluous. For example, the snippet > >>> > >>> int test (int x, int y) > >>> { > >>> register int r4 asm ("r4") = x; > >>> register int r5 asm ("r5") = y; > >>> unsigned int copy = y; > >>> asm ("foo %0,%1,%2" : "+d" (r4) : "d" (r5), "d" (copy)); > >>> return r4; > >>> } > >>> > >>> could be rewritten into > >>> > >>> int test (int x, int y) > >>> { > >>> asm ("foo %0,%1,%2" : "+{r4}" (x) : "{r5}" (y), "d" (y)); > >>> return x; > >>> } > > I like this idea but I'm wondering: regular constraints specify what sort of > value is needed, for example an int vs. a short int vs. a float. The > notation you've shown doesn't seem to have that aspect.
As Maciej already pointed out the type of the expression should suffice. My assumption was that an asm can deal with a value as is or its promoted value. At least for integer values this should be fine and AFAICS is also the case for simple constraints like "r" which do not define any mode. I've probably overseen something but which constraint differentiates between int vs short? However, you have a good point with this and I should test this more. > The other comment is that I didn't see documentation updates to reflect this > new feature. I didn't came up with documentation yet since I was not sure whether such a proposal would be accepted at all, i.e., just wanted to hear whether you see some show stoppers or not. Assuming this goes well I guess it should be documented under simple constraints https://gcc.gnu.org/onlinedocs/gcc/Simple-Constraints.html Thanks, Stefan