List of Lists Pass Option

Is there a preferred way to specify a pass option that takes a list of lists. I have a use case where I want to specify an interchange vector for every operand of an operation.

Ideally, it would have the following format:
-transpose-paddings=[1,0],[0,1],[0,1,2]
The option should translate to a vector/list containing the interchange vectors [1,0], [0,1], and [0,1,2]. Is it possible to use ListOption for such nested lists?

I currently plan to use a slightly different format:
-transpose-paddings=1:0,0:1,0:1:2
In this case, I can use ListOption<std::string> to obtain the inner lists and then parse them manually using the colon separators.

Is there a better way to do this?

@River707

We don’t have anything builtin for lists of lists (essentially everything is using existing LLVM command line functionality internally). Conceptually though, you can pass in your own command line option parser type to the list option and have it parse some custom format (not sure if this is plumbed in the .td, but it should be). I don’t think we have any examples in-tree of how to do that, but we should add some (maybe the list of list is a good example).

– River

I did give it a try:
https://reviews.llvm.org/D118444

Unfortunately, some of the helpers for printing the option are hidden in CommandLine.cpp. It may actually be better to stick to a ListOption<std::string> or Option<std::string>. Especially, since the patch has also side-effects on PassOptions.h. Let me know if you think something similar would be a good addition to PassOptions.

Tobias