[PATCH] D14994: Enable MatchRegisterName to match register altnames

Alex Bradbury via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 3 13:37:39 PST 2015


asb added a comment.

In http://reviews.llvm.org/D14994#301864, @colinl wrote:

> Hmm interesting.  That code section seems to be dead, for instance I did:
>
>   -                    dag regList, RegAltNameIndex idx = NoRegAltName>
>   +                    dag regList>
>   }
>
>
>
>
>   -  RegAltNameIndex altNameIndex = idx
>   +  RegAltNameIndex altNameIndex = NoRegAltName;
>
>
> And all the targets seem to still build which seems to indicate no target was using the defaulted template parameter.


That is correct, that parameter is dead and this submitted patchset removes it. Do beware when reading the AsmWriterEmitter code that the variable naming surrounding AltName and AltNameIndex can be very confusing.

> I'm not sure why it would have been implemented that way.  When printing we need to make a one-to-many decision, one register enum maps to multiple register names and it seems like the natural name to pick would have been the primary one.  If they wanted to print a different register they would have swapped an alt name for the primary.


Well sometimes you have a distinction between the ABI and the architectural name, and you want to print the ABI name but refer to the architectural name in generated assembly. See also my bugfix http://reviews.llvm.org/D1504 to AsmWriterEmitter.

You could imagine having multiple different ABI names, and selecting the preferred one (and thus the preferred AltNameIndex) based on the Target, though of course this isn't done currently.

> In the reverse direction it doesn't seem necessary to make that distinction, it's a many-to-one decision where multiple register names all map to a single register enum.


The point I think is that that .td description for any register with altnames isn't complete unless there is also a list of RegAltNameIndices which indicates how they can be addressed. This is similar to the SubRegs and SubRegIndices lists.

Perhaps @grosbach, the original author of the altname system could comment on this?


http://reviews.llvm.org/D14994





More information about the llvm-commits mailing list