Path: blob/master/tools/android-sdk/renderscript/clang-include/htmxlintrin.h
496 views
/*===---- htmxlintrin.h - XL compiler HTM execution intrinsics-------------===*\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 __HTMXLINTRIN_H23#define __HTMXLINTRIN_H2425#ifndef __HTM__26#error "HTM instruction set not enabled"27#endif2829#include <htmintrin.h>3031#ifdef __powerpc__3233#ifdef __cplusplus34extern "C" {35#endif3637#define _TEXASR_PTR(TM_BUF) \38((texasr_t *)((TM_BUF)+0))39#define _TEXASRU_PTR(TM_BUF) \40((texasru_t *)((TM_BUF)+0))41#define _TEXASRL_PTR(TM_BUF) \42((texasrl_t *)((TM_BUF)+4))43#define _TFIAR_PTR(TM_BUF) \44((tfiar_t *)((TM_BUF)+8))4546typedef char TM_buff_type[16];4748/* This macro can be used to determine whether a transaction was successfully49started from the __TM_begin() and __TM_simple_begin() intrinsic functions50below. */51#define _HTM_TBEGIN_STARTED 15253extern __inline long54__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))55__TM_simple_begin (void)56{57if (__builtin_expect (__builtin_tbegin (0), 1))58return _HTM_TBEGIN_STARTED;59return 0;60}6162extern __inline long63__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))64__TM_begin (void* const __TM_buff)65{66*_TEXASRL_PTR (__TM_buff) = 0;67if (__builtin_expect (__builtin_tbegin (0), 1))68return _HTM_TBEGIN_STARTED;69#ifdef __powerpc64__70*_TEXASR_PTR (__TM_buff) = __builtin_get_texasr ();71#else72*_TEXASRU_PTR (__TM_buff) = __builtin_get_texasru ();73*_TEXASRL_PTR (__TM_buff) = __builtin_get_texasr ();74#endif75*_TFIAR_PTR (__TM_buff) = __builtin_get_tfiar ();76return 0;77}7879extern __inline long80__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))81__TM_end (void)82{83if (__builtin_expect (__builtin_tend (0), 1))84return 1;85return 0;86}8788extern __inline void89__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))90__TM_abort (void)91{92__builtin_tabort (0);93}9495extern __inline void96__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))97__TM_named_abort (unsigned char const __code)98{99__builtin_tabort (__code);100}101102extern __inline void103__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))104__TM_resume (void)105{106__builtin_tresume ();107}108109extern __inline void110__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))111__TM_suspend (void)112{113__builtin_tsuspend ();114}115116extern __inline long117__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))118__TM_is_user_abort (void* const __TM_buff)119{120texasru_t texasru = *_TEXASRU_PTR (__TM_buff);121return _TEXASRU_ABORT (texasru);122}123124extern __inline long125__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))126__TM_is_named_user_abort (void* const __TM_buff, unsigned char *__code)127{128texasru_t texasru = *_TEXASRU_PTR (__TM_buff);129130*__code = _TEXASRU_FAILURE_CODE (texasru);131return _TEXASRU_ABORT (texasru);132}133134extern __inline long135__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))136__TM_is_illegal (void* const __TM_buff)137{138texasru_t texasru = *_TEXASRU_PTR (__TM_buff);139return _TEXASRU_DISALLOWED (texasru);140}141142extern __inline long143__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))144__TM_is_footprint_exceeded (void* const __TM_buff)145{146texasru_t texasru = *_TEXASRU_PTR (__TM_buff);147return _TEXASRU_FOOTPRINT_OVERFLOW (texasru);148}149150extern __inline long151__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))152__TM_nesting_depth (void* const __TM_buff)153{154texasrl_t texasrl;155156if (_HTM_STATE (__builtin_ttest ()) == _HTM_NONTRANSACTIONAL)157{158texasrl = *_TEXASRL_PTR (__TM_buff);159if (!_TEXASR_FAILURE_SUMMARY (texasrl))160texasrl = 0;161}162else163texasrl = (texasrl_t) __builtin_get_texasr ();164165return _TEXASR_TRANSACTION_LEVEL (texasrl);166}167168extern __inline long169__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))170__TM_is_nested_too_deep(void* const __TM_buff)171{172texasru_t texasru = *_TEXASRU_PTR (__TM_buff);173return _TEXASRU_NESTING_OVERFLOW (texasru);174}175176extern __inline long177__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))178__TM_is_conflict(void* const __TM_buff)179{180texasru_t texasru = *_TEXASRU_PTR (TM_buff);181/* Return TEXASR bits 11 (Self-Induced Conflict) through18214 (Translation Invalidation Conflict). */183return (_TEXASRU_EXTRACT_BITS (texasru, 14, 4)) ? 1 : 0;184}185186extern __inline long187__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))188__TM_is_failure_persistent(void* const __TM_buff)189{190texasru_t texasru = *_TEXASRU_PTR (__TM_buff);191return _TEXASRU_FAILURE_PERSISTENT (texasru);192}193194extern __inline long195__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))196__TM_failure_address(void* const __TM_buff)197{198return *_TFIAR_PTR (__TM_buff);199}200201extern __inline long long202__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))203__TM_failure_code(void* const __TM_buff)204{205return *_TEXASR_PTR (__TM_buff);206}207208#ifdef __cplusplus209}210#endif211212#endif /* __powerpc__ */213214#ifdef __s390__215216#include <stdint.h>217218/* These intrinsics are being made available for compatibility with219the IBM XL compiler. For documentation please see the "z/OS XL220C/C++ Programming Guide" publically available on the web. */221222static __inline long __attribute__((__always_inline__, __nodebug__))223__TM_simple_begin ()224{225return __builtin_tbegin_nofloat (0);226}227228static __inline long __attribute__((__always_inline__, __nodebug__))229__TM_begin (void* const __tdb)230{231return __builtin_tbegin_nofloat (__tdb);232}233234static __inline long __attribute__((__always_inline__, __nodebug__))235__TM_end ()236{237return __builtin_tend ();238}239240static __inline void __attribute__((__always_inline__))241__TM_abort ()242{243return __builtin_tabort (_HTM_FIRST_USER_ABORT_CODE);244}245246static __inline void __attribute__((__always_inline__, __nodebug__))247__TM_named_abort (unsigned char const __code)248{249return __builtin_tabort ((int)_HTM_FIRST_USER_ABORT_CODE + __code);250}251252static __inline void __attribute__((__always_inline__, __nodebug__))253__TM_non_transactional_store (void* const __addr, long long const __value)254{255__builtin_non_tx_store ((uint64_t*)__addr, (uint64_t)__value);256}257258static __inline long __attribute__((__always_inline__, __nodebug__))259__TM_nesting_depth (void* const __tdb_ptr)260{261int depth = __builtin_tx_nesting_depth ();262struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;263264if (depth != 0)265return depth;266267if (tdb->format != 1)268return 0;269return tdb->nesting_depth;270}271272/* Transaction failure diagnostics */273274static __inline long __attribute__((__always_inline__, __nodebug__))275__TM_is_user_abort (void* const __tdb_ptr)276{277struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;278279if (tdb->format != 1)280return 0;281282return !!(tdb->abort_code >= _HTM_FIRST_USER_ABORT_CODE);283}284285static __inline long __attribute__((__always_inline__, __nodebug__))286__TM_is_named_user_abort (void* const __tdb_ptr, unsigned char* __code)287{288struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;289290if (tdb->format != 1)291return 0;292293if (tdb->abort_code >= _HTM_FIRST_USER_ABORT_CODE)294{295*__code = tdb->abort_code - _HTM_FIRST_USER_ABORT_CODE;296return 1;297}298return 0;299}300301static __inline long __attribute__((__always_inline__, __nodebug__))302__TM_is_illegal (void* const __tdb_ptr)303{304struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;305306return (tdb->format == 1307&& (tdb->abort_code == 4 /* unfiltered program interruption */308|| tdb->abort_code == 11 /* restricted instruction */));309}310311static __inline long __attribute__((__always_inline__, __nodebug__))312__TM_is_footprint_exceeded (void* const __tdb_ptr)313{314struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;315316return (tdb->format == 1317&& (tdb->abort_code == 7 /* fetch overflow */318|| tdb->abort_code == 8 /* store overflow */));319}320321static __inline long __attribute__((__always_inline__, __nodebug__))322__TM_is_nested_too_deep (void* const __tdb_ptr)323{324struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;325326return tdb->format == 1 && tdb->abort_code == 13; /* depth exceeded */327}328329static __inline long __attribute__((__always_inline__, __nodebug__))330__TM_is_conflict (void* const __tdb_ptr)331{332struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;333334return (tdb->format == 1335&& (tdb->abort_code == 9 /* fetch conflict */336|| tdb->abort_code == 10 /* store conflict */));337}338339static __inline long __attribute__((__always_inline__, __nodebug__))340__TM_is_failure_persistent (long const __result)341{342return __result == _HTM_TBEGIN_PERSISTENT;343}344345static __inline long __attribute__((__always_inline__, __nodebug__))346__TM_failure_address (void* const __tdb_ptr)347{348struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;349return tdb->atia;350}351352static __inline long __attribute__((__always_inline__, __nodebug__))353__TM_failure_code (void* const __tdb_ptr)354{355struct __htm_tdb *tdb = (struct __htm_tdb*)__tdb_ptr;356357return tdb->abort_code;358}359360#endif /* __s390__ */361362#endif /* __HTMXLINTRIN_H */363364365