diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-01-26 06:49:09 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-01-26 06:49:09 +0000 |
| commit | 273fc663dfc6431cd7bc85b62fab3ebd50c8fb12 (patch) | |
| tree | d397740bce89ad03e586206c3ea6699c4a559214 | |
| parent | 76e689636be099136805a940c0d15ec2e8896313 (diff) | |
| download | bcm5719-llvm-273fc663dfc6431cd7bc85b62fab3ebd50c8fb12.tar.gz bcm5719-llvm-273fc663dfc6431cd7bc85b62fab3ebd50c8fb12.zip | |
Bitmangle file characteristic bits into the low bits of
the content cache pointer. This saves 105876 bytes on
cocoa.h because it shrinks the SLocEntry union, which
we have a big array of. It would be nice to use
PointerIntPair here, but we can't because it is in a
union.
llvm-svn: 63004
| -rw-r--r-- | clang/include/clang/Basic/SourceManager.h | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/clang/include/clang/Basic/SourceManager.h b/clang/include/clang/Basic/SourceManager.h index 17c39f8016e..a58662443d1 100644 --- a/clang/include/clang/Basic/SourceManager.h +++ b/clang/include/clang/Basic/SourceManager.h @@ -130,31 +130,33 @@ namespace SrcMgr { /// This is an invalid SLOC for the main file (top of the #include chain). unsigned IncludeLoc; // Really a SourceLocation - /// Content - Information about the source buffer itself. - const ContentCache *Content; - - /// FileCharacteristic - This is an instance of CharacteristicKind, - /// indicating whether this is a system header dir or not. - unsigned FileCharacteristic : 2; + /// Data - This contains the ContentCache* and the bits indicating the + /// characteristic of the file and whether it has #line info, all bitmangled + /// together. + uintptr_t Data; public: /// get - Return a FileInfo object. static FileInfo get(SourceLocation IL, const ContentCache *Con, CharacteristicKind FileCharacter) { FileInfo X; X.IncludeLoc = IL.getRawEncoding(); - X.Content = Con; - X.FileCharacteristic = FileCharacter; + X.Data = (uintptr_t)Con; + assert((X.Data & 7) == 0 &&"ContentCache pointer insufficiently aligned"); + assert((unsigned)FileCharacter < 4 && "invalid file character"); + X.Data |= (unsigned)FileCharacter; return X; } SourceLocation getIncludeLoc() const { return SourceLocation::getFromRawEncoding(IncludeLoc); } - const ContentCache* getContentCache() const { return Content; } + const ContentCache* getContentCache() const { + return reinterpret_cast<const ContentCache*>(Data & ~7UL); + } /// getCharacteristic - Return whether this is a system header or not. CharacteristicKind getFileCharacteristic() const { - return (CharacteristicKind)FileCharacteristic; + return (CharacteristicKind)(Data & 3); } }; |

