diff --git a/include/ck_pr.h b/include/ck_pr.h index cd2a1805..1eb358e4 100644 --- a/include/ck_pr.h +++ b/include/ck_pr.h @@ -56,16 +56,10 @@ #include "gcc/sparcv9/ck_pr.h" #elif defined(__ppc64__) #include "gcc/ppc64/ck_pr.h" -#elif defined(__s390x__) -#include "gcc/s390x/ck_pr.h" #elif defined(__ppc__) #include "gcc/ppc/ck_pr.h" #elif defined(__arm__) #include "gcc/arm/ck_pr.h" -#elif defined(__aarch64__) -#include "gcc/aarch64/ck_pr.h" -#elif defined(__riscv) && __riscv_xlen == 64 -#include "gcc/riscv64/ck_pr.h" #elif !defined(__GNUC__) #error Your platform is unsupported #endif diff --git a/include/gcc/aarch64/ck_f_pr.h b/include/gcc/aarch64/ck_f_pr.h deleted file mode 100644 index 93ecee07..00000000 --- a/include/gcc/aarch64/ck_f_pr.h +++ /dev/null @@ -1,167 +0,0 @@ -/* DO NOT EDIT. This is auto-generated from feature.sh */ -#define CK_F_PR_ADD_16 -#define CK_F_PR_ADD_32 -#define CK_F_PR_ADD_64 -#define CK_F_PR_ADD_8 -#define CK_F_PR_ADD_CHAR -#define CK_F_PR_ADD_INT -#define CK_F_PR_ADD_PTR -#define CK_F_PR_ADD_SHORT -#define CK_F_PR_ADD_UINT -#define CK_F_PR_AND_16 -#define CK_F_PR_AND_32 -#define CK_F_PR_AND_64 -#define CK_F_PR_AND_8 -#define CK_F_PR_AND_CHAR -#define CK_F_PR_AND_INT -#define CK_F_PR_AND_PTR -#define CK_F_PR_AND_SHORT -#define CK_F_PR_AND_UINT -#define CK_F_PR_BARRIER -#define CK_F_PR_CAS_16 -#define CK_F_PR_CAS_16_VALUE -#define CK_F_PR_CAS_32 -#define CK_F_PR_CAS_32_VALUE -#define CK_F_PR_CAS_64 -#define CK_F_PR_CAS_64_VALUE -#define CK_F_PR_CAS_64_2 -#define CK_F_PR_CAS_64_2_VALUE -#define CK_F_PR_CAS_DOUBLE -#define CK_F_PR_CAS_DOUBLE_VALUE -#define CK_F_PR_CAS_8 -#define CK_F_PR_CAS_8_VALUE -#define CK_F_PR_CAS_CHAR -#define CK_F_PR_CAS_CHAR_VALUE -#define CK_F_PR_CAS_INT -#define CK_F_PR_CAS_INT_VALUE -#define CK_F_PR_CAS_PTR -#define CK_F_PR_CAS_PTR_2 -#define CK_F_PR_CAS_PTR_2_VALUE -#define CK_F_PR_CAS_PTR_VALUE -#define CK_F_PR_CAS_SHORT -#define CK_F_PR_CAS_SHORT_VALUE -#define CK_F_PR_CAS_UINT -#define CK_F_PR_CAS_UINT_VALUE -#define CK_F_PR_DEC_16 -#define CK_F_PR_DEC_32 -#define CK_F_PR_DEC_64 -#define CK_F_PR_DEC_8 -#define CK_F_PR_DEC_CHAR -#define CK_F_PR_DEC_INT -#define CK_F_PR_DEC_PTR -#define CK_F_PR_DEC_SHORT -#define CK_F_PR_DEC_UINT -#define CK_F_PR_FAA_16 -#define CK_F_PR_FAA_32 -#define CK_F_PR_FAA_64 -#define CK_F_PR_FAA_8 -#define CK_F_PR_FAA_CHAR -#define CK_F_PR_FAA_INT -#define CK_F_PR_FAA_PTR -#define CK_F_PR_FAA_SHORT -#define CK_F_PR_FAA_UINT -#define CK_F_PR_FAS_16 -#define CK_F_PR_FAS_32 -#define CK_F_PR_FAS_64 -#define CK_F_PR_FAS_8 -#define CK_F_PR_FAS_CHAR -#define CK_F_PR_FAS_INT -#define CK_F_PR_FAS_PTR -#define CK_F_PR_FAS_SHORT -#define CK_F_PR_FAS_UINT -#define CK_F_PR_FENCE_ATOMIC -#define CK_F_PR_FENCE_ATOMIC_LOAD -#define CK_F_PR_FENCE_ATOMIC_STORE -#define CK_F_PR_FENCE_LOAD -#define CK_F_PR_FENCE_LOAD_ATOMIC -#define CK_F_PR_FENCE_LOAD_DEPENDS -#define CK_F_PR_FENCE_LOAD_STORE -#define CK_F_PR_FENCE_MEMORY -#define CK_F_PR_FENCE_STORE -#define CK_F_PR_FENCE_STORE_ATOMIC -#define CK_F_PR_FENCE_STORE_LOAD -#define CK_F_PR_FENCE_STRICT_ATOMIC -#define CK_F_PR_FENCE_STRICT_ATOMIC_LOAD -#define CK_F_PR_FENCE_STRICT_ATOMIC_STORE -#define CK_F_PR_FENCE_STRICT_LOAD -#define CK_F_PR_FENCE_STRICT_LOAD_ATOMIC -#define CK_F_PR_FENCE_STRICT_LOAD_STORE -#define CK_F_PR_FENCE_STRICT_MEMORY -#define CK_F_PR_FENCE_STRICT_STORE -#define CK_F_PR_FENCE_STRICT_STORE_ATOMIC -#define CK_F_PR_FENCE_STRICT_STORE_LOAD -#define CK_F_PR_INC_16 -#define CK_F_PR_INC_32 -#define CK_F_PR_INC_64 -#define CK_F_PR_INC_8 -#define CK_F_PR_INC_CHAR -#define CK_F_PR_INC_INT -#define CK_F_PR_INC_PTR -#define CK_F_PR_INC_SHORT -#define CK_F_PR_INC_UINT -#define CK_F_PR_LOAD_16 -#define CK_F_PR_LOAD_32 -#define CK_F_PR_LOAD_64 -#define CK_F_PR_LOAD_DOUBLE -#define CK_F_PR_LOAD_8 -#define CK_F_PR_LOAD_CHAR -#define CK_F_PR_LOAD_INT -#define CK_F_PR_LOAD_PTR -#define CK_F_PR_LOAD_SHORT -#define CK_F_PR_LOAD_UINT -#define CK_F_PR_NEG_16 -#define CK_F_PR_NEG_32 -#define CK_F_PR_NEG_64 -#define CK_F_PR_NEG_8 -#define CK_F_PR_NEG_CHAR -#define CK_F_PR_NEG_INT -#define CK_F_PR_NEG_PTR -#define CK_F_PR_NEG_SHORT -#define CK_F_PR_NEG_UINT -#define CK_F_PR_NOT_16 -#define CK_F_PR_NOT_32 -#define CK_F_PR_NOT_64 -#define CK_F_PR_NOT_8 -#define CK_F_PR_NOT_CHAR -#define CK_F_PR_NOT_INT -#define CK_F_PR_NOT_PTR -#define CK_F_PR_NOT_SHORT -#define CK_F_PR_NOT_UINT -#define CK_F_PR_OR_16 -#define CK_F_PR_OR_32 -#define CK_F_PR_OR_64 -#define CK_F_PR_OR_8 -#define CK_F_PR_OR_CHAR -#define CK_F_PR_OR_INT -#define CK_F_PR_OR_PTR -#define CK_F_PR_OR_SHORT -#define CK_F_PR_OR_UINT -#define CK_F_PR_STALL -#define CK_F_PR_STORE_16 -#define CK_F_PR_STORE_32 -#define CK_F_PR_STORE_64 -#define CK_F_PR_STORE_DOUBLE -#define CK_F_PR_STORE_8 -#define CK_F_PR_STORE_CHAR -#define CK_F_PR_STORE_INT -#define CK_F_PR_STORE_PTR -#define CK_F_PR_STORE_SHORT -#define CK_F_PR_STORE_UINT -#define CK_F_PR_SUB_16 -#define CK_F_PR_SUB_32 -#define CK_F_PR_SUB_64 -#define CK_F_PR_SUB_8 -#define CK_F_PR_SUB_CHAR -#define CK_F_PR_SUB_INT -#define CK_F_PR_SUB_PTR -#define CK_F_PR_SUB_SHORT -#define CK_F_PR_SUB_UINT -#define CK_F_PR_XOR_16 -#define CK_F_PR_XOR_32 -#define CK_F_PR_XOR_64 -#define CK_F_PR_XOR_8 -#define CK_F_PR_XOR_CHAR -#define CK_F_PR_XOR_INT -#define CK_F_PR_XOR_PTR -#define CK_F_PR_XOR_SHORT -#define CK_F_PR_XOR_UINT diff --git a/include/gcc/aarch64/ck_pr.h b/include/gcc/aarch64/ck_pr.h deleted file mode 100644 index b1e5bfa1..00000000 --- a/include/gcc/aarch64/ck_pr.h +++ /dev/null @@ -1,227 +0,0 @@ -/* - * Copyright 2009-2016 Samy Al Bahra. - * Copyright 2013-2016 Olivier Houchard. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef CK_PR_AARCH64_H -#define CK_PR_AARCH64_H - -#ifndef CK_PR_H -#error Do not include this file directly, use ck_pr.h -#endif - -#include -#include - -/* - * The following represent supported atomic operations. - * These operations may be emulated. - */ -#include "ck_f_pr.h" - -/* - * Minimum interface requirement met. - */ -#define CK_F_PR - -CK_CC_INLINE static void -ck_pr_stall(void) -{ - - __asm__ __volatile__("" ::: "memory"); - return; -} - -#define CK_DMB_SY __asm __volatile("dmb ish" : : "r" (0) : "memory") -#define CK_DMB_LD __asm __volatile("dmb ishld" : : "r" (0) : "memory") -#define CK_DMB_ST __asm __volatile("dmb ishst" : : "r" (0) : "memory") - -#define CK_PR_FENCE(T, I) \ - CK_CC_INLINE static void \ - ck_pr_fence_strict_##T(void) \ - { \ - I; \ - } - -CK_PR_FENCE(atomic, CK_DMB_ST) -CK_PR_FENCE(atomic_store, CK_DMB_ST) -CK_PR_FENCE(atomic_load, CK_DMB_SY) -CK_PR_FENCE(store_atomic, CK_DMB_ST) -CK_PR_FENCE(load_atomic, CK_DMB_SY) -CK_PR_FENCE(store, CK_DMB_ST) -CK_PR_FENCE(store_load, CK_DMB_SY) -CK_PR_FENCE(load, CK_DMB_LD) -CK_PR_FENCE(load_store, CK_DMB_SY) -CK_PR_FENCE(memory, CK_DMB_SY) -CK_PR_FENCE(acquire, CK_DMB_SY) -CK_PR_FENCE(release, CK_DMB_SY) -CK_PR_FENCE(acqrel, CK_DMB_SY) -CK_PR_FENCE(lock, CK_DMB_SY) -CK_PR_FENCE(unlock, CK_DMB_SY) - -#undef CK_PR_FENCE - -#undef CK_DMB_SI -#undef CK_DMB_LD -#undef CK_DMB_ST - -#define CK_PR_LOAD(S, M, T, I) \ - CK_CC_INLINE static T \ - ck_pr_md_load_##S(const M *target) \ - { \ - long r = 0; \ - __asm__ __volatile__(I " %w0, [%1]\n" \ - : "=r" (r) \ - : "r" (target) \ - : "memory"); \ - return ((T)r); \ - } -#define CK_PR_LOAD_64(S, M, T, I) \ - CK_CC_INLINE static T \ - ck_pr_md_load_##S(const M *target) \ - { \ - long r = 0; \ - __asm__ __volatile__(I " %0, [%1]\n" \ - : "=r" (r) \ - : "r" (target) \ - : "memory"); \ - return ((T)r); \ - } - - -CK_PR_LOAD_64(ptr, void, void *, "ldr") - -#define CK_PR_LOAD_S(S, T, I) CK_PR_LOAD(S, T, T, I) -#define CK_PR_LOAD_S_64(S, T, I) CK_PR_LOAD_64(S, T, T, I) - -CK_PR_LOAD_S_64(64, uint64_t, "ldr") -CK_PR_LOAD_S(32, uint32_t, "ldr") -CK_PR_LOAD_S(16, uint16_t, "ldrh") -CK_PR_LOAD_S(8, uint8_t, "ldrb") -CK_PR_LOAD_S(uint, unsigned int, "ldr") -CK_PR_LOAD_S(int, int, "ldr") -CK_PR_LOAD_S(short, short, "ldrh") -CK_PR_LOAD_S(char, char, "ldrb") -#ifndef CK_PR_DISABLE_DOUBLE -CK_PR_LOAD_S_64(double, double, "ldr") -#endif - -#undef CK_PR_LOAD_S -#undef CK_PR_LOAD_S_64 -#undef CK_PR_LOAD -#undef CK_PR_LAOD_64 - -#define CK_PR_STORE(S, M, T, I) \ - CK_CC_INLINE static void \ - ck_pr_md_store_##S(M *target, T v) \ - { \ - __asm__ __volatile__(I " %w2, [%1]" \ - : "=m" (*(T *)target) \ - : "r" (target), \ - "r" (v) \ - : "memory"); \ - return; \ - } -#define CK_PR_STORE_64(S, M, T, I) \ - CK_CC_INLINE static void \ - ck_pr_md_store_##S(M *target, T v) \ - { \ - __asm__ __volatile__(I " %2, [%1]" \ - : "=m" (*(T *)target) \ - : "r" (target), \ - "r" (v) \ - : "memory"); \ - return; \ - } - -CK_PR_STORE_64(ptr, void, const void *, "str") - -#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, I) -#define CK_PR_STORE_S_64(S, T, I) CK_PR_STORE_64(S, T, T, I) - -CK_PR_STORE_S_64(64, uint64_t, "str") -CK_PR_STORE_S(32, uint32_t, "str") -CK_PR_STORE_S(16, uint16_t, "strh") -CK_PR_STORE_S(8, uint8_t, "strb") -CK_PR_STORE_S(uint, unsigned int, "str") -CK_PR_STORE_S(int, int, "str") -CK_PR_STORE_S(short, short, "strh") -CK_PR_STORE_S(char, char, "strb") -#ifndef CK_PR_DISABLE_DOUBLE -CK_PR_STORE_S_64(double, double, "str") -#endif - -#undef CK_PR_STORE_S -#undef CK_PR_STORE_S_64 -#undef CK_PR_STORE -#undef CK_PR_STORE_64 - -#ifdef CK_MD_LSE_ENABLE -#include "ck_pr_lse.h" -#else -#include "ck_pr_llsc.h" -#endif - -/* - * ck_pr_neg_*() functions can only be implemented via LL/SC, as there are no - * LSE alternatives. - */ -#define CK_PR_NEG(N, M, T, W, R) \ - CK_CC_INLINE static void \ - ck_pr_neg_##N(M *target) \ - { \ - T previous = 0; \ - T tmp = 0; \ - __asm__ __volatile__("1:\n" \ - "ldxr" W " %" R "0, [%2]\n"\ - "neg %" R "0, %" R "0\n" \ - "stxr" W " %w1, %" R "0, [%2]\n" \ - "cbnz %w1, 1b\n" \ - : "=&r" (previous), \ - "=&r" (tmp) \ - : "r" (target) \ - : "memory", "cc"); \ - return; \ - } - -CK_PR_NEG(ptr, void, void *, "", "") -CK_PR_NEG(64, uint64_t, uint64_t, "", "") - -#define CK_PR_NEG_S(S, T, W) \ - CK_PR_NEG(S, T, T, W, "w") \ - -CK_PR_NEG_S(32, uint32_t, "") -CK_PR_NEG_S(uint, unsigned int, "") -CK_PR_NEG_S(int, int, "") -CK_PR_NEG_S(16, uint16_t, "h") -CK_PR_NEG_S(8, uint8_t, "b") -CK_PR_NEG_S(short, short, "h") -CK_PR_NEG_S(char, char, "b") - -#undef CK_PR_NEG_S -#undef CK_PR_NEG - -#endif /* CK_PR_AARCH64_H */ - diff --git a/include/gcc/aarch64/ck_pr_llsc.h b/include/gcc/aarch64/ck_pr_llsc.h deleted file mode 100644 index 3832ddb4..00000000 --- a/include/gcc/aarch64/ck_pr_llsc.h +++ /dev/null @@ -1,352 +0,0 @@ -/* - * Copyright 2009-2016 Samy Al Bahra. - * Copyright 2013-2016 Olivier Houchard. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef CK_PR_AARCH64_LLSC_H -#define CK_PR_AARCH64_LLSC_H - -#ifndef CK_PR_H -#error Do not include this file directly, use ck_pr.h -#endif - -CK_CC_INLINE static bool -ck_pr_cas_64_2_value(uint64_t target[2], uint64_t compare[2], uint64_t set[2], uint64_t value[2]) -{ - uint64_t tmp1, tmp2; - - __asm__ __volatile__("1:\n" - "ldxp %0, %1, [%4]\n" - "mov %2, %0\n" - "mov %3, %1\n" - "eor %0, %0, %5\n" - "eor %1, %1, %6\n" - "orr %1, %0, %1\n" - "mov %w0, #0\n" - "cbnz %1, 2f\n" - "stxp %w0, %7, %8, [%4]\n" - "cbnz %w0, 1b\n" - "mov %w0, #1\n" - "2:" - : "=&r" (tmp1), "=&r" (tmp2), "=&r" (value[0]), "=&r" (value[1]) - : "r" (target), "r" (compare[0]), "r" (compare[1]), "r" (set[0]), "r" (set[1]) - : "cc", "memory"); - - return (tmp1); -} - -CK_CC_INLINE static bool -ck_pr_cas_ptr_2_value(void *target, void *compare, void *set, void *value) -{ - return (ck_pr_cas_64_2_value(CK_CPP_CAST(uint64_t *, target), - CK_CPP_CAST(uint64_t *, compare), - CK_CPP_CAST(uint64_t *, set), - CK_CPP_CAST(uint64_t *, value))); -} - -CK_CC_INLINE static bool -ck_pr_cas_64_2(uint64_t target[2], uint64_t compare[2], uint64_t set[2]) -{ - uint64_t tmp1, tmp2; - - __asm__ __volatile__("1:\n" - "ldxp %0, %1, [%2]\n" - "eor %0, %0, %3\n" - "eor %1, %1, %4\n" - "orr %1, %0, %1\n" - "mov %w0, #0\n" - "cbnz %1, 2f\n" - "stxp %w0, %5, %6, [%2]\n" - "cbnz %w0, 1b\n" - "mov %w0, #1\n" - "2:" - : "=&r" (tmp1), "=&r" (tmp2) - : "r" (target), "r" (compare[0]), "r" (compare[1]), "r" (set[0]), "r" (set[1]) - : "cc", "memory"); - - return (tmp1); -} -CK_CC_INLINE static bool -ck_pr_cas_ptr_2(void *target, void *compare, void *set) -{ - return (ck_pr_cas_64_2(CK_CPP_CAST(uint64_t *, target), - CK_CPP_CAST(uint64_t *, compare), - CK_CPP_CAST(uint64_t *, set))); -} - - -#define CK_PR_CAS(N, M, T, W, R) \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N##_value(M *target, T compare, T set, M *value) \ - { \ - T previous; \ - T tmp; \ - __asm__ __volatile__("1:\n" \ - "ldxr" W " %" R "0, [%2]\n" \ - "cmp %" R "0, %" R "4\n" \ - "b.ne 2f\n" \ - "stxr" W " %w1, %" R "3, [%2]\n" \ - "cbnz %w1, 1b\n" \ - "2:" \ - : "=&r" (previous), \ - "=&r" (tmp) \ - : "r" (target), \ - "r" (set), \ - "r" (compare) \ - : "memory", "cc"); \ - *(T *)value = previous; \ - return (previous == compare); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N(M *target, T compare, T set) \ - { \ - T previous; \ - T tmp; \ - __asm__ __volatile__( \ - "1:\n" \ - "ldxr" W " %" R "0, [%2]\n" \ - "cmp %" R "0, %" R "4\n" \ - "b.ne 2f\n" \ - "stxr" W " %w1, %" R "3, [%2]\n" \ - "cbnz %w1, 1b\n" \ - "2:" \ - : "=&r" (previous), \ - "=&r" (tmp) \ - : "r" (target), \ - "r" (set), \ - "r" (compare) \ - : "memory", "cc"); \ - return (previous == compare); \ - } - -CK_PR_CAS(ptr, void, void *, "", "") - -#define CK_PR_CAS_S(N, M, W, R) CK_PR_CAS(N, M, M, W, R) -CK_PR_CAS_S(64, uint64_t, "", "") -#ifndef CK_PR_DISABLE_DOUBLE -CK_PR_CAS_S(double, double, "", "") -#endif -CK_PR_CAS_S(32, uint32_t, "", "w") -CK_PR_CAS_S(uint, unsigned int, "", "w") -CK_PR_CAS_S(int, int, "", "w") -CK_PR_CAS_S(16, uint16_t, "h", "w") -CK_PR_CAS_S(8, uint8_t, "b", "w") -CK_PR_CAS_S(short, short, "h", "w") -CK_PR_CAS_S(char, char, "b", "w") - - -#undef CK_PR_CAS_S -#undef CK_PR_CAS - -#define CK_PR_FAS(N, M, T, W, R) \ - CK_CC_INLINE static T \ - ck_pr_fas_##N(M *target, T v) \ - { \ - T previous; \ - T tmp; \ - __asm__ __volatile__("1:\n" \ - "ldxr" W " %" R "0, [%2]\n"\ - "stxr" W " %w1, %" R "3, [%2]\n"\ - "cbnz %w1, 1b\n" \ - : "=&r" (previous), \ - "=&r" (tmp) \ - : "r" (target), \ - "r" (v) \ - : "memory", "cc"); \ - return (previous); \ - } - -CK_PR_FAS(64, uint64_t, uint64_t, "", "") -CK_PR_FAS(32, uint32_t, uint32_t, "", "w") -CK_PR_FAS(ptr, void, void *, "", "") -CK_PR_FAS(int, int, int, "", "w") -CK_PR_FAS(uint, unsigned int, unsigned int, "", "w") -CK_PR_FAS(16, uint16_t, uint16_t, "h", "w") -CK_PR_FAS(8, uint8_t, uint8_t, "b", "w") -CK_PR_FAS(short, short, short, "h", "w") -CK_PR_FAS(char, char, char, "b", "w") - - -#undef CK_PR_FAS - -#define CK_PR_UNARY(O, N, M, T, I, W, R) \ - CK_CC_INLINE static void \ - ck_pr_##O##_##N(M *target) \ - { \ - T previous = 0; \ - T tmp = 0; \ - __asm__ __volatile__("1:\n" \ - "ldxr" W " %" R "0, [%2]\n"\ - I "\n" \ - "stxr" W " %w1, %" R "0, [%2]\n" \ - "cbnz %w1, 1b\n" \ - : "=&r" (previous), \ - "=&r" (tmp) \ - : "r" (target) \ - : "memory", "cc"); \ - return; \ - } - -CK_PR_UNARY(inc, ptr, void, void *, "add %0, %0, #1", "", "") -CK_PR_UNARY(dec, ptr, void, void *, "sub %0, %0, #1", "", "") -CK_PR_UNARY(not, ptr, void, void *, "mvn %0, %0", "", "") -CK_PR_UNARY(inc, 64, uint64_t, uint64_t, "add %0, %0, #1", "", "") -CK_PR_UNARY(dec, 64, uint64_t, uint64_t, "sub %0, %0, #1", "", "") -CK_PR_UNARY(not, 64, uint64_t, uint64_t, "mvn %0, %0", "", "") - -#define CK_PR_UNARY_S(S, T, W) \ - CK_PR_UNARY(inc, S, T, T, "add %w0, %w0, #1", W, "w") \ - CK_PR_UNARY(dec, S, T, T, "sub %w0, %w0, #1", W, "w") \ - CK_PR_UNARY(not, S, T, T, "mvn %w0, %w0", W, "w") \ - -CK_PR_UNARY_S(32, uint32_t, "") -CK_PR_UNARY_S(uint, unsigned int, "") -CK_PR_UNARY_S(int, int, "") -CK_PR_UNARY_S(16, uint16_t, "h") -CK_PR_UNARY_S(8, uint8_t, "b") -CK_PR_UNARY_S(short, short, "h") -CK_PR_UNARY_S(char, char, "b") - -#undef CK_PR_UNARY_S -#undef CK_PR_UNARY - -#define CK_PR_BINARY(O, N, M, T, I, W, R) \ - CK_CC_INLINE static void \ - ck_pr_##O##_##N(M *target, T delta) \ - { \ - T previous; \ - T tmp; \ - __asm__ __volatile__("1:\n" \ - "ldxr" W " %" R "0, [%2]\n"\ - I " %" R "0, %" R "0, %" R "3\n" \ - "stxr" W " %w1, %" R "0, [%2]\n" \ - "cbnz %w1, 1b\n" \ - : "=&r" (previous), \ - "=&r" (tmp) \ - : "r" (target), \ - "r" (delta) \ - : "memory", "cc"); \ - return; \ - } - -CK_PR_BINARY(and, ptr, void, uintptr_t, "and", "", "") -CK_PR_BINARY(add, ptr, void, uintptr_t, "add", "", "") -CK_PR_BINARY(or, ptr, void, uintptr_t, "orr", "", "") -CK_PR_BINARY(sub, ptr, void, uintptr_t, "sub", "", "") -CK_PR_BINARY(xor, ptr, void, uintptr_t, "eor", "", "") -CK_PR_BINARY(and, 64, uint64_t, uint64_t, "and", "", "") -CK_PR_BINARY(add, 64, uint64_t, uint64_t, "add", "", "") -CK_PR_BINARY(or, 64, uint64_t, uint64_t, "orr", "", "") -CK_PR_BINARY(sub, 64, uint64_t, uint64_t, "sub", "", "") -CK_PR_BINARY(xor, 64, uint64_t, uint64_t, "eor", "", "") - -#define CK_PR_BINARY_S(S, T, W) \ - CK_PR_BINARY(and, S, T, T, "and", W, "w") \ - CK_PR_BINARY(add, S, T, T, "add", W, "w") \ - CK_PR_BINARY(or, S, T, T, "orr", W, "w") \ - CK_PR_BINARY(sub, S, T, T, "sub", W, "w") \ - CK_PR_BINARY(xor, S, T, T, "eor", W, "w") - -CK_PR_BINARY_S(32, uint32_t, "") -CK_PR_BINARY_S(uint, unsigned int, "") -CK_PR_BINARY_S(int, int, "") -CK_PR_BINARY_S(16, uint16_t, "h") -CK_PR_BINARY_S(8, uint8_t, "b") -CK_PR_BINARY_S(short, short, "h") -CK_PR_BINARY_S(char, char, "b") - -#undef CK_PR_BINARY_S -#undef CK_PR_BINARY - -CK_CC_INLINE static void * -ck_pr_faa_ptr(void *target, uintptr_t delta) -{ - uintptr_t previous, r, tmp; - - __asm__ __volatile__("1:\n" - "ldxr %0, [%3]\n" - "add %1, %4, %0\n" - "stxr %w2, %1, [%3]\n" - "cbnz %w2, 1b\n" - : "=&r" (previous), - "=&r" (r), - "=&r" (tmp) - : "r" (target), - "r" (delta) - : "memory", "cc"); - - return (void *)(previous); -} - -CK_CC_INLINE static uint64_t -ck_pr_faa_64(uint64_t *target, uint64_t delta) -{ - uint64_t previous, r, tmp; - - __asm__ __volatile__("1:\n" - "ldxr %0, [%3]\n" - "add %1, %4, %0\n" - "stxr %w2, %1, [%3]\n" - "cbnz %w2, 1b;" - : "=&r" (previous), - "=&r" (r), - "=&r" (tmp) - : "r" (target), - "r" (delta) - : "memory", "cc"); - - return (previous); -} - -#define CK_PR_FAA(S, T, W) \ - CK_CC_INLINE static T \ - ck_pr_faa_##S(T *target, T delta) \ - { \ - T previous, r, tmp; \ - __asm__ __volatile__("1:\n" \ - "ldxr" W " %w0, [%3]\n" \ - "add %w1, %w4, %w0\n" \ - "stxr" W " %w2, %w1, [%3]\n" \ - "cbnz %w2, 1b\n" \ - : "=&r" (previous), \ - "=&r" (r), \ - "=&r" (tmp) \ - : "r" (target), \ - "r" (delta) \ - : "memory", "cc"); \ - return (previous); \ - } - -CK_PR_FAA(32, uint32_t, "") -CK_PR_FAA(uint, unsigned int, "") -CK_PR_FAA(int, int, "") -CK_PR_FAA(16, uint16_t, "h") -CK_PR_FAA(8, uint8_t, "b") -CK_PR_FAA(short, short, "h") -CK_PR_FAA(char, char, "b") - -#undef CK_PR_FAA - -#endif /* CK_PR_AARCH64_LLSC_H */ diff --git a/include/gcc/aarch64/ck_pr_lse.h b/include/gcc/aarch64/ck_pr_lse.h deleted file mode 100644 index e450e72d..00000000 --- a/include/gcc/aarch64/ck_pr_lse.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright 2009-2016 Samy Al Bahra. - * Copyright 2013-2016 Olivier Houchard. - * Copyright 2016 Alexey Kopytov. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef CK_PR_AARCH64_LSE_H -#define CK_PR_AARCH64_LSE_H - -#error bite -#ifndef CK_PR_H -#error Do not include this file directly, use ck_pr.h -#endif - -CK_CC_INLINE static bool -ck_pr_cas_64_2_value(uint64_t target[2], uint64_t compare[2], uint64_t set[2], uint64_t value[2]) -{ - uint64_t tmp1; - uint64_t tmp2; - register uint64_t x0 __asm__ ("x0") = compare[0]; - register uint64_t x1 __asm__ ("x1") = compare[1]; - register uint64_t x2 __asm__ ("x2") = set[0]; - register uint64_t x3 __asm__ ("x3") = set[1]; - - __asm__ __volatile__("casp %0, %1, %4, %5, [%6]\n" - "eor %2, %0, %7\n" - "eor %3, %1, %8\n" - "orr %2, %2, %3\n" - : "+&r" (x0), "+&r" (x1), "=&r" (tmp1), "=&r" (tmp2) - : "r" (x2), "r" (x3), "r" (target), "r" (compare[0]), "r" (compare[1]) - : "memory"); - - value[0] = x0; - value[1] = x1; - - return (!!tmp1); -} - -CK_CC_INLINE static bool -ck_pr_cas_ptr_2_value(void *target, void *compare, void *set, void *value) -{ - return (ck_pr_cas_64_2_value(CK_CPP_CAST(uint64_t *, target), - CK_CPP_CAST(uint64_t *, compare), - CK_CPP_CAST(uint64_t *, set), - CK_CPP_CAST(uint64_t *, value))); -} - -CK_CC_INLINE static bool -ck_pr_cas_64_2(uint64_t target[2], uint64_t compare[2], uint64_t set[2]) -{ - register uint64_t x0 __asm__ ("x0") = compare[0]; - register uint64_t x1 __asm__ ("x1") = compare[1]; - register uint64_t x2 __asm__ ("x2") = set[0]; - register uint64_t x3 __asm__ ("x3") = set[1]; - - __asm__ __volatile__("casp %0, %1, %2, %3, [%4]\n" - "eor %0, %0, %5\n" - "eor %1, %1, %6\n" - "orr %0, %0, %1\n" - : "+&r" (x0), "+&r" (x1) - : "r" (x2), "r" (x3), "r" (target), "r" (compare[0]), "r" (compare[1]) - : "memory"); - - return (!!x0); -} -CK_CC_INLINE static bool -ck_pr_cas_ptr_2(void *target, void *compare, void *set) -{ - return (ck_pr_cas_64_2(CK_CPP_CAST(uint64_t *, target), - CK_CPP_CAST(uint64_t *, compare), - CK_CPP_CAST(uint64_t *, set))); -} - - -#define CK_PR_CAS(N, M, T, W, R) \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N##_value(M *target, T compare, T set, M *value) \ - { \ - *(T *)value = compare; \ - __asm__ __volatile__( \ - "cas" W " %" R "0, %" R "2, [%1]\n"\ - : "+&r" (*(T *)value) \ - : "r" (target), \ - "r" (set) \ - : "memory"); \ - return (*(T *)value == compare); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N(M *target, T compare, T set) \ - { \ - T previous = compare; \ - __asm__ __volatile__( \ - "cas" W " %" R "0, %" R "2, [%1]\n"\ - : "+&r" (previous) \ - : "r" (target), \ - "r" (set) \ - : "memory"); \ - return (previous == compare); \ - } - -CK_PR_CAS(ptr, void, void *, "", "") - -#define CK_PR_CAS_S(N, M, W, R) CK_PR_CAS(N, M, M, W, R) -CK_PR_CAS_S(64, uint64_t, "", "") -#ifndef CK_PR_DISABLE_DOUBLE -CK_PR_CAS_S(double, double, "", "") -#endif -CK_PR_CAS_S(32, uint32_t, "", "w") -CK_PR_CAS_S(uint, unsigned int, "", "w") -CK_PR_CAS_S(int, int, "", "w") -CK_PR_CAS_S(16, uint16_t, "h", "w") -CK_PR_CAS_S(8, uint8_t, "b", "w") -CK_PR_CAS_S(short, short, "h", "w") -CK_PR_CAS_S(char, char, "b", "w") - - -#undef CK_PR_CAS_S -#undef CK_PR_CAS - -#define CK_PR_FAS(N, M, T, W, R) \ - CK_CC_INLINE static T \ - ck_pr_fas_##N(M *target, T v) \ - { \ - T previous; \ - __asm__ __volatile__( \ - "swp" W " %" R "2, %" R "0, [%1]\n"\ - : "=&r" (previous) \ - : "r" (target), \ - "r" (v) \ - : "memory"); \ - return (previous); \ - } - -CK_PR_FAS(64, uint64_t, uint64_t, "", "") -CK_PR_FAS(32, uint32_t, uint32_t, "", "w") -CK_PR_FAS(ptr, void, void *, "", "") -CK_PR_FAS(int, int, int, "", "w") -CK_PR_FAS(uint, unsigned int, unsigned int, "", "w") -CK_PR_FAS(16, uint16_t, uint16_t, "h", "w") -CK_PR_FAS(8, uint8_t, uint8_t, "b", "w") -CK_PR_FAS(short, short, short, "h", "w") -CK_PR_FAS(char, char, char, "b", "w") - - -#undef CK_PR_FAS - -#define CK_PR_UNARY(O, N, M, T, I, W, R, S) \ - CK_CC_INLINE static void \ - ck_pr_##O##_##N(M *target) \ - { \ - __asm__ __volatile__(I "\n" \ - "st" S W " " R "0, [%0]\n" \ - : \ - : "r" (target) \ - : "x0", "memory"); \ - return; \ - } - -CK_PR_UNARY(inc, ptr, void, void *, "mov x0, 1", "", "x", "add") -CK_PR_UNARY(dec, ptr, void, void *, "mov x0, -1", "", "x", "add") -CK_PR_UNARY(not, ptr, void, void *, "mov x0, -1", "", "x", "eor") -CK_PR_UNARY(inc, 64, uint64_t, uint64_t, "mov x0, 1", "", "x", "add") -CK_PR_UNARY(dec, 64, uint64_t, uint64_t, "mov x0, -1", "", "x", "add") -CK_PR_UNARY(not, 64, uint64_t, uint64_t, "mov x0, -1", "", "x", "eor") - -#define CK_PR_UNARY_S(S, T, W) \ - CK_PR_UNARY(inc, S, T, T, "mov w0, 1", W, "w", "add") \ - CK_PR_UNARY(dec, S, T, T, "mov w0, -1", W, "w", "add") \ - CK_PR_UNARY(not, S, T, T, "mov w0, -1", W, "w", "eor") \ - -CK_PR_UNARY_S(32, uint32_t, "") -CK_PR_UNARY_S(uint, unsigned int, "") -CK_PR_UNARY_S(int, int, "") -CK_PR_UNARY_S(16, uint16_t, "h") -CK_PR_UNARY_S(8, uint8_t, "b") -CK_PR_UNARY_S(short, short, "h") -CK_PR_UNARY_S(char, char, "b") - -#undef CK_PR_UNARY_S -#undef CK_PR_UNARY - -#define CK_PR_BINARY(O, N, M, T, S, W, R, I) \ - CK_CC_INLINE static void \ - ck_pr_##O##_##N(M *target, T delta) \ - { \ - __asm__ __volatile__(I "\n" \ - "st" S W " %" R "0, [%1]\n"\ - : "+&r" (delta) \ - : "r" (target) \ - : "memory"); \ - return; \ - } - -CK_PR_BINARY(and, ptr, void, uintptr_t, "clr", "", "", "mvn %0, %0") -CK_PR_BINARY(add, ptr, void, uintptr_t, "add", "", "", "") -CK_PR_BINARY(or, ptr, void, uintptr_t, "set", "", "", "") -CK_PR_BINARY(sub, ptr, void, uintptr_t, "add", "", "", "neg %0, %0") -CK_PR_BINARY(xor, ptr, void, uintptr_t, "eor", "", "", "") -CK_PR_BINARY(and, 64, uint64_t, uint64_t, "clr", "", "", "mvn %0, %0") -CK_PR_BINARY(add, 64, uint64_t, uint64_t, "add", "", "", "") -CK_PR_BINARY(or, 64, uint64_t, uint64_t, "set", "", "", "") -CK_PR_BINARY(sub, 64, uint64_t, uint64_t, "add", "", "", "neg %0, %0") -CK_PR_BINARY(xor, 64, uint64_t, uint64_t, "eor", "", "", "") - -#define CK_PR_BINARY_S(S, T, W) \ - CK_PR_BINARY(and, S, T, T, "clr", W, "w", "mvn %w0, %w0") \ - CK_PR_BINARY(add, S, T, T, "add", W, "w", "") \ - CK_PR_BINARY(or, S, T, T, "set", W, "w", "") \ - CK_PR_BINARY(sub, S, T, T, "add", W, "w", "neg %w0, %w0") \ - CK_PR_BINARY(xor, S, T, T, "eor", W, "w", "") - -CK_PR_BINARY_S(32, uint32_t, "") -CK_PR_BINARY_S(uint, unsigned int, "") -CK_PR_BINARY_S(int, int, "") -CK_PR_BINARY_S(16, uint16_t, "h") -CK_PR_BINARY_S(8, uint8_t, "b") -CK_PR_BINARY_S(short, short, "h") -CK_PR_BINARY_S(char, char, "b") - -#undef CK_PR_BINARY_S -#undef CK_PR_BINARY - -CK_CC_INLINE static void * -ck_pr_faa_ptr(void *target, uintptr_t delta) -{ - uintptr_t previous; - - __asm__ __volatile__( - "ldadd %2, %0, [%1]\n" - : "=r" (previous) - : "r" (target), - "r" (delta) - : "memory"); - - return (void *)(previous); -} - -CK_CC_INLINE static uint64_t -ck_pr_faa_64(uint64_t *target, uint64_t delta) -{ - uint64_t previous; - - __asm__ __volatile__( - "ldadd %2, %0, [%1]\n" - : "=r" (previous) - : "r" (target), - "r" (delta) - : "memory"); - - return (previous); -} - -#define CK_PR_FAA(S, T, W) \ - CK_CC_INLINE static T \ - ck_pr_faa_##S(T *target, T delta) \ - { \ - T previous; \ - __asm__ __volatile__( \ - "ldadd" W " %w2, %w0, [%1]\n" \ - : "=r" (previous) \ - : "r" (target), \ - "r" (delta) \ - : "memory"); \ - return (previous); \ - } - -CK_PR_FAA(32, uint32_t, "") -CK_PR_FAA(uint, unsigned int, "") -CK_PR_FAA(int, int, "") -CK_PR_FAA(16, uint16_t, "h") -CK_PR_FAA(8, uint8_t, "b") -CK_PR_FAA(short, short, "h") -CK_PR_FAA(char, char, "b") - -#undef CK_PR_FAA - -#endif /* CK_PR_AARCH64_LSE_H */ diff --git a/include/gcc/riscv64/ck_f_pr.h b/include/gcc/riscv64/ck_f_pr.h deleted file mode 100644 index 72b83734..00000000 --- a/include/gcc/riscv64/ck_f_pr.h +++ /dev/null @@ -1,134 +0,0 @@ -/* DO NOT EDIT. This is auto-generated from feature.sh */ -#define CK_F_PR_ADD_32 -#define CK_F_PR_ADD_64 -#define CK_F_PR_ADD_INT -#define CK_F_PR_ADD_PTR -#define CK_F_PR_ADD_UINT -#define CK_F_PR_AND_32 -#define CK_F_PR_AND_64 -#define CK_F_PR_AND_INT -#define CK_F_PR_AND_PTR -#define CK_F_PR_AND_UINT -#define CK_F_PR_BTC_32 -#define CK_F_PR_BTC_64 -#define CK_F_PR_BTC_INT -#define CK_F_PR_BTC_PTR -#define CK_F_PR_BTC_UINT -#define CK_F_PR_BTR_32 -#define CK_F_PR_BTR_64 -#define CK_F_PR_BTR_INT -#define CK_F_PR_BTR_PTR -#define CK_F_PR_BTR_UINT -#define CK_F_PR_BTS_32 -#define CK_F_PR_BTS_64 -#define CK_F_PR_BTS_INT -#define CK_F_PR_BTS_PTR -#define CK_F_PR_BTS_UINT -#define CK_F_PR_CAS_32 -#define CK_F_PR_CAS_32_VALUE -#define CK_F_PR_CAS_64 -#define CK_F_PR_CAS_64_VALUE -#define CK_F_PR_CAS_DOUBLE -#define CK_F_PR_CAS_DOUBLE_VALUE -#define CK_F_PR_CAS_INT -#define CK_F_PR_CAS_INT_VALUE -#define CK_F_PR_CAS_PTR -#define CK_F_PR_CAS_PTR_VALUE -#define CK_F_PR_CAS_UINT -#define CK_F_PR_CAS_UINT_VALUE -#define CK_F_PR_DEC_32 -#define CK_F_PR_DEC_32_ZERO -#define CK_F_PR_DEC_64 -#define CK_F_PR_DEC_64_ZERO -#define CK_F_PR_DEC_INT -#define CK_F_PR_DEC_INT_ZERO -#define CK_F_PR_DEC_PTR -#define CK_F_PR_DEC_PTR_ZERO -#define CK_F_PR_DEC_UINT -#define CK_F_PR_DEC_UINT_ZERO -#define CK_F_PR_FAA_32 -#define CK_F_PR_FAA_64 -#define CK_F_PR_FAA_INT -#define CK_F_PR_FAA_PTR -#define CK_F_PR_FAA_UINT -#define CK_F_PR_FAS_32 -#define CK_F_PR_FAS_64 -#define CK_F_PR_FAS_INT -#define CK_F_PR_FAS_PTR -#define CK_F_PR_FAS_UINT -#define CK_F_PR_FENCE_STRICT_ACQREL -#define CK_F_PR_FENCE_STRICT_ACQUIRE -#define CK_F_PR_FENCE_STRICT_ATOMIC -#define CK_F_PR_FENCE_STRICT_ATOMIC_LOAD -#define CK_F_PR_FENCE_STRICT_ATOMIC_STORE -#define CK_F_PR_FENCE_STRICT_LOAD -#define CK_F_PR_FENCE_STRICT_LOAD_ATOMIC -#define CK_F_PR_FENCE_STRICT_LOAD_STORE -#define CK_F_PR_FENCE_STRICT_LOCK -#define CK_F_PR_FENCE_STRICT_MEMORY -#define CK_F_PR_FENCE_STRICT_RELEASE -#define CK_F_PR_FENCE_STRICT_STORE -#define CK_F_PR_FENCE_STRICT_STORE_ATOMIC -#define CK_F_PR_FENCE_STRICT_STORE_LOAD -#define CK_F_PR_FENCE_STRICT_UNLOCK -#define CK_F_PR_INC_32 -#define CK_F_PR_INC_32_ZERO -#define CK_F_PR_INC_64 -#define CK_F_PR_INC_64_ZERO -#define CK_F_PR_INC_INT -#define CK_F_PR_INC_INT_ZERO -#define CK_F_PR_INC_PTR -#define CK_F_PR_INC_PTR_ZERO -#define CK_F_PR_INC_UINT -#define CK_F_PR_INC_UINT_ZERO -#define CK_F_PR_LOAD_16 -#define CK_F_PR_LOAD_32 -#define CK_F_PR_LOAD_64 -#define CK_F_PR_LOAD_8 -#define CK_F_PR_LOAD_CHAR -#define CK_F_PR_LOAD_DOUBLE -#define CK_F_PR_LOAD_INT -#define CK_F_PR_LOAD_PTR -#define CK_F_PR_LOAD_SHORT -#define CK_F_PR_LOAD_UINT -#define CK_F_PR_NEG_32 -#define CK_F_PR_NEG_32_ZERO -#define CK_F_PR_NEG_64 -#define CK_F_PR_NEG_64_ZERO -#define CK_F_PR_NEG_INT -#define CK_F_PR_NEG_INT_ZERO -#define CK_F_PR_NEG_PTR -#define CK_F_PR_NEG_PTR_ZERO -#define CK_F_PR_NEG_UINT -#define CK_F_PR_NEG_UINT_ZERO -#define CK_F_PR_NOT_32 -#define CK_F_PR_NOT_64 -#define CK_F_PR_NOT_INT -#define CK_F_PR_NOT_PTR -#define CK_F_PR_NOT_UINT -#define CK_F_PR_OR_32 -#define CK_F_PR_OR_64 -#define CK_F_PR_OR_INT -#define CK_F_PR_OR_PTR -#define CK_F_PR_OR_UINT -#define CK_F_PR_STALL -#define CK_F_PR_STORE_16 -#define CK_F_PR_STORE_32 -#define CK_F_PR_STORE_64 -#define CK_F_PR_STORE_8 -#define CK_F_PR_STORE_CHAR -#define CK_F_PR_STORE_DOUBLE -#define CK_F_PR_STORE_INT -#define CK_F_PR_STORE_PTR -#define CK_F_PR_STORE_SHORT -#define CK_F_PR_STORE_UINT -#define CK_F_PR_SUB_32 -#define CK_F_PR_SUB_64 -#define CK_F_PR_SUB_INT -#define CK_F_PR_SUB_PTR -#define CK_F_PR_SUB_UINT -#define CK_F_PR_XOR_32 -#define CK_F_PR_XOR_64 -#define CK_F_PR_XOR_INT -#define CK_F_PR_XOR_PTR -#define CK_F_PR_XOR_UINT diff --git a/include/gcc/riscv64/ck_pr.h b/include/gcc/riscv64/ck_pr.h deleted file mode 100644 index c0befa7b..00000000 --- a/include/gcc/riscv64/ck_pr.h +++ /dev/null @@ -1,548 +0,0 @@ -/* - * Copyright 2009-2016 Samy Al Bahra. - * Copyright 2013-2016 Olivier Houchard. - * All rights reserved. - * Copyright 2022 The FreeBSD Foundation. - * - * Portions of this software were developed by Mitchell Horne - * under sponsorship from the FreeBSD Foundation. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef CK_PR_RISCV64_H -#define CK_PR_RISCV64_H - -#ifndef CK_PR_H -#error Do not include this file directly, use ck_pr.h -#endif - -#include -#include - -#if !defined(__riscv_xlen) || __riscv_xlen != 64 -#error "only for riscv64!" -#endif - -/* - * The following represent supported atomic operations. - * These operations may be emulated. - */ -#include "ck_f_pr.h" - -/* - * Minimum interface requirement met. - */ -#define CK_F_PR - -CK_CC_INLINE static void -ck_pr_stall(void) -{ - - __asm__ __volatile__("" ::: "memory"); - return; -} - -/* - * The FENCE instruction is defined in terms of predecessor and successor bits. - * This allows for greater granularity in specifying whether reads (loads) or - * writes (stores) may pass over either side of the fence. - * - * e.g. "fence r,rw" creates a barrier with acquire semantics. - * - * Note that atomic memory operations (AMOs) are defined by the RISC-V spec to - * act as both a load and store memory operation (read-modify-write, in other - * words). Thus, any of r, w, or rw will enforce ordering on an AMO. - */ -#define CK_FENCE(p, s) __asm __volatile("fence " #p "," #s ::: "memory"); -#define CK_FENCE_RW_RW CK_FENCE(rw,rw) - -#define CK_PR_FENCE(T, I) \ - CK_CC_INLINE static void \ - ck_pr_fence_strict_##T(void) \ - { \ - I; \ - } - -CK_PR_FENCE(atomic, CK_FENCE_RW_RW) -CK_PR_FENCE(atomic_store, CK_FENCE(rw,w)) -CK_PR_FENCE(atomic_load, CK_FENCE(rw,r)) -CK_PR_FENCE(store_atomic, CK_FENCE(w,rw)) -CK_PR_FENCE(load_atomic, CK_FENCE(r,rw)) -CK_PR_FENCE(store, CK_FENCE(w,w)) -CK_PR_FENCE(store_load, CK_FENCE(w,r)) -CK_PR_FENCE(load, CK_FENCE(r,r)) -CK_PR_FENCE(load_store, CK_FENCE(r,w)) -CK_PR_FENCE(memory, CK_FENCE_RW_RW) -CK_PR_FENCE(acquire, CK_FENCE(r,rw)) -CK_PR_FENCE(release, CK_FENCE(rw,w)) -CK_PR_FENCE(acqrel, CK_FENCE_RW_RW) -CK_PR_FENCE(lock, CK_FENCE_RW_RW) -CK_PR_FENCE(unlock, CK_FENCE_RW_RW) - -#undef CK_PR_FENCE - -#undef CK_FENCE_RW_RW -#undef CK_FENCE - -/* - * ck_pr_load(3) - */ -#define CK_PR_LOAD(S, M, T, I) \ - CK_CC_INLINE static T \ - ck_pr_md_load_##S(const M *target) \ - { \ - long r = 0; \ - __asm__ __volatile__(I " %0, 0(%1)\n" \ - : "=r" (r) \ - : "r" (target) \ - : "memory"); \ - return ((T)r); \ - } -#define CK_PR_LOAD_S(S, T, I) CK_PR_LOAD(S, T, T, I) - -CK_PR_LOAD(ptr, void, void *, "ld") -CK_PR_LOAD_S(64, uint64_t, "ld") -CK_PR_LOAD_S(32, uint32_t, "lwu") -CK_PR_LOAD_S(16, uint16_t, "lhu") -CK_PR_LOAD_S(8, uint8_t, "lbu") -CK_PR_LOAD_S(uint, unsigned int, "lwu") -CK_PR_LOAD_S(int, int, "lw") -CK_PR_LOAD_S(short, short, "lh") -CK_PR_LOAD_S(char, char, "lb") -#ifndef CK_PR_DISABLE_DOUBLE -CK_PR_LOAD_S(double, double, "ld") -#endif - -#undef CK_PR_LOAD_S -#undef CK_PR_LOAD - -/* - * ck_pr_store(3) - */ -#define CK_PR_STORE(S, M, T, I) \ - CK_CC_INLINE static void \ - ck_pr_md_store_##S(M *target, T val) \ - { \ - __asm__ __volatile__(I " %1, 0(%0)" \ - : \ - : "r" (target), \ - "r" (val) \ - : "memory"); \ - } -#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, I) - -CK_PR_STORE(ptr, void, const void *, "sd") -CK_PR_STORE_S(64, uint64_t, "sd") -CK_PR_STORE_S(32, uint32_t, "sw") -CK_PR_STORE_S(16, uint16_t, "sh") -CK_PR_STORE_S(8, uint8_t, "sb") -CK_PR_STORE_S(uint, unsigned int, "sw") -CK_PR_STORE_S(int, int, "sw") -CK_PR_STORE_S(short, short, "sh") -CK_PR_STORE_S(char, char, "sb") -#ifndef CK_PR_DISABLE_DOUBLE -CK_PR_STORE_S(double, double, "sd") -#endif - -#undef CK_PR_STORE_S -#undef CK_PR_STORE - -/* - * ck_pr_cas(3) - * - * NB: 'S' is to cast compare to a signed 32-bit integer, so the value will be - * sign-extended when passed to inline asm. GCC does this sign extension - * implicitly, while clang does not. It is necessary because lr.w sign-extends - * the value read from memory, so compare must match that to avoid looping - * unconditionally. - */ -#define CK_PR_CAS(N, M, T, C, S, W) \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N##_value(M *target, T compare, T set, M *value) \ - { \ - T previous; \ - int tmp; \ - __asm__ __volatile__("1:\n" \ - "li %[tmp], 1\n" \ - "lr." W " %[p], %[t]\n" \ - "bne %[p], %[c], 2f\n" \ - "sc." W " %[tmp], %[s], %[t]\n" \ - "bnez %[tmp], 1b\n" \ - "2:" \ - : [p]"=&r" (previous), \ - [tmp]"=&r" (tmp), \ - [t]"+A" (*(C *)target) \ - : [s]"r" (set), \ - [c]"r" ((long)(S)compare) \ - : "memory"); \ - *(T *)value = previous; \ - return (tmp == 0); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N(M *target, T compare, T set) \ - { \ - T previous; \ - int tmp; \ - __asm__ __volatile__("1:\n" \ - "li %[tmp], 1\n" \ - "lr." W " %[p], %[t]\n" \ - "bne %[p], %[c], 2f\n" \ - "sc." W " %[tmp], %[s], %[t]\n" \ - "bnez %[tmp], 1b\n" \ - "2:" \ - : [p]"=&r" (previous), \ - [tmp]"=&r" (tmp), \ - [t]"+A" (*(C *)target) \ - : [s]"r" (set), \ - [c]"r" ((long)(S)compare) \ - : "memory"); \ - return (tmp == 0); \ - } -#define CK_PR_CAS_S(N, T, W) CK_PR_CAS(N, T, T, T, T, W) -#define CK_PR_CAS_32_S(N, T, W) CK_PR_CAS(N, T, T, T, int32_t, W) - -CK_PR_CAS(ptr, void, void *, uint64_t, uint64_t, "d") -CK_PR_CAS_S(64, uint64_t, "d") -CK_PR_CAS_32_S(32, uint32_t, "w") -CK_PR_CAS_32_S(uint, unsigned int, "w") -CK_PR_CAS_32_S(int, int, "w") -#ifndef CK_PR_DISABLE_DOUBLE -CK_PR_CAS_S(double, double, "d") -#endif - -#undef CK_PR_CAS_S -#undef CK_PR_CAS - -/* - * ck_pr_faa(3) - */ -#define CK_PR_FAA(N, M, T, C, W) \ - CK_CC_INLINE static T \ - ck_pr_faa_##N(M *target, T delta) \ - { \ - T previous; \ - __asm__ __volatile__("amoadd." W " %0, %2, %1\n" \ - : "=&r" (previous), \ - "+A" (*(C *)target) \ - : "r" (delta) \ - : "memory"); \ - return (previous); \ - } -#define CK_PR_FAA_S(N, T, W) CK_PR_FAA(N, T, T, T, W) - -CK_PR_FAA(ptr, void, void *, uint64_t, "d") -CK_PR_FAA_S(64, uint64_t, "d") -CK_PR_FAA_S(32, uint32_t, "w") -CK_PR_FAA_S(uint, unsigned int, "w") -CK_PR_FAA_S(int, int, "w") - -#undef CK_PR_FAA_S -#undef CK_PR_FAA - -/* - * ck_pr_fas(3) - */ -#define CK_PR_FAS(N, M, T, C, W) \ - CK_CC_INLINE static T \ - ck_pr_fas_##N(M *target, T val) \ - { \ - T previous; \ - __asm__ __volatile__("amoswap." W " %0, %2, %1\n" \ - : "=&r" (previous), \ - "+A" (*(C *)target) \ - : "r" (val) \ - : "memory"); \ - return (previous); \ - } -#define CK_PR_FAS_S(N, T, W) CK_PR_FAS(N, T, T, T, W) - -CK_PR_FAS(ptr, void, void *, uint64_t, "d") -CK_PR_FAS_S(64, uint64_t, "d") -CK_PR_FAS_S(32, uint32_t, "w") -CK_PR_FAS_S(int, int, "w") -CK_PR_FAS_S(uint, unsigned int, "w") - -#undef CK_PR_FAS_S -#undef CK_PR_FAS - -/* - * ck_pr_add(3) - */ -#define CK_PR_ADD(N, M, T, C, W) \ - CK_CC_INLINE static void \ - ck_pr_add_##N(M *target, T val) \ - { \ - __asm__ __volatile__("amoadd." W " zero, %1, %0\n" \ - : "+A" (*(C *)target) \ - : "r" (val) \ - : "memory"); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_add_##N##_is_zero(M *target, T val) \ - { \ - T previous; \ - __asm__ __volatile__("amoadd." W " %0, %2, %1\n" \ - : "=&r" (previous), \ - "+A" (*(C *)target) \ - : "r" (val) \ - : "memory"); \ - return (((C)previous + (C)val) == 0); \ - } -#define CK_PR_ADD_S(N, T, W) CK_PR_ADD(N, T, T, T, W) - -CK_PR_ADD(ptr, void, void *, uint64_t, "d") -CK_PR_ADD_S(64, uint64_t, "d") -CK_PR_ADD_S(32, uint32_t, "w") -CK_PR_ADD_S(uint, unsigned int, "w") -CK_PR_ADD_S(int, int, "w") - -#undef CK_PR_ADD_S -#undef CK_PR_ADD - -/* - * ck_pr_inc(3) - * - * Implemented in terms of ck_pr_add(3); RISC-V has no atomic inc or dec - * instructions. - */ -#define CK_PR_INC(N, M, T, W) \ - CK_CC_INLINE static void \ - ck_pr_inc_##N(M *target) \ - { \ - ck_pr_add_##N(target, (T)1); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_inc_##N##_is_zero(M *target) \ - { \ - return (ck_pr_add_##N##_is_zero(target, (T)1)); \ - } -#define CK_PR_INC_S(N, T, W) CK_PR_INC(N, T, T, W) - -CK_PR_INC(ptr, void, void *, "d") -CK_PR_INC_S(64, uint64_t, "d") -CK_PR_INC_S(32, uint32_t, "w") -CK_PR_INC_S(uint, unsigned int, "w") -CK_PR_INC_S(int, int, "w") - -#undef CK_PR_INC_S -#undef CK_PR_INC - -/* - * ck_pr_sub(3) - */ -#define CK_PR_SUB(N, M, T, C, W) \ - CK_CC_INLINE static void \ - ck_pr_sub_##N(M *target, T val) \ - { \ - __asm__ __volatile__("amoadd." W " zero, %1, %0\n" \ - : "+A" (*(C *)target) \ - : "r" (-(C)val) \ - : "memory"); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_sub_##N##_is_zero(M *target, T val) \ - { \ - T previous; \ - __asm__ __volatile__("amoadd." W " %0, %2, %1\n" \ - : "=&r" (previous), \ - "+A" (*(C *)target) \ - : "r" (-(C)val) \ - : "memory"); \ - return (((C)previous - (C)val) == 0); \ - } -#define CK_PR_SUB_S(N, T, W) CK_PR_SUB(N, T, T, T, W) - -CK_PR_SUB(ptr, void, void *, uint64_t, "d") -CK_PR_SUB_S(64, uint64_t, "d") -CK_PR_SUB_S(32, uint32_t, "w") -CK_PR_SUB_S(uint, unsigned int, "w") -CK_PR_SUB_S(int, int, "w") - -#undef CK_PR_SUB_S -#undef CK_PR_SUB - -/* - * ck_pr_dec(3) - */ -#define CK_PR_DEC(N, M, T, W) \ - CK_CC_INLINE static void \ - ck_pr_dec_##N(M *target) \ - { \ - ck_pr_sub_##N(target, (T)1); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_dec_##N##_is_zero(M *target) \ - { \ - return (ck_pr_sub_##N##_is_zero(target, (T)1)); \ - } -#define CK_PR_DEC_S(N, T, W) CK_PR_DEC(N, T, T, W) - -CK_PR_DEC(ptr, void, void *, "d") -CK_PR_DEC_S(64, uint64_t, "d") -CK_PR_DEC_S(32, uint32_t, "w") -CK_PR_DEC_S(uint, unsigned int, "w") -CK_PR_DEC_S(int, int, "w") - -#undef CK_PR_DEC_S -#undef CK_PR_DEC - -/* - * ck_pr_neg(3) - */ -#define CK_PR_NEG(N, M, T, C, W) \ - CK_CC_INLINE static void \ - ck_pr_neg_##N(M *target) \ - { \ - __asm__ __volatile__("1:\n" \ - "lr." W " t0, %0\n" \ - "sub t0, zero, t0\n" \ - "sc." W " t1, t0, %0\n" \ - "bnez t1, 1b\n" \ - : "+A" (*(C *)target) \ - : \ - : "t0", "t1", "memory"); \ - } -#define CK_PR_NEG_S(N, T, W) CK_PR_NEG(N, T, T, T, W) - -CK_PR_NEG(ptr, void, void *, uint64_t, "d") -CK_PR_NEG_S(64, uint64_t, "d") -CK_PR_NEG_S(32, uint32_t, "w") -CK_PR_NEG_S(uint, unsigned int, "w") -CK_PR_NEG_S(int, int, "w") - -#undef CK_PR_NEG_S -#undef CK_PR_NEG - -/* - * ck_pr_not(3) - */ -#define CK_PR_NOT(N, M, T, C, W) \ - CK_CC_INLINE static void \ - ck_pr_not_##N(M *target) \ - { \ - __asm__ __volatile__("1:\n" \ - "lr." W " t0, %0\n" \ - "not t0, t0\n" \ - "sc." W " t1, t0, %0\n" \ - "bnez t1, 1b\n" \ - : "+A" (*(C *)target) \ - : \ - : "t0", "t1", "memory"); \ - } -#define CK_PR_NOT_S(N, T, W) CK_PR_NOT(N, T, T, T, W) - -CK_PR_NOT(ptr, void, void *, uint64_t, "d") -CK_PR_NOT_S(64, uint64_t, "d") -CK_PR_NOT_S(32, uint32_t, "w") -CK_PR_NOT_S(uint, unsigned int, "w") -CK_PR_NOT_S(int, int, "w") - -#undef CK_PR_NOT_S -#undef CK_PR_NOT - -/* - * ck_pr_and(3), ck_pr_or(3), and ck_pr_xor(3) - */ -#define CK_PR_BINARY(O, N, M, T, C, I, W) \ - CK_CC_INLINE static void \ - ck_pr_##O##_##N(M *target, T delta) \ - { \ - __asm__ __volatile__(I "." W " zero, %1, %0\n" \ - : "+A" (*(C *)target) \ - : "r" (delta) \ - : "memory"); \ - } - -CK_PR_BINARY(and, ptr, void, void *, uint64_t, "amoand", "d") -CK_PR_BINARY(or, ptr, void, void *, uint64_t, "amoor", "d") -CK_PR_BINARY(xor, ptr, void, void *, uint64_t, "amoxor", "d") - -#define CK_PR_BINARY_S(S, T, W) \ - CK_PR_BINARY(and, S, T, T, T, "amoand", W) \ - CK_PR_BINARY(or, S, T, T, T, "amoor", W) \ - CK_PR_BINARY(xor, S, T, T, T, "amoxor", W) \ - -CK_PR_BINARY_S(64, uint64_t, "d") -CK_PR_BINARY_S(32, uint32_t, "w") -CK_PR_BINARY_S(uint, unsigned int, "w") -CK_PR_BINARY_S(int, int, "w") - -#undef CK_PR_BINARY_S -#undef CK_PR_BINARY - -/* - * ck_pr_btc(3), ck_pr_btr(3), and ck_pr_bts(3) - */ -#define CK_PR_BTX(K, S, I, W, M, C, O) \ - CK_CC_INLINE static bool \ - ck_pr_##K##_##S(M *target, unsigned int idx) \ - { \ - C ret; \ - C mask = (C)0x1 << idx; \ - __asm__ __volatile__(I "." W " %1, %2, %0\n" \ - : "+A" (*(C *)target), \ - "=r" (ret) \ - : "r" (O(mask)) \ - : "memory", "cc"); \ - return ((ret & mask) != 0); \ - } - -#define CK_PR_BTC(S, W, M, C) CK_PR_BTX(btc, S, "amoxor", W, M, C, 0+) -#define CK_PR_BTC_S(S, W, T) CK_PR_BTC(S, W, T, T) - -CK_PR_BTC(ptr, "d", void, uint64_t) -CK_PR_BTC_S(64, "d", uint64_t) -CK_PR_BTC_S(32, "w", uint32_t) -CK_PR_BTC_S(uint, "w", unsigned int) -CK_PR_BTC_S(int, "w", int) - -#undef CK_PR_BTC_S -#undef CK_PR_BTC - -#define CK_PR_BTR(S, W, M, C) CK_PR_BTX(btr, S, "amoand", W, M, C, ~) -#define CK_PR_BTR_S(S, W, T) CK_PR_BTR(S, W, T, T) - -CK_PR_BTR(ptr, "d", void, uint64_t) -CK_PR_BTR_S(64, "d", uint64_t) -CK_PR_BTR_S(32, "w", uint32_t) -CK_PR_BTR_S(uint, "w", unsigned int) -CK_PR_BTR_S(int, "w", int) - -#undef CK_PR_BTR_S -#undef CK_PR_BTR - -#define CK_PR_BTS(S, W, M, C) CK_PR_BTX(bts, S, "amoor", W, M, C, 0+) -#define CK_PR_BTS_S(S, W, T) CK_PR_BTS(S, W, T, T) - -CK_PR_BTS(ptr, "d", void, uint64_t) -CK_PR_BTS_S(64, "d", uint64_t) -CK_PR_BTS_S(32, "w", uint32_t) -CK_PR_BTS_S(uint, "w", unsigned int) -CK_PR_BTS_S(int, "w", int) - -#undef CK_PR_BTS_S -#undef CK_PR_BTS - -#undef CK_PR_BTX - -#endif /* CK_PR_RISCV64_H */ diff --git a/include/gcc/s390x/ck_f_pr.h b/include/gcc/s390x/ck_f_pr.h deleted file mode 100644 index cd54a289..00000000 --- a/include/gcc/s390x/ck_f_pr.h +++ /dev/null @@ -1,97 +0,0 @@ -/* DO NOT EDIT. This is auto-generated from feature.sh */ -#define CK_F_PR_ADD_32 -#define CK_F_PR_ADD_64 -#define CK_F_PR_ADD_INT -#define CK_F_PR_ADD_PTR -#define CK_F_PR_ADD_UINT -#define CK_F_PR_AND_32 -#define CK_F_PR_AND_64 -#define CK_F_PR_AND_INT -#define CK_F_PR_AND_PTR -#define CK_F_PR_AND_UINT -#define CK_F_PR_CAS_32 -#define CK_F_PR_CAS_32_VALUE -#define CK_F_PR_CAS_64 -#define CK_F_PR_CAS_64_VALUE -#define CK_F_PR_CAS_INT -#define CK_F_PR_CAS_INT_VALUE -#define CK_F_PR_CAS_PTR -#define CK_F_PR_CAS_PTR_VALUE -#define CK_F_PR_CAS_UINT -#define CK_F_PR_CAS_UINT_VALUE -#define CK_F_PR_DEC_32 -#define CK_F_PR_DEC_64 -#define CK_F_PR_DEC_INT -#define CK_F_PR_DEC_PTR -#define CK_F_PR_DEC_UINT -#define CK_F_PR_FAA_32 -#define CK_F_PR_FAA_64 -#define CK_F_PR_FAA_INT -#define CK_F_PR_FAA_PTR -#define CK_F_PR_FAA_UINT -#define CK_F_PR_FAS_32 -#define CK_F_PR_FAS_64 -#define CK_F_PR_FAS_INT -#define CK_F_PR_FAS_PTR -#define CK_F_PR_FAS_UINT -#define CK_F_PR_FAS_DOUBLE -#define CK_F_PR_FENCE_LOAD -#define CK_F_PR_FENCE_LOAD_DEPENDS -#define CK_F_PR_FENCE_MEMORY -#define CK_F_PR_FENCE_STORE -#define CK_F_PR_FENCE_STRICT_LOAD -#define CK_F_PR_FENCE_STRICT_LOAD_DEPENDS -#define CK_F_PR_FENCE_STRICT_MEMORY -#define CK_F_PR_FENCE_STRICT_STORE -#define CK_F_PR_INC_32 -#define CK_F_PR_INC_64 -#define CK_F_PR_INC_INT -#define CK_F_PR_INC_PTR -#define CK_F_PR_INC_UINT -#define CK_F_PR_LOAD_16 -#define CK_F_PR_LOAD_32 -#define CK_F_PR_LOAD_64 -#define CK_F_PR_LOAD_8 -#define CK_F_PR_LOAD_CHAR -#define CK_F_PR_LOAD_DOUBLE -#define CK_F_PR_LOAD_INT -#define CK_F_PR_LOAD_PTR -#define CK_F_PR_LOAD_SHORT -#define CK_F_PR_LOAD_UINT -#define CK_F_PR_NEG_32 -#define CK_F_PR_NEG_64 -#define CK_F_PR_NEG_INT -#define CK_F_PR_NEG_PTR -#define CK_F_PR_NEG_UINT -#define CK_F_PR_NOT_32 -#define CK_F_PR_NOT_64 -#define CK_F_PR_NOT_INT -#define CK_F_PR_NOT_PTR -#define CK_F_PR_NOT_UINT -#define CK_F_PR_OR_32 -#define CK_F_PR_OR_64 -#define CK_F_PR_OR_INT -#define CK_F_PR_OR_PTR -#define CK_F_PR_OR_UINT -#define CK_F_PR_STALL -#define CK_F_PR_STORE_16 -#define CK_F_PR_STORE_32 -#define CK_F_PR_STORE_64 -#define CK_F_PR_STORE_8 -#define CK_F_PR_STORE_CHAR -#define CK_F_PR_STORE_DOUBLE -#define CK_F_PR_STORE_INT -#define CK_F_PR_STORE_PTR -#define CK_F_PR_STORE_SHORT -#define CK_F_PR_STORE_UINT -#define CK_F_PR_SUB_32 -#define CK_F_PR_SUB_64 -#define CK_F_PR_SUB_INT -#define CK_F_PR_SUB_PTR -#define CK_F_PR_SUB_UINT -#define CK_F_PR_XOR_32 -#define CK_F_PR_XOR_64 -#define CK_F_PR_XOR_INT -#define CK_F_PR_XOR_PTR -#define CK_F_PR_XOR_UINT - diff --git a/include/gcc/s390x/ck_pr.h b/include/gcc/s390x/ck_pr.h deleted file mode 100644 index 8ad22b2d..00000000 --- a/include/gcc/s390x/ck_pr.h +++ /dev/null @@ -1,373 +0,0 @@ -/* - * Copyright 2009-2015 Samy Al Bahra. - * Copyright 2017 Neale Ferguson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef CK_PR_S390X_H -#define CK_PR_S390X_H - -#ifndef CK_PR_H -#error Do not include this file directly, use ck_pr.h -#endif - -#include -#include - -/* - * The following represent supported atomic operations. - * These operations may be emulated. - */ -#include "ck_f_pr.h" - -/* - * Minimum interface requirement met. - */ -#define CK_F_PR - -/* - * This bounces the hardware thread from low to medium - * priority. I am unsure of the benefits of this approach - * but it is used by the Linux kernel. - */ -CK_CC_INLINE static void -ck_pr_stall(void) -{ - __sync_synchronize(); - return; -} - -#define CK_PR_FENCE(T) \ - CK_CC_INLINE static void \ - ck_pr_fence_strict_##T(void) \ - { \ - __sync_synchronize(); \ - } - -/* - * These are derived from: - * http://www.ibm.com/developerworks/systems/articles/powerpc.html - */ -CK_PR_FENCE(atomic) -CK_PR_FENCE(atomic_store) -CK_PR_FENCE(atomic_load) -CK_PR_FENCE(store_atomic) -CK_PR_FENCE(load_atomic) -CK_PR_FENCE(store) -CK_PR_FENCE(store_load) -CK_PR_FENCE(load) -CK_PR_FENCE(load_store) -CK_PR_FENCE(memory) -CK_PR_FENCE(acquire) -CK_PR_FENCE(release) -CK_PR_FENCE(acqrel) -CK_PR_FENCE(lock) -CK_PR_FENCE(unlock) - -#undef CK_PR_FENCE - -#define CK_PR_LOAD(S, M, T, C, I) \ - CK_CC_INLINE static T \ - ck_pr_md_load_##S(const M *target) \ - { \ - T r; \ - __asm__ __volatile__(I "\t%0, %1\n" \ - : "=r" (r) \ - : "Q" (*(const C *)target) \ - : "memory"); \ - return (r); \ - } - -CK_PR_LOAD(ptr, void, void *, uint64_t, "lg") - -#define CK_PR_LOAD_S(S, T, I) CK_PR_LOAD(S, T, T, T, I) - -CK_PR_LOAD_S(64, uint64_t, "lg") -CK_PR_LOAD_S(32, uint32_t, "llgf") -CK_PR_LOAD_S(16, uint16_t, "llgh") -CK_PR_LOAD_S(8, uint8_t, "llgc") -CK_PR_LOAD_S(uint, unsigned int, "llgf") -CK_PR_LOAD_S(int, int, "llgf") -CK_PR_LOAD_S(short, short, "lgh") -CK_PR_LOAD_S(char, char, "lgb") -#ifndef CK_PR_DISABLE_DOUBLE -CK_CC_INLINE static double -ck_pr_md_load_double(const double *target) -{ - double r; - __asm__ __volatile__("ld %0, %1\n" - : "=f" (r) - : "Q" (*(const double *)target) - : "memory"); - return (r); -} -#endif - -#undef CK_PR_LOAD_S -#undef CK_PR_LOAD - -#define CK_PR_STORE(S, M, T, C, I) \ - CK_CC_INLINE static void \ - ck_pr_md_store_##S(M *target, T v) \ - { \ - __asm__ __volatile__(I "\t%1, %0\n" \ - : "=Q" (*(C *)target) \ - : "r" (v) \ - : "memory"); \ - return; \ - } - -CK_PR_STORE(ptr, void, const void *, uint64_t, "stg") - -#define CK_PR_STORE_S(S, T, I) CK_PR_STORE(S, T, T, T, I) - -CK_PR_STORE_S(64, uint64_t, "stg") -CK_PR_STORE_S(32, uint32_t, "st") -CK_PR_STORE_S(16, uint16_t, "sth") -CK_PR_STORE_S(8, uint8_t, "stc") -CK_PR_STORE_S(uint, unsigned int, "st") -CK_PR_STORE_S(int, int, "st") -CK_PR_STORE_S(short, short, "sth") -CK_PR_STORE_S(char, char, "stc") -#ifndef CK_PR_DISABLE_DOUBLE -CK_CC_INLINE static void -ck_pr_md_store_double(double *target, double v) -{ - __asm__ __volatile__(" std %1, %0\n" - : "=Q" (*(double *)target) - : "f" (v) - : "0", "memory"); -} -#endif - -#undef CK_PR_STORE_S -#undef CK_PR_STORE - -CK_CC_INLINE static bool -ck_pr_cas_64_value(uint64_t *target, uint64_t compare, uint64_t set, uint64_t *value) -{ - *value = __sync_val_compare_and_swap(target,compare,set); - return (*value == compare); -} - -CK_CC_INLINE static bool -ck_pr_cas_ptr_value(void *target, void *compare, void *set, void *value) -{ - uintptr_t previous; - - previous = __sync_val_compare_and_swap((uintptr_t *) target, - (uintptr_t) compare, - (uintptr_t) set); - *((uintptr_t *) value) = previous; - return (previous == (uintptr_t) compare); -} - -CK_CC_INLINE static bool -ck_pr_cas_64(uint64_t *target, uint64_t compare, uint64_t set) -{ - return(__sync_bool_compare_and_swap(target,compare,set)); -} - -CK_CC_INLINE static bool -ck_pr_cas_ptr(void *target, void *compare, void *set) -{ - return(__sync_bool_compare_and_swap((uintptr_t *) target, - (uintptr_t) compare, - (uintptr_t) set)); -} - -#define CK_PR_CAS(N, T) \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N##_value(T *target, T compare, T set, T *value) \ - { \ - *value = __sync_val_compare_and_swap(target, \ - compare, \ - set); \ - return(*value == compare); \ - } \ - CK_CC_INLINE static bool \ - ck_pr_cas_##N(T *target, T compare, T set) \ - { \ - return(__sync_bool_compare_and_swap(target, \ - compare, \ - set)); \ - } - -CK_PR_CAS(32, uint32_t) -CK_PR_CAS(uint, unsigned int) -CK_PR_CAS(int, int) - -#undef CK_PR_CAS - -CK_CC_INLINE static void * -ck_pr_fas_ptr(void *target, void *v) -{ - return((void *)__atomic_exchange_n((uintptr_t *) target, (uintptr_t) v, __ATOMIC_ACQUIRE)); -} - -#define CK_PR_FAS(N, M, T) \ - CK_CC_INLINE static T \ - ck_pr_fas_##N(M *target, T v) \ - { \ - return(__atomic_exchange_n(target, v, __ATOMIC_ACQUIRE)); \ - } - -CK_PR_FAS(64, uint64_t, uint64_t) -CK_PR_FAS(32, uint32_t, uint32_t) -CK_PR_FAS(int, int, int) -CK_PR_FAS(uint, unsigned int, unsigned int) - -#ifndef CK_PR_DISABLE_DOUBLE -CK_CC_INLINE static double -ck_pr_fas_double(double *target, double *v) -{ - double previous; - - __asm__ __volatile__ (" lg 1,%2\n" - "0: lg 0,%1\n" - " csg 0,1,%1\n" - " jnz 0b\n" - " ldgr %0,0\n" - : "=f" (previous) - : "Q" (target), "Q" (v) - : "0", "1", "cc", "memory"); - return (previous); -} -#endif - -#undef CK_PR_FAS - -/* - * Atomic store-only binary operations. - */ -#define CK_PR_BINARY(K, S, M, T) \ - CK_CC_INLINE static void \ - ck_pr_##K##_##S(M *target, T d) \ - { \ - d = __sync_fetch_and_##K((T *)target, d); \ - return; \ - } - -#define CK_PR_BINARY_S(K, S, T) CK_PR_BINARY(K, S, T, T) - -#define CK_PR_GENERATE(K) \ - CK_PR_BINARY(K, ptr, void, void *) \ - CK_PR_BINARY_S(K, char, char) \ - CK_PR_BINARY_S(K, int, int) \ - CK_PR_BINARY_S(K, uint, unsigned int) \ - CK_PR_BINARY_S(K, 64, uint64_t) \ - CK_PR_BINARY_S(K, 32, uint32_t) \ - CK_PR_BINARY_S(K, 16, uint16_t) \ - CK_PR_BINARY_S(K, 8, uint8_t) - -CK_PR_GENERATE(add) -CK_PR_GENERATE(sub) -CK_PR_GENERATE(and) -CK_PR_GENERATE(or) -CK_PR_GENERATE(xor) - -#undef CK_PR_GENERATE -#undef CK_PR_BINARY_S -#undef CK_PR_BINARY - -#define CK_PR_UNARY(S, M, T) \ - CK_CC_INLINE static void \ - ck_pr_inc_##S(M *target) \ - { \ - ck_pr_add_##S(target, (T)1); \ - return; \ - } \ - CK_CC_INLINE static void \ - ck_pr_dec_##S(M *target) \ - { \ - ck_pr_sub_##S(target, (T)1); \ - return; \ - } - -#define CK_PR_UNARY_X(S, M) \ - CK_CC_INLINE static void \ - ck_pr_not_##S(M *target) \ - { \ - M newval; \ - do { \ - newval = ~(*target); \ - } while (!__sync_bool_compare_and_swap(target, \ - *target, \ - newval)); \ - } \ - CK_CC_INLINE static void \ - ck_pr_neg_##S(M *target) \ - { \ - M newval; \ - do { \ - newval = -(*target); \ - } while (!__sync_bool_compare_and_swap(target, \ - *target, \ - newval)); \ - } - -#define CK_PR_UNARY_S(S, M) CK_PR_UNARY(S, M, M) \ - CK_PR_UNARY_X(S, M) - -CK_PR_UNARY(ptr, void, void *) -CK_PR_UNARY_S(char, char) -CK_PR_UNARY_S(int, int) -CK_PR_UNARY_S(uint, unsigned int) -CK_PR_UNARY_S(64, uint64_t) -CK_PR_UNARY_S(32, uint32_t) -CK_PR_UNARY_S(16, uint16_t) -CK_PR_UNARY_S(8, uint8_t) - -#undef CK_PR_UNARY_S -#undef CK_PR_UNARY - -CK_CC_INLINE static void * -ck_pr_faa_ptr(void *target, uintptr_t delta) -{ - uintptr_t previous; - - previous = __sync_fetch_and_add((uintptr_t *) target, delta); - - return (void *)(previous); -} - -#define CK_PR_FAA(S, T) \ - CK_CC_INLINE static T \ - ck_pr_faa_##S(T *target, T delta) \ - { \ - T previous; \ - \ - previous = __sync_fetch_and_add(target, delta); \ - \ - return (previous); \ - } - -CK_PR_FAA(64, uint64_t) -CK_PR_FAA(32, uint32_t) -CK_PR_FAA(uint, unsigned int) -CK_PR_FAA(int, int) - -#undef CK_PR_FAA - -#endif /* CK_PR_S390X_H */