cl::opt Ideas

I've added some debugging flags to my register allocator here to
turn on and off specific debug messages. I did this with llvm::cl::bits
which allows me to turn on multiple options.

But its kind of ugly because each option is independent as far as
llvm is concerned and I have to prefix each option with something
like RegallocDebug so users know what it's about. For example:

  ColoringDebugBits(llvm::cl::desc("Regalloc Debug Flags:"),
                      clEnumVal(RegallocDebugColoring, "Output while
                      clEnumVal(RegallocDebugSimplify, "Output while

<And associated enums, etc.>

-RegallocDebugColoring -RegallocDebugSimplify

It's a little tedious to do this for each of the options.

What I really want is something like named alternatives that allows
multiple values to be specialized, so the user types something like

-RegallocDebug=Coloring -RegallocDebug=Simplify

No, it doesn't same user typing (yet) but it does save developer typing
because the prefixing is taken care of by cl::opt.

Now, what would REALLY be nice is something that helps the users
as well, so they might type


This isn't the most critical thing on my list, but I thought I'd post the
idea to see if anyone else has been working on something like this
or could make use of it.

I am NOT signing up to implement it. :slight_smile: Yet.


I could make good use of it. But it's not critical for me either.


You can have this today with cl::CommaSeparated. For example, the llc -mattr=foo,bar,baz option works this way.