[llvm-commits] PATCH: replace if-chain in AsmParser's directive parsing code

Chris Lattner clattner at apple.com
Tue Dec 18 11:09:44 PST 2012


On Dec 17, 2012, at 4:45 PM, Eli Bendersky <eliben at google.com> wrote:

> AsmParser has a couple of if-chains when parsing directives. The
> attached patch replaces the if-chains with enum+switch. No change in
> functionality.
> 
> Unfortunately I didn't measure any significant speedups for the whole
> llvm-mc (only 1-2%), so I'll do more fine-grained measurements once I
> get the opportunity.
> 
> Also, I should add that in general AsmParser's parsing code can be
> cleaned up even more (for example w.r.t. the extensions registersing
> directive parsers, which can be unified with other directive parsing
> code). So this patch should just be seen as a first step in a
> (hopefully) right direction.

Just MHO, but this makes the code more complex and hopefully won't provide a speedup.  We generally expect that:

StringRef X = …

if (X == "foo")
  return ...
if (x == "bar")
  return …

to be turned into a switch on X[0].

-Chris





More information about the llvm-commits mailing list