================
@@ -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:
This logic is pretty hard to follow along with and I think should be part of
Compiler.h (we already have `LLVM_ATTRIBUTE_USED` there) so it can be hidden
behind a macro like `LLVM_TARGET_SSE_42` or something. As it stands, the parens
are hard to reason about because it looks like enabling SSE 4.2 means we skip
the `__has_attribute` checks. The confusion also ends up below where:
```
#ifndef __SSE4_2__
__attribute__((target("default")))
#endif
```
just hangs out by itself instead of being associated with the other
declaration, which is also guarded by macros.
https://github.com/llvm/llvm-project/pull/175452
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits