[cfe-commits] [cfe-dev] [LLVMdev] OpenMP support in CLANG: A proposal

Chris Lattner clattner at apple.com
Sun Oct 28 11:08:46 PDT 2012


On Oct 28, 2012, at 6:54 AM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> On Sun, Oct 28, 2012 at 3:49 PM, Mahesha HS <mahesha.llvm at gmail.com> wrote:
>> I curiously looked into the OpenMP parsing in GCC. It follows the
>> method of string comparison but *without* maintaining any string table
>> in a following manner (by switching based on the first character of an
>> identifier token) . I think, I can also follow the same technique. I
>> should have done this long before in order to prevent unnecessarily
>> maintaining a string table. But, I still welcome other better
>> techniques, if any.
> 
> Clang already does this sort of thing, but the matching code is
> autogenerated by TableGen.  For example, take a look at
> tools/clang/include/clang/AST/CommentCommandInfo.inc in the build
> tree.
> 
> It might sound sensible to code the switch() for OMP clauses by hand
> just because there are only a few of them.  But OTOH, it will create a
> possibly unwanted precedent of hardcoding where we have the
> infrastructure to autogenerate code.

Personally, I'd rather that you optimize for keeping the parsing code *simple*.  There are places in the parser that we have to optimize for performance, but they are rare, and OpenMP directives are not common enough to go to extreme measures like this.  Please just make the code as simple, clear, and short as possible.

-Chris



More information about the cfe-commits mailing list