This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Add !interleave operator to concatenate a list of values with delimiters
ClosedPublic

Authored by Paul-C-Anagnostopoulos on Oct 30 2020, 8:34 AM.

Details

Summary

This patch adds the !adjoin bang operator. It takes a list of string or int/bits/bit and concatenates them with a specified delimiter in between each pair. I updated the documentation to describe it.

I added a test for it.

I modified some TableGen files to make use of it.

Diff Detail

Event Timeline

Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Paul-C-Anagnostopoulos requested review of this revision.Oct 30 2020, 8:34 AM

Oops, Builders.cpp should not be in this patch. I will remove it.

I removed Builders.cpp from this revision.

Nice reduction

llvm/include/llvm/TableGen/Record.h
811–812

OOC what is the ordering here?

The word "adjoin" is a bit obscure and I don't think it quote connotes the right thing here. How about !interleave instead?

I wouldn't use !interleave. That sounds like it is doing something with multiple lists. Another choice was !listify, but that seems like it would construct a list. I agree, though, that !adjoin sounds more like an operation on sets.

How about !delimconcat?

llvm/include/llvm/TableGen/Record.h
811–812

I've pondered the ordering of various lists in TableGen and the best I can come up with is that they are grouped logically. Do you think I should alphabetize this list?

If I hear no objection, I will name this bang operator !delimconcat.

FWIW, I suggested interleave because of the llvm::interleave algorithm in llvm/ADT/STLExtras.h

Ah, I didn't realize there was a precedent for the name. Okay, let's call it !interleave. It reads nicely, too.

Paul-C-Anagnostopoulos retitled this revision from [TableGen] Add !adjoin operator to adjoin a list of values with delimiters to [TableGen] Add !interleave operator to concatenate a list of values with delimiters.

Change the name of the new bang operator to !interleave.

lattner accepted this revision.Nov 2 2020, 8:12 AM

nice!

This revision is now accepted and ready to land.Nov 2 2020, 8:12 AM