This is an archive of the discontinued LLVM Phabricator instance.

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

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

Details

Summary

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.Jan 12 2021, 10:02 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 12 2021, 10:02 AM
fpichet accepted this revision.Jan 12 2021, 10:21 AM

This works for me

This revision is now accepted and ready to land.Jan 12 2021, 10:21 AM
madhur13490 added inline comments.
llvm/test/TableGen/cast-string.td
42

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.

54

Typo - Initializer?

llvm/test/TableGen/cast-string.td
42

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.

54

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)Jan 12 2021, 11:08 AM
This revision was landed with ongoing or failed builds.Jan 14 2021, 7:21 AM
This revision was automatically updated to reflect the committed changes.