2015-12-28 19:52:10 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SIMD_H__
|
|
|
|
#define __SIMD_H__
|
|
|
|
|
|
|
|
#if defined(LPC43XX_M4)
|
|
|
|
|
|
|
|
#include <hal.h>
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
struct vec4_s8 {
|
2023-05-18 16:16:05 -04:00
|
|
|
union {
|
|
|
|
int8_t v[4];
|
|
|
|
uint32_t w;
|
|
|
|
};
|
2015-12-28 19:52:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
struct vec2_s16 {
|
2023-05-18 16:16:05 -04:00
|
|
|
constexpr vec2_s16()
|
|
|
|
: v{0, 0} {
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr vec2_s16(
|
|
|
|
const int16_t v)
|
|
|
|
: v{v, v} {
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr vec2_s16(
|
|
|
|
const int16_t v0,
|
|
|
|
const int16_t v1)
|
|
|
|
: v{v0, v1} {
|
|
|
|
}
|
|
|
|
|
|
|
|
constexpr vec2_s16(
|
|
|
|
const vec2_s16& other)
|
|
|
|
: w{other.w} {
|
|
|
|
}
|
|
|
|
|
|
|
|
vec2_s16& operator=(const vec2_s16& other) {
|
|
|
|
w = other.w;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
union {
|
|
|
|
int16_t v[2];
|
|
|
|
uint32_t w;
|
|
|
|
};
|
2015-12-28 19:52:10 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline vec4_s8 rev16(const vec4_s8 v) {
|
2023-05-18 16:16:05 -04:00
|
|
|
vec4_s8 result;
|
|
|
|
result.w = __REV16(v.w);
|
|
|
|
return result;
|
2015-12-28 19:52:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline vec4_s8 pkhbt(const vec4_s8 v1, const vec4_s8 v2, const size_t sh = 0) {
|
2023-05-18 16:16:05 -04:00
|
|
|
vec4_s8 result;
|
|
|
|
result.w = __PKHBT(v1.w, v2.w, sh);
|
|
|
|
return result;
|
2015-12-28 19:52:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline vec2_s16 pkhbt(const vec2_s16 v1, const vec2_s16 v2, const size_t sh = 0) {
|
2023-05-18 16:16:05 -04:00
|
|
|
vec2_s16 result;
|
|
|
|
result.w = __PKHBT(v1.w, v2.w, sh);
|
|
|
|
return result;
|
2015-12-28 19:52:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline vec2_s16 pkhtb(const vec2_s16 v1, const vec2_s16 v2, const size_t sh = 0) {
|
2023-05-18 16:16:05 -04:00
|
|
|
vec2_s16 result;
|
|
|
|
result.w = __PKHTB(v1.w, v2.w, sh);
|
|
|
|
return result;
|
2015-12-28 19:52:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline vec2_s16 sxtb16(const vec4_s8 v, const size_t sh = 0) {
|
2023-05-18 16:16:05 -04:00
|
|
|
vec2_s16 result;
|
|
|
|
result.w = __SXTB16(v.w, sh);
|
|
|
|
return result;
|
2015-12-28 19:52:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int32_t smlsd(const vec2_s16 v1, const vec2_s16 v2, const int32_t accum) {
|
2023-05-18 16:16:05 -04:00
|
|
|
return __SMLSD(v1.w, v2.w, accum);
|
2015-12-28 19:52:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int32_t smlad(const vec2_s16 v1, const vec2_s16 v2, const int32_t accum) {
|
2023-05-18 16:16:05 -04:00
|
|
|
return __SMLAD(v1.w, v2.w, accum);
|
2015-12-28 19:52:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* defined(LPC43XX_M4) */
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
#endif /*__SIMD_H__*/
|