summaryrefslogtreecommitdiffstats
path: root/clang/Lex/Lexer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-27 04:42:31 +0000
committerChris Lattner <sabre@nondot.org>2006-10-27 04:42:31 +0000
commitaded4a977d8fc00546c99f26b8e12780a693d859 (patch)
tree274ceed12322447e1bc155c042e0cb15ef2aa587 /clang/Lex/Lexer.cpp
parent6cc3e36cd7f952d31ed24be277db9f1efa34e839 (diff)
downloadbcm5719-llvm-aded4a977d8fc00546c99f26b8e12780a693d859.tar.gz
bcm5719-llvm-aded4a977d8fc00546c99f26b8e12780a693d859.zip
Implement an sse2 version of the block comment scanner.
llvm-svn: 39060
Diffstat (limited to 'clang/Lex/Lexer.cpp')
-rw-r--r--clang/Lex/Lexer.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp
index c8433559927..fa51cc7e5df 100644
--- a/clang/Lex/Lexer.cpp
+++ b/clang/Lex/Lexer.cpp
@@ -770,6 +770,10 @@ static bool isEndOfBlockCommentWithEscapedNewLine(const char *CurPtr,
return true;
}
+#ifdef __SSE2__
+#include <emmintrin.h>
+#endif
+
/// SkipBlockComment - We have just read the /* characters from input. Read
/// until we find the */ characters that terminate the comment. Note that we
/// don't bother decoding trigraphs or escaped newlines in block comments,
@@ -799,7 +803,15 @@ bool Lexer::SkipBlockComment(LexerToken &Result, const char *CurPtr) {
C = *CurPtr++;
if (C == '/') goto FoundSlash;
-
+
+#ifdef __SSE2__
+ __m128i Slashes = _mm_set_epi8('/', '/', '/', '/', '/', '/', '/', '/',
+ '/', '/', '/', '/', '/', '/', '/', '/');
+ while (CurPtr+16 <= BufferEnd &&
+ _mm_movemask_epi8(_mm_cmpeq_epi8(*(__m128i*)CurPtr, Slashes)) == 0)
+ CurPtr += 16;
+#else
+ // Scan for '/' quickly. Many block comments are very large.
while (CurPtr[0] != '/' &&
CurPtr[1] != '/' &&
CurPtr[2] != '/' &&
@@ -807,9 +819,13 @@ bool Lexer::SkipBlockComment(LexerToken &Result, const char *CurPtr) {
CurPtr+4 < BufferEnd) {
CurPtr += 4;
}
+#endif
+
+ // It has to be one of the bytes scanned, increment to it and read one.
C = *CurPtr++;
}
+ // Loop to scan the remainder.
while (C != '/' && C != '\0')
C = *CurPtr++;
OpenPOWER on IntegriCloud