[cfe-commits] r62447 - /cfe/trunk/lib/Lex/PTHLexer.cpp

Chris Lattner clattner at apple.com
Sun Jan 18 11:39:57 PST 2009


On Jan 18, 2009, at 3:54 AM, Sebastian Redl wrote:

> Chris Lattner wrote:
>> Author: lattner
>> Date: Sat Jan 17 20:19:16 2009
>> New Revision: 62447
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=62447&view=rev
>> Log:
>> On i386 and x86-64, just do unaligned loads
>> instead of assembling from bytes.  This speeds up -Eonly PTH reading
>> of cocoa.h by about 2ms, which is 4.2%.
>>
>> +#if defined(__i386__) || defined(__x86_64__)
>>
>
> We need a central place for determining this support, and then  
> define a
> config macro based on this, so that the locations using this can  
> just write
>
> #if defined(CLANG_UNALIGNED_LOADSTORE)
>
> or something like that. The current method is too brittle. Aside from
> being complicated to extend to other platforms (you have to hunt down
> every place that does this, which gets complicated if we have more  
> than
> one place that tests capability by querying the platform instead of a
> capability flag), compilers simply don't agree on the names for the
> platform flags. So, to make the above work on both GCC and MSVC, you
> have to write something like (can't remember the MS macros exactly):
>
> #if defined(__i386__) || defined(_M_X86) || defined(__x86_64__) ||
> defined(_M_AMD64)

Oh I agree.  I'm sorry, I should have mentioned that this is a short- 
term hack.  I really think the right answer is to bite the size cost  
and bump tokens up to being 12 bytes instead of 11.  This would allow  
us to read a token by doing 3 4-byte loads, and wouldn't require  
target-specific hacks.

-Chris



More information about the cfe-commits mailing list