1e0306b2bSmatt/*- 2e0306b2bSmatt * Copyright (c) 2012 The NetBSD Foundation, Inc. 3e0306b2bSmatt * All rights reserved. 4e0306b2bSmatt * 5e0306b2bSmatt * This code is derived from software contributed to The NetBSD Foundation 6e0306b2bSmatt * by Matt Thomas of 3am Software Foundry. 7e0306b2bSmatt * 8e0306b2bSmatt * Redistribution and use in source and binary forms, with or without 9e0306b2bSmatt * modification, are permitted provided that the following conditions 10e0306b2bSmatt * are met: 11e0306b2bSmatt * 1. Redistributions of source code must retain the above copyright 12e0306b2bSmatt * notice, this list of conditions and the following disclaimer. 13e0306b2bSmatt * 2. Redistributions in binary form must reproduce the above copyright 14e0306b2bSmatt * notice, this list of conditions and the following disclaimer in the 15e0306b2bSmatt * documentation and/or other materials provided with the distribution. 16e0306b2bSmatt * 17e0306b2bSmatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18e0306b2bSmatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19e0306b2bSmatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20e0306b2bSmatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21e0306b2bSmatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22e0306b2bSmatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23e0306b2bSmatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24e0306b2bSmatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25e0306b2bSmatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26e0306b2bSmatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27e0306b2bSmatt * POSSIBILITY OF SUCH DAMAGE. 28e0306b2bSmatt */ 29e0306b2bSmatt 30e0306b2bSmatt#include <machine/asm.h> 31e0306b2bSmatt 32e0306b2bSmatt#ifdef _ARM_ARCH_7 33e0306b2bSmatt 34*817045ffSmattRCSID("$NetBSD: neon_mask.S,v 1.2 2012/12/18 06:14:23 matt Exp $") 35e0306b2bSmatt 36e0306b2bSmatt/* 37e0306b2bSmatt * __neon_loading_qword_bitmask(size_t len); 38e0306b2bSmatt * IN r0 = length of mask in bits 39e0306b2bSmatt * OUT q0 = mask 40e0306b2bSmatt */ 41e0306b2bSmattENTRY(__neon_leading_qword_bitmask) 42e0306b2bSmatt cmp r0, #64 /* which dword is partial? */ 43e0306b2bSmatt#ifdef __ARMEL__ 44e0306b2bSmatt sublt r0, r0, #64 /* 1st dword needs MSBs cleared */ 45e0306b2bSmatt subge r1, r0, #128 /* 2nd dword needs MSBs cleared */ 46e0306b2bSmatt#else 47*817045ffSmatt rsblt r0, r0, #64 /* 1st dword needs LSBs cleared */ 48e0306b2bSmatt rsbge r1, r0, #128 /* 2nd dword needs LSBs cleared */ 49e0306b2bSmatt#endif 50e0306b2bSmatt movge r0, #0 /* 1st dword needs to left alone */ 51e0306b2bSmatt movlt r1, #64 /* 2st dword needs to be cleared */ 52e0306b2bSmatt vmov d2, r0, r1 /* move dword shifts to SIMD */ 53e0306b2bSmatt vmovl.u32 q1, d2 /* 2 U32 -> 2 U64 */ 54e0306b2bSmatt vmvn.u64 q0, #0 /* create a mask */ 55e0306b2bSmatt vshl.u64 q0, q0, q1 /* shift out unneeded bytes */ 56e0306b2bSmatt RET 57e0306b2bSmattEND(__neon_leading_qword_bitmask) 58e0306b2bSmatt 59e0306b2bSmatt#endif /* _ARM_ARCH_7 */ 60