sl@0: /* sl@0: * Copyright © 2004 Red Hat, Inc. sl@0: * Copyright © 2005 Trolltech AS sl@0: * sl@0: * Permission to use, copy, modify, distribute, and sell this software and its sl@0: * documentation for any purpose is hereby granted without fee, provided that sl@0: * the above copyright notice appear in all copies and that both that sl@0: * copyright notice and this permission notice appear in supporting sl@0: * documentation, and that the name of Red Hat not be used in advertising or sl@0: * publicity pertaining to distribution of the software without specific, sl@0: * written prior permission. Red Hat makes no representations about the sl@0: * suitability of this software for any purpose. It is provided "as is" sl@0: * without express or implied warranty. sl@0: * sl@0: * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS sl@0: * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND sl@0: * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY sl@0: * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES sl@0: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN sl@0: * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING sl@0: * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS sl@0: * SOFTWARE. sl@0: * sl@0: * Author: Søren Sandmann (sandmann@redhat.com) sl@0: * Lars Knoll (lars@trolltech.com) sl@0: * sl@0: * Based on work by Owen Taylor sl@0: */ sl@0: sl@0: sl@0: #define MmxNegate(x) _mm_xor_si64((x), mmx_4x00ff) sl@0: #define MmxAlpha(x) _mm_shuffle_pi16 ((x), _MM_SHUFFLE(3, 3, 3, 3)); sl@0: #define MmxTo(x) _mm_unpacklo_pi8 (_mm_cvtsi32_si64((x)), mmx_0) sl@0: #define MmxFrom(x) (uint32_t)_mm_cvtsi64_si32(_mm_packs_pu16((x), mmx_0)) sl@0: #define MmxAdd(x, y) _mm_adds_pu16 ((x), (y)) sl@0: sl@0: #define MmxMulAdd(x, a, y) do { \ sl@0: x = _mm_mullo_pi16 (x, a); \ sl@0: x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); \ sl@0: x = _mm_adds_pu16 (x, mmx_4x0080); \ sl@0: x = _mm_srli_pi16 (x, 8); \ sl@0: x = _mm_adds_pu16(x, y); \ sl@0: } while (0) sl@0: sl@0: #define MmxMul(x, a) do { \ sl@0: x = _mm_mullo_pi16 (x, a); \ sl@0: x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); \ sl@0: x = _mm_adds_pu16 (x, mmx_4x0080); \ sl@0: x = _mm_srli_pi16 (x, 8); \ sl@0: } while (0) sl@0: sl@0: #define MmxAddMul(x, a, y, b) do { \ sl@0: x = _mm_mullo_pi16 (x, a); \ sl@0: y = _mm_mullo_pi16 (y, b); \ sl@0: x = _mm_srli_pi16(x, 1); \ sl@0: y = _mm_srli_pi16(y, 1); \ sl@0: x = _mm_adds_pu16 (x, y); \ sl@0: x = _mm_adds_pu16 (x, _mm_srli_pi16 (x, 8)); \ sl@0: x = _mm_adds_pu16 (x, mmx_4x0080); \ sl@0: x = _mm_srli_pi16 (x, 7); \ sl@0: } while (0) sl@0: