[HarfBuzz] harfbuzz: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Oct 15 20:21:25 UTC 2017
src/hb-private.hh | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/hb-set-private.hh | 62 +---------------------------------------------
2 files changed, 69 insertions(+), 60 deletions(-)
New commits:
commit 7737e87ac4582d57945f3ffbbae1012f62c6b482
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Oct 15 16:21:03 2017 -0400
Properly detect vector_size attribute and use fallback otherwise
diff --git a/src/hb-private.hh b/src/hb-private.hh
index 46bffac2..3cf8b8d3 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -1058,6 +1058,73 @@ hb_codepoint_parse (const char *s, unsigned int len, int base, hb_codepoint_t *o
}
+/* Vectorization */
+
+struct HbOpOr
+{
+ static const bool passthru_left = true;
+ static const bool passthru_right = true;
+ template <typename T> static void process (T &o, const T &a, const T &b) { o = a | b; }
+};
+struct HbOpAnd
+{
+ static const bool passthru_left = false;
+ static const bool passthru_right = false;
+ template <typename T> static void process (T &o, const T &a, const T &b) { o = a & b; }
+};
+struct HbOpMinus
+{
+ static const bool passthru_left = true;
+ static const bool passthru_right = false;
+ template <typename T> static void process (T &o, const T &a, const T &b) { o = a & ~b; }
+};
+struct HbOpXor
+{
+ static const bool passthru_left = true;
+ static const bool passthru_right = true;
+ template <typename T> static void process (T &o, const T &a, const T &b) { o = a ^ b; }
+};
+
+/* Type behaving similar to vectorized vars defined using __attribute__((vector_size(...))). */
+template <typename elt_t, unsigned int byte_size>
+struct hb_vector_size_t
+{
+ elt_t& operator [] (unsigned int i) { return v[i]; }
+ const elt_t& operator [] (unsigned int i) const { return v[i]; }
+
+ template <class Op>
+ inline hb_vector_size_t process (const hb_vector_size_t &o) const
+ {
+ hb_vector_size_t r;
+ for (unsigned int i = 0; i < ARRAY_LENGTH (v); i++)
+ Op::process (r.v[i], v[i], o.v[i]);
+ return r;
+ }
+ inline hb_vector_size_t operator | (const hb_vector_size_t &o) const
+ { return process<HbOpOr> (o); }
+ inline hb_vector_size_t operator & (const hb_vector_size_t &o) const
+ { return process<HbOpAnd> (o); }
+ inline hb_vector_size_t operator ^ (const hb_vector_size_t &o) const
+ { return process<HbOpXor> (o); }
+ inline hb_vector_size_t operator ~ () const
+ {
+ hb_vector_size_t r;
+ for (unsigned int i = 0; i < ARRAY_LENGTH (v); i++)
+ r.v[i] = ~v[i];
+ return r;
+ }
+
+ private:
+ static_assert (byte_size / sizeof (elt_t) * sizeof (elt_t) == byte_size);
+ elt_t v[byte_size / sizeof (elt_t)];
+};
+
+/* The `vector_size' attribute was introduced in gcc 3.1. */
+#if defined( __GNUC__ ) && ( __GNUC__ >= 4 )
+#define HAVE_VECTOR_SIZE 1
+#endif
+
+
/* Global runtime options. */
struct hb_options_t
diff --git a/src/hb-set-private.hh b/src/hb-set-private.hh
index 227a5507..7bb57d9f 100644
--- a/src/hb-set-private.hh
+++ b/src/hb-set-private.hh
@@ -35,64 +35,6 @@
* hb_set_t
*/
-struct HbOpOr
-{
- static const bool passthru_left = true;
- static const bool passthru_right = true;
- template <typename T> static void process (T &o, const T &a, const T &b) { o = a | b; }
-};
-struct HbOpAnd
-{
- static const bool passthru_left = false;
- static const bool passthru_right = false;
- template <typename T> static void process (T &o, const T &a, const T &b) { o = a & b; }
-};
-struct HbOpMinus
-{
- static const bool passthru_left = true;
- static const bool passthru_right = false;
- template <typename T> static void process (T &o, const T &a, const T &b) { o = a & ~b; }
-};
-struct HbOpXor
-{
- static const bool passthru_left = true;
- static const bool passthru_right = true;
- template <typename T> static void process (T &o, const T &a, const T &b) { o = a ^ b; }
-};
-
-template <typename elt_t, unsigned int byte_size>
-struct vector_like_t
-{
- elt_t& operator [] (unsigned int i) { return v[i]; }
- const elt_t& operator [] (unsigned int i) const { return v[i]; }
-
- template <class Op>
- inline vector_like_t process (const vector_like_t &o) const
- {
- vector_like_t r;
- for (unsigned int i = 0; i < ARRAY_LENGTH (v); i++)
- Op::process (r.v[i], v[i], o.v[i]);
- return r;
- }
- inline vector_like_t operator | (const vector_like_t &o) const
- { return process<HbOpOr> (o); }
- inline vector_like_t operator & (const vector_like_t &o) const
- { return process<HbOpAnd> (o); }
- inline vector_like_t operator ^ (const vector_like_t &o) const
- { return process<HbOpXor> (o); }
- inline vector_like_t operator ~ () const
- {
- vector_like_t r;
- for (unsigned int i = 0; i < ARRAY_LENGTH (v); i++)
- r.v[i] = ~v[i];
- return r;
- }
-
- private:
- static_assert (byte_size / sizeof (elt_t) * sizeof (elt_t) == byte_size);
- elt_t v[byte_size / sizeof (elt_t)];
-};
-
struct hb_set_t
{
struct page_map_t
@@ -194,10 +136,10 @@ struct hb_set_t
typedef uint64_t elt_t;
-#if 0
+#if HAVE_VECTOR_SIZE
typedef elt_t vector_t __attribute__((vector_size (PAGE_BITS / 8)));
#else
- typedef vector_like_t<elt_t, PAGE_BITS / 8> vector_t;
+ typedef hb_vector_size_t<elt_t, PAGE_BITS / 8> vector_t;
#endif
vector_t v;
More information about the HarfBuzz
mailing list