From 61287cdbe2eac721eaf61114c0182e042ea6cf5b Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 9 Aug 2020 08:24:07 -0700 Subject: [PATCH] ircd::simd: Split unaligned type related to separate header. --- include/ircd/simd/simd.h | 1 + include/ircd/simd/type.h | 41 -------------- include/ircd/simd/type.unaligned.h | 89 ++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+), 41 deletions(-) create mode 100644 include/ircd/simd/type.unaligned.h diff --git a/include/ircd/simd/simd.h b/include/ircd/simd/simd.h index ab31c60a2..e73a15895 100644 --- a/include/ircd/simd/simd.h +++ b/include/ircd/simd/simd.h @@ -12,6 +12,7 @@ #define HAVE_IRCD_SIMD_H #include "type.h" +#include "type.unaligned.h" #include "traits.h" #include "lane_cast.h" #include "broad_cast.h" diff --git a/include/ircd/simd/type.h b/include/ircd/simd/type.h index 83e707437..4d59c921b 100644 --- a/include/ircd/simd/type.h +++ b/include/ircd/simd/type.h @@ -11,29 +11,6 @@ #pragma once #define HAVE_IRCD_SIMD_TYPE_H -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpsabi" -#pragma GCC diagnostic ignored "-Wpacked" - -/// Unaligned type wrapper macro -#define IRCD_SIMD_TYPEDEF_UNALIGNED(TYPE, NAME) \ -struct \ -__attribute__((packed)) \ -__attribute__((aligned(1))) \ -__attribute__((visibility("internal"))) \ -NAME \ -{ \ - TYPE val; \ - \ - operator TYPE () const { return val; } \ - \ - template NAME &operator=(T&& t) \ - { \ - val = std::forward(t); \ - return *this; \ - } \ -} - // // scalar // @@ -78,10 +55,6 @@ namespace ircd typedef __m512i u512x1; // [_______________________________0________________________________| typedef __m256i u256x1; // [________________0________________| typedef __m128i u128x1; // [________0________| - - IRCD_SIMD_TYPEDEF_UNALIGNED(__m512i, u512x1_u); - IRCD_SIMD_TYPEDEF_UNALIGNED(__m256i, u256x1_u); - IRCD_SIMD_TYPEDEF_UNALIGNED(__m128i, u128x1_u); } #endif @@ -108,10 +81,6 @@ namespace ircd typedef __m512i i512x1; // [_______________________________0________________________________| typedef __m256i i256x1; // [________________0________________| typedef __m128i i128x1; // [________0________| - - IRCD_SIMD_TYPEDEF_UNALIGNED(__m512i, i512x1_u); - IRCD_SIMD_TYPEDEF_UNALIGNED(__m256i, i256x1_u); - IRCD_SIMD_TYPEDEF_UNALIGNED(__m128i, i128x1_u); } #endif @@ -130,10 +99,6 @@ namespace ircd typedef __m512 f512x1; // [_______________________________0________________________________| typedef __m256 f256x1; // [________________0________________| typedef __m128 f128x1; // [____|____0____|____| - - IRCD_SIMD_TYPEDEF_UNALIGNED(__m512, f512x1_u); - IRCD_SIMD_TYPEDEF_UNALIGNED(__m256, f256x1_u); - IRCD_SIMD_TYPEDEF_UNALIGNED(__m128, f128x1_u); } #endif @@ -151,15 +116,9 @@ namespace ircd typedef __m512d d512x1; // [_______________________________0________________________________| typedef __m256d d256x1; // [________________0________________| typedef __m128d d128x1; // [________0________] - - IRCD_SIMD_TYPEDEF_UNALIGNED(__m512d, d512x1_u); - IRCD_SIMD_TYPEDEF_UNALIGNED(__m256d, d256x1_u); - IRCD_SIMD_TYPEDEF_UNALIGNED(__m128d, d128x1_u); } #endif -#pragma GCC diagnostic pop - // // other words // diff --git a/include/ircd/simd/type.unaligned.h b/include/ircd/simd/type.unaligned.h new file mode 100644 index 000000000..a7907652b --- /dev/null +++ b/include/ircd/simd/type.unaligned.h @@ -0,0 +1,89 @@ +// The Construct +// +// Copyright (C) The Construct Developers, Authors & Contributors +// Copyright (C) 2016-2020 Jason Volk +// +// Permission to use, copy, modify, and/or distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice is present in all copies. The +// full license for this software is available in the LICENSE file. + +#pragma once +#define HAVE_IRCD_SIMD_TYPE_UNALIGNED_H + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpsabi" +#pragma GCC diagnostic ignored "-Wpacked" + +/// Unaligned type wrapper macro +#define IRCD_SIMD_TYPEDEF_UNALIGNED(TYPE, NAME) \ +struct \ +__attribute__((packed)) \ +__attribute__((aligned(1))) \ +__attribute__((visibility("internal"))) \ +NAME \ +{ \ + TYPE val; \ + \ + operator TYPE () const { return val; } \ + \ + template NAME &operator=(T&& t) \ + { \ + val = std::forward(t); \ + return *this; \ + } \ +} + +// +// unsigned +// + +#ifdef HAVE_X86INTRIN_H +namespace ircd +{ + IRCD_SIMD_TYPEDEF_UNALIGNED(__m512i, u512x1_u); + IRCD_SIMD_TYPEDEF_UNALIGNED(__m256i, u256x1_u); + IRCD_SIMD_TYPEDEF_UNALIGNED(__m128i, u128x1_u); +} +#endif + +// +// signed +// + +#ifdef HAVE_X86INTRIN_H +namespace ircd +{ + IRCD_SIMD_TYPEDEF_UNALIGNED(__m512i, i512x1_u); + IRCD_SIMD_TYPEDEF_UNALIGNED(__m256i, i256x1_u); + IRCD_SIMD_TYPEDEF_UNALIGNED(__m128i, i128x1_u); +} +#endif + +// +// single precision +// + +#ifdef HAVE_X86INTRIN_H +namespace ircd +{ + IRCD_SIMD_TYPEDEF_UNALIGNED(__m512, f512x1_u); + IRCD_SIMD_TYPEDEF_UNALIGNED(__m256, f256x1_u); + IRCD_SIMD_TYPEDEF_UNALIGNED(__m128, f128x1_u); +} +#endif + +// +// double precision +// + +#ifdef HAVE_X86INTRIN_H +namespace ircd +{ + IRCD_SIMD_TYPEDEF_UNALIGNED(__m512d, d512x1_u); + IRCD_SIMD_TYPEDEF_UNALIGNED(__m256d, d256x1_u); + IRCD_SIMD_TYPEDEF_UNALIGNED(__m128d, d128x1_u); +} +#endif + +#pragma GCC diagnostic pop