Page MenuHomePhabricator

[TableGen] Enhance !cast<string> to handle bit and bits types

Authored by Paul-C-Anagnostopoulos on Tue, Jan 12, 10:02 AM.



This revision enhances the !cast operator so it can cast bit and bits to string. It could already cast int to string.

I added a test for this change.

Note that allowing !cast to handle bit and bits means that the paste operator (#) can concatenate them.

Diff Detail

Event Timeline

Paul-C-Anagnostopoulos requested review of this revision.Tue, Jan 12, 10:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptTue, Jan 12, 10:02 AM
fpichet accepted this revision.Tue, Jan 12, 10:21 AM

This works for me

This revision is now accepted and ready to land.Tue, Jan 12, 10:21 AM
madhur13490 added inline comments.

Would it be useful if we can cast bits to the literal string also and not just to its decimal equivalent? e.g. something like

!cast<stringref>(bits1) -> "0b0101".

I am not sure if this exists today or any backend needs it.


Typo - Initializer?


It can't be a pseudo-type without all sorts of horrible parsing hackery. I'll look around to see if it seems useful and then add a !binaryliteral operator if so.


I left off the "I" so it won't matter whether it is upper- or lowercase.

Paul-C-Anagnostopoulos edited the summary of this revision. (Show Details)Tue, Jan 12, 11:08 AM
This revision was landed with ongoing or failed builds.Thu, Jan 14, 7:21 AM
This revision was automatically updated to reflect the committed changes.