1/****************************************************************************** 2 * 3 * Copyright (C) 2015 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ***************************************************************************** 18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19*/ 20/** 21******************************************************************************* 22* @file 23* icv_platform_macros.h 24* 25* @brief 26* This header files contains all the platform/toolchain specific macros 27* 28* @author 29* Ittiam 30* 31* @par List of Functions: 32* 33* @remarks 34* None 35* 36******************************************************************************* 37*/ 38#ifndef __ICV_PLATFORM_MACROS_H__ 39#define __ICV_PLATFORM_MACROS_H__ 40 41static __inline UWORD32 CLZ(UWORD32 u4_word) 42{ 43 if(u4_word) 44 return (__builtin_clz(u4_word)); 45 else 46 return 32; 47} 48 49static __inline UWORD32 CLZNZ(UWORD32 u4_word) 50{ 51 ASSERT(u4_word); 52 return (__builtin_clz(u4_word)); 53} 54 55static __inline WORD32 CLIP_U8(WORD32 x) 56{ 57 asm("usat %0, #8, %1" : "=r"(x) : "r"(x)); 58 return x; 59} 60 61static __inline WORD32 CLIP_S8(WORD32 x) 62{ 63 asm("ssat %0, #8, %1" : "=r"(x) : "r"(x)); 64 return x; 65} 66 67static __inline WORD32 CLIP_U12(WORD32 x) 68{ 69 asm("usat %0, #12, %1" : "=r"(x) : "r"(x)); 70 return x; 71} 72 73static __inline WORD32 CLIP_S12(WORD32 x) 74{ 75 asm("ssat %0, #12, %1" : "=r"(x) : "r"(x)); 76 return x; 77} 78 79static __inline WORD32 CLIP_U16(WORD32 x) 80{ 81 asm("usat %0, #16, %1" : "=r"(x) : "r"(x)); 82 return x; 83} 84static __inline WORD32 CLIP_S16(WORD32 x) 85{ 86 asm("ssat %0, #16, %1" : "=r"(x) : "r"(x)); 87 return x; 88} 89 90static __inline UWORD32 ITT_BIG_ENDIAN(UWORD32 x) 91{ 92 asm("rev %0, %1" : "=r"(x) : "r"(x)); 93 return x; 94} 95 96#define NOP(nop_cnt) {UWORD32 nop_i; for (nop_i = 0; nop_i < nop_cnt; nop_i++) asm("nop");} 97 98#define PREFETCH(x) __builtin_prefetch(x); 99 100#define DATA_SYNC() __sync_synchronize() 101 102#define SHL(x,y) (((y) < 32) ? ((x) << (y)) : 0) 103#define SHR(x,y) (((y) < 32) ? ((x) >> (y)) : 0) 104 105#define SHR_NEG(val,shift) (((shift) > 0) ? ( (val) >> (shift)) : ((val) << (-(shift)))) 106#define SHL_NEG(val,shift) (((shift) > 0) ? ( (val) >> (-(shift))) : ((val) << (shift))) 107 108#define INLINE inline 109 110#define MEM_ALIGN8 __attribute__ ((aligned (8))) 111#define MEM_ALIGN16 __attribute__ ((aligned (16))) 112#define MEM_ALIGN32 __attribute__ ((aligned (32))) 113 114 115#endif /* __ICV_PLATFORM_MACROS_H__ */ 116