[LLVMdev] cl::opt Ideas

David Greene dag at cray.com
Mon Oct 15 14:45:52 PDT 2007


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:

  llvm::cl::bits<coloring_debug_flags> 
  ColoringDebugBits(llvm::cl::desc("Regalloc Debug Flags:"),
                    llvm::cl::values(
                      clEnumVal(RegallocDebugColoring, "Output while 
coloring"),
                      clEnumVal(RegallocDebugSimplify, "Output while 
simplifying"));

<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
this:

-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

-RegallocDebug=Coloring,Simplify

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.  :)  Yet.

                                                    -Dave



More information about the llvm-dev mailing list