@@ -220,7 +220,7 @@ acc_char_index (word_type cmp ATTRIBUTE_UNUSED,
and branches without increasing the number of arithmetic operations.
It's almost certainly going to be a win with 64-bit word size. */
-static bool
+static bool ATTRIBUTE_UNUSED
search_line_acc_char (const uchar *s, const uchar *end, const uchar **out)
{
const word_type repl_nl = acc_char_replicate ('\n');
@@ -497,6 +497,116 @@ search_line_fast (const uchar *s, const uchar *end, const uchar **out)
return search_line_acc_char (s, end, out);
}
+#elif defined(__ALTIVEC__)
+
+static bool
+search_line_fast (const uchar *s, const uchar *end, const uchar **out)
+{
+ typedef __vector unsigned char vc;
+
+ const vc repl_nl = {
+ '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n',
+ '\n', '\n', '\n', '\n', '\n', '\n', '\n', '\n'
+ };
+ const vc repl_cr = {
+ '\r', '\r', '\r', '\r', '\r', '\r', '\r', '\r',
+ '\r', '\r', '\r', '\r', '\r', '\r', '\r', '\r'
+ };
+ const vc repl_bs = {
+ '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\',
+ '\\', '\\', '\\', '\\', '\\', '\\', '\\', '\\'
+ };
+ const vc repl_qm = {
+ '?', '?', '?', '?', '?', '?', '?', '?',
+ '?', '?', '?', '?', '?', '?', '?', '?',
+ };
+ const vc ones = {
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1,
+ };
+ const vc zero = { 0 };
+
+ ptrdiff_t left;
+ vc data, vsl, t;
+
+ left = end - s;
+ data = __builtin_vec_ld(0, (const vc *)s);
+ vsl = __builtin_vec_lvsr(0, s);
+ t = __builtin_vec_perm(zero, ones, vsl);
+ data &= t;
+
+ left += (uintptr_t)s & 15;
+ s = (const uchar *)((uintptr_t)s & -16);
+ goto start;
+
+ do
+ {
+ vc m_nl, m_cr, m_bs, m_qm;
+
+ left -= 16;
+ s += 16;
+ if (__builtin_expect (left <= 0, 0))
+ {
+ *out = s;
+ return false;
+ }
+ data = __builtin_vec_ld(0, (const vc *)s);
+
+ start:
+ m_nl = (vc) __builtin_vec_cmpeq(data, repl_nl);
+ m_cr = (vc) __builtin_vec_cmpeq(data, repl_cr);
+ m_bs = (vc) __builtin_vec_cmpeq(data, repl_bs);
+ m_qm = (vc) __builtin_vec_cmpeq(data, repl_qm);
+ t = (m_nl | m_cr) | (m_bs | m_qm);
+ }
+ while (!__builtin_vec_vcmpeq_p(/*__CR6_LT_REV*/3, t, zero));
+
+ /* A match somewhere. Scan T for the match. */
+ {
+#define N (sizeof(vc) / sizeof(long))
+
+ union {
+ vc v;
+ unsigned long l[N];
+ } u;
+ typedef char check_count[(N == 2 || N == 4) * 2 - 1];
+
+ unsigned long l, i = 0;
+
+ u.v = t;
+ switch (N)
+ {
+ case 4:
+ l = u.l[i++];
+ if (l != 0)
+ break;
+ s += sizeof(unsigned long);
+ l = u.l[i++];
+ if (l != 0)
+ break;
+ s += sizeof(unsigned long);
+ case 2:
+ l = u.l[i++];
+ if (l != 0)
+ break;
+ s += sizeof(unsigned long);
+ l = u.l[i];
+ }
+
+ l = __builtin_clzl(l);
+ l /= 8;
+ *out = s + l;
+ return true;
+
+#undef N
+ }
+}
+
+void
+init_vectorized_lexer (void)
+{
+}
+
#else
/* We only have one accellerated alternative. Use a direct call so that