Path: blob/master/tools/android-sdk/renderscript/clang-include/htmintrin.h
496 views
/*===---- htmintrin.h - Standard header for PowerPC HTM ---------------===*\1*2* Permission is hereby granted, free of charge, to any person obtaining a copy3* of this software and associated documentation files (the "Software"), to deal4* in the Software without restriction, including without limitation the rights5* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell6* copies of the Software, and to permit persons to whom the Software is7* furnished to do so, subject to the following conditions:8*9* The above copyright notice and this permission notice shall be included in10* all copies or substantial portions of the Software.11*12* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR13* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE15* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER16* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,17* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN18* THE SOFTWARE.19*20\*===----------------------------------------------------------------------===*/2122#ifndef __HTMINTRIN_H23#define __HTMINTRIN_H2425#ifndef __HTM__26#error "HTM instruction set not enabled"27#endif2829#ifdef __powerpc__3031#include <stdint.h>3233typedef uint64_t texasr_t;34typedef uint32_t texasru_t;35typedef uint32_t texasrl_t;36typedef uintptr_t tfiar_t;37typedef uintptr_t tfhar_t;3839#define _HTM_STATE(CR0) ((CR0 >> 1) & 0x3)40#define _HTM_NONTRANSACTIONAL 0x041#define _HTM_SUSPENDED 0x142#define _HTM_TRANSACTIONAL 0x24344#define _TEXASR_EXTRACT_BITS(TEXASR,BITNUM,SIZE) \45(((TEXASR) >> (63-(BITNUM))) & ((1<<(SIZE))-1))46#define _TEXASRU_EXTRACT_BITS(TEXASR,BITNUM,SIZE) \47(((TEXASR) >> (31-(BITNUM))) & ((1<<(SIZE))-1))4849#define _TEXASR_FAILURE_CODE(TEXASR) \50_TEXASR_EXTRACT_BITS(TEXASR, 7, 8)51#define _TEXASRU_FAILURE_CODE(TEXASRU) \52_TEXASRU_EXTRACT_BITS(TEXASRU, 7, 8)5354#define _TEXASR_FAILURE_PERSISTENT(TEXASR) \55_TEXASR_EXTRACT_BITS(TEXASR, 7, 1)56#define _TEXASRU_FAILURE_PERSISTENT(TEXASRU) \57_TEXASRU_EXTRACT_BITS(TEXASRU, 7, 1)5859#define _TEXASR_DISALLOWED(TEXASR) \60_TEXASR_EXTRACT_BITS(TEXASR, 8, 1)61#define _TEXASRU_DISALLOWED(TEXASRU) \62_TEXASRU_EXTRACT_BITS(TEXASRU, 8, 1)6364#define _TEXASR_NESTING_OVERFLOW(TEXASR) \65_TEXASR_EXTRACT_BITS(TEXASR, 9, 1)66#define _TEXASRU_NESTING_OVERFLOW(TEXASRU) \67_TEXASRU_EXTRACT_BITS(TEXASRU, 9, 1)6869#define _TEXASR_FOOTPRINT_OVERFLOW(TEXASR) \70_TEXASR_EXTRACT_BITS(TEXASR, 10, 1)71#define _TEXASRU_FOOTPRINT_OVERFLOW(TEXASRU) \72_TEXASRU_EXTRACT_BITS(TEXASRU, 10, 1)7374#define _TEXASR_SELF_INDUCED_CONFLICT(TEXASR) \75_TEXASR_EXTRACT_BITS(TEXASR, 11, 1)76#define _TEXASRU_SELF_INDUCED_CONFLICT(TEXASRU) \77_TEXASRU_EXTRACT_BITS(TEXASRU, 11, 1)7879#define _TEXASR_NON_TRANSACTIONAL_CONFLICT(TEXASR) \80_TEXASR_EXTRACT_BITS(TEXASR, 12, 1)81#define _TEXASRU_NON_TRANSACTIONAL_CONFLICT(TEXASRU) \82_TEXASRU_EXTRACT_BITS(TEXASRU, 12, 1)8384#define _TEXASR_TRANSACTION_CONFLICT(TEXASR) \85_TEXASR_EXTRACT_BITS(TEXASR, 13, 1)86#define _TEXASRU_TRANSACTION_CONFLICT(TEXASRU) \87_TEXASRU_EXTRACT_BITS(TEXASRU, 13, 1)8889#define _TEXASR_TRANSLATION_INVALIDATION_CONFLICT(TEXASR) \90_TEXASR_EXTRACT_BITS(TEXASR, 14, 1)91#define _TEXASRU_TRANSLATION_INVALIDATION_CONFLICT(TEXASRU) \92_TEXASRU_EXTRACT_BITS(TEXASRU, 14, 1)9394#define _TEXASR_IMPLEMENTAION_SPECIFIC(TEXASR) \95_TEXASR_EXTRACT_BITS(TEXASR, 15, 1)96#define _TEXASRU_IMPLEMENTAION_SPECIFIC(TEXASRU) \97_TEXASRU_EXTRACT_BITS(TEXASRU, 15, 1)9899#define _TEXASR_INSTRUCTION_FETCH_CONFLICT(TEXASR) \100_TEXASR_EXTRACT_BITS(TEXASR, 16, 1)101#define _TEXASRU_INSTRUCTION_FETCH_CONFLICT(TEXASRU) \102_TEXASRU_EXTRACT_BITS(TEXASRU, 16, 1)103104#define _TEXASR_ABORT(TEXASR) \105_TEXASR_EXTRACT_BITS(TEXASR, 31, 1)106#define _TEXASRU_ABORT(TEXASRU) \107_TEXASRU_EXTRACT_BITS(TEXASRU, 31, 1)108109110#define _TEXASR_SUSPENDED(TEXASR) \111_TEXASR_EXTRACT_BITS(TEXASR, 32, 1)112113#define _TEXASR_PRIVILEGE(TEXASR) \114_TEXASR_EXTRACT_BITS(TEXASR, 35, 2)115116#define _TEXASR_FAILURE_SUMMARY(TEXASR) \117_TEXASR_EXTRACT_BITS(TEXASR, 36, 1)118119#define _TEXASR_TFIAR_EXACT(TEXASR) \120_TEXASR_EXTRACT_BITS(TEXASR, 37, 1)121122#define _TEXASR_ROT(TEXASR) \123_TEXASR_EXTRACT_BITS(TEXASR, 38, 1)124125#define _TEXASR_TRANSACTION_LEVEL(TEXASR) \126_TEXASR_EXTRACT_BITS(TEXASR, 63, 12)127128#endif /* __powerpc */129130#ifdef __s390__131132/* Condition codes generated by tbegin */133#define _HTM_TBEGIN_STARTED 0134#define _HTM_TBEGIN_INDETERMINATE 1135#define _HTM_TBEGIN_TRANSIENT 2136#define _HTM_TBEGIN_PERSISTENT 3137138/* The abort codes below this threshold are reserved for machine use. */139#define _HTM_FIRST_USER_ABORT_CODE 256140141/* The transaction diagnostic block is it is defined in the Principles142of Operation chapter 5-91. */143144struct __htm_tdb {145unsigned char format; /* 0 */146unsigned char flags;147unsigned char reserved1[4];148unsigned short nesting_depth;149unsigned long long abort_code; /* 8 */150unsigned long long conflict_token; /* 16 */151unsigned long long atia; /* 24 */152unsigned char eaid; /* 32 */153unsigned char dxc;154unsigned char reserved2[2];155unsigned int program_int_id;156unsigned long long exception_id; /* 40 */157unsigned long long bea; /* 48 */158unsigned char reserved3[72]; /* 56 */159unsigned long long gprs[16]; /* 128 */160} __attribute__((__packed__, __aligned__ (8)));161162163/* Helper intrinsics to retry tbegin in case of transient failure. */164165static __inline int __attribute__((__always_inline__, __nodebug__))166__builtin_tbegin_retry_null (int __retry)167{168int cc, i = 0;169170while ((cc = __builtin_tbegin(0)) == _HTM_TBEGIN_TRANSIENT171&& i++ < __retry)172__builtin_tx_assist(i);173174return cc;175}176177static __inline int __attribute__((__always_inline__, __nodebug__))178__builtin_tbegin_retry_tdb (void *__tdb, int __retry)179{180int cc, i = 0;181182while ((cc = __builtin_tbegin(__tdb)) == _HTM_TBEGIN_TRANSIENT183&& i++ < __retry)184__builtin_tx_assist(i);185186return cc;187}188189#define __builtin_tbegin_retry(tdb, retry) \190(__builtin_constant_p(tdb == 0) && tdb == 0 ? \191__builtin_tbegin_retry_null(retry) : \192__builtin_tbegin_retry_tdb(tdb, retry))193194static __inline int __attribute__((__always_inline__, __nodebug__))195__builtin_tbegin_retry_nofloat_null (int __retry)196{197int cc, i = 0;198199while ((cc = __builtin_tbegin_nofloat(0)) == _HTM_TBEGIN_TRANSIENT200&& i++ < __retry)201__builtin_tx_assist(i);202203return cc;204}205206static __inline int __attribute__((__always_inline__, __nodebug__))207__builtin_tbegin_retry_nofloat_tdb (void *__tdb, int __retry)208{209int cc, i = 0;210211while ((cc = __builtin_tbegin_nofloat(__tdb)) == _HTM_TBEGIN_TRANSIENT212&& i++ < __retry)213__builtin_tx_assist(i);214215return cc;216}217218#define __builtin_tbegin_retry_nofloat(tdb, retry) \219(__builtin_constant_p(tdb == 0) && tdb == 0 ? \220__builtin_tbegin_retry_nofloat_null(retry) : \221__builtin_tbegin_retry_nofloat_tdb(tdb, retry))222223#endif /* __s390__ */224225#endif /* __HTMINTRIN_H */226227228