From b882517d5e0378c87df05c26ed19c3fe1c2784e2 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Thu, 10 Mar 2011 03:54:30 +0100 Subject: [PATCH] PPC64: Complete port, add binary write-only operations. --- include/gcc/ppc64/ck_f_pr.h | 85 ++++++++++++++++++++++++------------- include/gcc/ppc64/ck_pr.h | 38 +++++++++++++++++ 2 files changed, 93 insertions(+), 30 deletions(-) diff --git a/include/gcc/ppc64/ck_f_pr.h b/include/gcc/ppc64/ck_f_pr.h index 46b571d..8ea8301 100644 --- a/include/gcc/ppc64/ck_f_pr.h +++ b/include/gcc/ppc64/ck_f_pr.h @@ -1,4 +1,14 @@ /* 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 @@ -9,6 +19,21 @@ #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_FENCE_LOAD #define CK_F_PR_FENCE_LOAD_DEPENDS #define CK_F_PR_FENCE_MEMORY @@ -17,6 +42,11 @@ #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 @@ -26,6 +56,21 @@ #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 @@ -36,33 +81,13 @@ #define CK_F_PR_STORE_PTR #define CK_F_PR_STORE_SHORT #define CK_F_PR_STORE_UINT -#define CK_F_PR_FAS_PTR -#define CK_F_PR_FAS_64 -#define CK_F_PR_FAS_32 -#define CK_F_PR_FAS_INT -#define CK_F_PR_FAS_UINT -#define CK_F_PR_INC_PTR -#define CK_F_PR_INC_64 -#define CK_F_PR_INC_32 -#define CK_F_PR_INC_UINT -#define CK_F_PR_INC_INT -#define CK_F_PR_DEC_PTR -#define CK_F_PR_DEC_64 -#define CK_F_PR_DEC_32 -#define CK_F_PR_DEC_UINT -#define CK_F_PR_DEC_INT -#define CK_F_PR_NOT_PTR -#define CK_F_PR_NOT_64 -#define CK_F_PR_NOT_32 -#define CK_F_PR_NOT_UINT -#define CK_F_PR_NOT_INT -#define CK_F_PR_NEG_PTR -#define CK_F_PR_NEG_64 -#define CK_F_PR_NEG_32 -#define CK_F_PR_NEG_UINT -#define CK_F_PR_NEG_INT -#define CK_F_PR_FAA_32 -#define CK_F_PR_FAA_64 -#define CK_F_PR_FAA_PTR -#define CK_F_PR_FAA_UINT -#define CK_F_PR_FAA_INT +#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/ppc64/ck_pr.h b/include/gcc/ppc64/ck_pr.h index 44df2f6..b3fc1f7 100644 --- a/include/gcc/ppc64/ck_pr.h +++ b/include/gcc/ppc64/ck_pr.h @@ -333,6 +333,44 @@ CK_PR_UNARY_S(int, int, "w") #undef CK_PR_UNARY_S #undef CK_PR_UNARY +#define CK_PR_BINARY(O, N, M, T, I, W) \ + CK_CC_INLINE static void \ + ck_pr_##O##_##N(M *target, T delta) \ + { \ + T previous; \ + __asm__ __volatile__("1:" \ + "l" W "arx %0, 0, %1;" \ + I " %0, %2, %0;" \ + "st" W "cx. %0, 0, %1;" \ + "bne- 1b;" \ + : "=&r" (previous) \ + : "r" (target), \ + "r" (delta) \ + : "memory", "cc"); \ + return; \ + } + +CK_PR_BINARY(and, ptr, void, uintptr_t, "and", "d") +CK_PR_BINARY(add, ptr, void, uintptr_t, "add", "d") +CK_PR_BINARY(or, ptr, void, uintptr_t, "or", "d") +CK_PR_BINARY(sub, ptr, void, uintptr_t, "sub", "d") +CK_PR_BINARY(xor, ptr, void, uintptr_t, "xor", "d") + +#define CK_PR_BINARY_S(S, T, W) \ + CK_PR_BINARY(and, S, T, T, "and", W) \ + CK_PR_BINARY(add, S, T, T, "add", W) \ + CK_PR_BINARY(or, S, T, T, "or", W) \ + CK_PR_BINARY(sub, S, T, T, "subf", W) \ + CK_PR_BINARY(xor, S, T, T, "xor", 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_CC_INLINE static void * ck_pr_faa_ptr(void *target, uintptr_t delta) {