================
@@ -1920,10 +1921,25 @@ bool Lexer::LexUnicodeIdentifierStart(Token &Result,
uint32_t C,
return true;
}
-static const char *
-fastParseASCIIIdentifier(const char *CurPtr,
- [[maybe_unused]] const char *BufferEnd) {
-#ifdef __SSE4_2__
+static const char *fastParseASCIIIdentifierScalar(const char *CurPtr) {
+ unsigned char C = *CurPtr;
+ while (isAsciiIdentifierContinue(C))
+ C = *++CurPtr;
+ return CurPtr;
+}
+
+// Fast path for lexing ASCII identifiers using SSE4.2 instructions.
+// Only enabled on x86/x86_64 when building with __SSE4_2__ enabled, or with a
+// compiler that supports the 'target' attribute, used for runtime dispatch.
+// Otherwise, we fall back to the scalar implementation.
+// We avoid runtime check on Windows because it is not yet well-supported.
+#if defined(__SSE4_2__) || (defined(__i386__) || defined(__x86_64__)) &&
\
----------------
AaronBallman wrote:
I was hoping we'd end up somewhere a bit more like:
https://godbolt.org/z/9EGGq83Ka but the issue is that we need to guard the
function definitions themselves (so on platforms without target attribute
support we only wind up with the default implementation), so yeah, I don't
think we can get as clean as I was hoping for. :-(
https://github.com/llvm/llvm-project/pull/175452
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits