aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/jumper/SkJumper_misc.h
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@chromium.org>2017-04-04 10:24:56 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-04 17:29:38 +0000
commit95f53be0059940da50d4fce10da5c4dcf037b6ae (patch)
tree9ae1fcc979936cf72f4f9757cbd48fdb84dbfbae /src/jumper/SkJumper_misc.h
parent744808823f635c863d7ca6b4eba652115c92ff85 (diff)
jumper, split store_f16 into to_half, store4
Pretty much the same deal as the last CL going the other direction: split store_f16 into to_half() and store4(). Platforms that had fused strategies here get a little less optimal, but the code's easier to follow, maintain, and reuse. Also adds widen_cast() to encapsulate the fairly common pattern of expanding one of our logical vector types (e.g. 8-byte U16) up to the width of the physical vector type (e.g. 16-byte __m128i). This operation is deeply understood by Clang, and often is a no-op. I could make bit_cast() do this, but it seems clearer to have two names. Change-Id: I7ba5bb4746acfcaa6d486379f67e07baee3820b2 Reviewed-on: https://skia-review.googlesource.com/11204 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/jumper/SkJumper_misc.h')
-rw-r--r--src/jumper/SkJumper_misc.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/jumper/SkJumper_misc.h b/src/jumper/SkJumper_misc.h
index 96035bd084..54e957ad6e 100644
--- a/src/jumper/SkJumper_misc.h
+++ b/src/jumper/SkJumper_misc.h
@@ -28,6 +28,14 @@ SI Dst bit_cast(const Src& src) {
return unaligned_load<Dst>(&src);
}
+template <typename Dst, typename Src>
+SI Dst widen_cast(const Src& src) {
+ static_assert(sizeof(Dst) > sizeof(Src), "");
+ Dst dst;
+ memcpy(&dst, &src, sizeof(Src));
+ return dst;
+}
+
// A couple functions for embedding constants directly into code,
// so that no .const or .literal4 section is created.
SI int C(int x) {