diff --git a/configure b/configure index ae14e02..4794445 100755 --- a/configure +++ b/configure @@ -95,6 +95,7 @@ generate() -e "s#@POINTER_PACK_ENABLE@#$POINTER_PACK_ENABLE#g" \ -e "s#@VMA_BITS@#$VMA_BITS_R#g" \ -e "s#@VMA_BITS_VALUE@#$VMA_BITS_VALUE_R#g" \ + -e "s#@MM@#$MM#g" \ $1 > $2 } @@ -114,6 +115,7 @@ generate_stdout() echo " CORES = $CORES" echo " POINTER_PACK = $POINTER_PACK_ENABLE" echo " VMA_BITS = $VMA_BITS" + echo " MEMORY_MODEL = $MM" echo echo "Headers will be installed in $HEADERS" echo "Libraries will be installed in $LIBRARY" @@ -139,6 +141,7 @@ for option in $*; do echo "The following options will modify code generation." echo " --cores=N Specify number of cores available on target machine" echo " --enable-pointer-packing Assumes address encoding is subset of pointer range" + echo " --memory-model=N Specify memory model (currently tso, pso or rmo)" echo " --vma-bits=N Specify valid number of VMA bits" echo echo "The following environment variables may be used:" @@ -150,6 +153,23 @@ for option in $*; do echo "Report bugs to ${MAINTAINER}." exit $EXIT_SUCCESS ;; + --memory-model=*) + case "$value" in + "tso") + MM="CK_MD_TSO" + ;; + "rmo") + MM="CK_MD_RMO" + ;; + "pso") + MM="CK_MD_PSO" + ;; + *) + echo "./configure [--help]" + exit $EXIT_FAILURE + ;; + esac + ;; --vma-bits=*) VMA_BITS=$value ;; @@ -259,16 +279,19 @@ printf "Detecting machine architecture..." PLATFORM=`uname -m 2> /dev/null` case $PLATFORM in "macppc"|"Power Macintosh"|"powerpc") + MM="${MM:-"CK_MD_RMO"}" PLATFORM=ppc ENVIRONMENT=32 LDFLAGS="-m32 $LDFLAGS" ;; "sun4u"|"sun4v"|"sparc64") + MM="${MM:-"CK_MD_TSO"}" PLATFORM=sparcv9 ENVIRONMENT=64 LDFLAGS="-m64 $LDFLAGS" ;; i386|i486|i586|i686|i586_i686|pentium*|athlon*|k5|k6|k6_2|k6_3) + MM="${MM:-"CK_MD_TSO"}" case $SYSTEM in darwin) ENVIRONMENT=64 @@ -317,8 +340,10 @@ case $PLATFORM in PLATFORM=x86_64 ENVIRONMENT=64 LDFLAGS="-m64 $LDFLAGS" + MM="${MM:-"CK_MD_TSO"}" ;; "i86pc") + MM="${MM:-"CK_MD_TSO"}" ISA=`isainfo -n 2> /dev/null || echo i386` case "$ISA" in "amd64") @@ -333,11 +358,13 @@ case $PLATFORM in esac ;; "ppc64") + MM="${MM:-"CK_MD_RMO"}" PLATFORM=ppc64 ENVIRONMENT=64 ;; *) PLATFORM= + MM="${MM:-"CK_MD_RMO"}" ;; esac diff --git a/include/ck_md.h.in b/include/ck_md.h.in index 6f3ab8d..4977c00 100644 --- a/include/ck_md.h.in +++ b/include/ck_md.h.in @@ -37,10 +37,14 @@ #ifndef @POINTER_PACK_ENABLE@ #define @POINTER_PACK_ENABLE@ -#endif +#endif /* @POINTER_PACK_ENABLE@ */ #ifndef @VMA_BITS@ #define @VMA_BITS@ @VMA_BITS_VALUE@ -#endif +#endif /* @VMA_BITS@ */ + +#ifndef @MM@ +#define @MM@ +#endif /* @MM@ */ #endif /* _CK_MD_H */ diff --git a/include/gcc/ppc/ck_pr.h b/include/gcc/ppc/ck_pr.h index be2c46f..4b233ab 100644 --- a/include/gcc/ppc/ck_pr.h +++ b/include/gcc/ppc/ck_pr.h @@ -33,6 +33,7 @@ #endif #include +#include /* * The following represent supported atomic operations. @@ -54,9 +55,7 @@ ck_pr_stall(void) return; } -/* - * We must assume RMO. - */ +#ifdef CK_MD_RMO #define CK_PR_FENCE(T, I) \ CK_CC_INLINE static void \ ck_pr_fence_strict_##T(void) \ @@ -67,6 +66,18 @@ ck_pr_stall(void) { \ __asm__ __volatile__(I ::: "memory"); \ } +#else +#define CK_PR_FENCE(T, I) \ + CK_CC_INLINE static void \ + ck_pr_fence_strict_##T(void) \ + { \ + __asm__ __volatile__(I ::: "memory"); \ + } \ + CK_CC_INLINE static void ck_pr_fence_##T(void) \ + { \ + __asm__ __volatile__("" ::: "memory"); \ + } +#endif /* !CK_MD_RMO */ CK_PR_FENCE(load_depends, "") CK_PR_FENCE(store, "eieio") diff --git a/include/gcc/ppc64/ck_pr.h b/include/gcc/ppc64/ck_pr.h index f2dea45..9b4880f 100644 --- a/include/gcc/ppc64/ck_pr.h +++ b/include/gcc/ppc64/ck_pr.h @@ -32,6 +32,7 @@ #endif #include +#include /* * The following represent supported atomic operations. @@ -53,9 +54,7 @@ ck_pr_stall(void) return; } -/* - * We must assume RMO. - */ +#if defined(CK_MD_RMO) #define CK_PR_FENCE(T, I) \ CK_CC_INLINE static void \ ck_pr_fence_strict_##T(void) \ @@ -66,6 +65,18 @@ ck_pr_stall(void) { \ __asm__ __volatile__(I ::: "memory"); \ } +#else +#define CK_PR_FENCE(T, I) \ + CK_CC_INLINE static void \ + ck_pr_fence_strict_##T(void) \ + { \ + __asm__ __volatile__(I ::: "memory"); \ + } \ + CK_CC_INLINE static void ck_pr_fence_##T(void) \ + { \ + __asm__ __volatile__("" ::: "memory"); \ + } +#endif /* !CK_MD_RMO */ CK_PR_FENCE(load_depends, "") CK_PR_FENCE(store, "eieio") diff --git a/include/gcc/x86/ck_pr.h b/include/gcc/x86/ck_pr.h index 687b050..8781970 100644 --- a/include/gcc/x86/ck_pr.h +++ b/include/gcc/x86/ck_pr.h @@ -33,6 +33,7 @@ #endif #include +#include #include #include @@ -62,6 +63,18 @@ ck_pr_stall(void) return; } +#ifdef CK_MD_RMO +#define CK_PR_FENCE(T, I) \ + CK_CC_INLINE static void \ + ck_pr_fence_strict_##T(void) \ + { \ + __asm__ __volatile__(I ::: "memory"); \ + } \ + CK_CC_INLINE static void ck_pr_fence_##T(void) \ + { \ + __asm__ __volatile__(I ::: "memory"); \ + } +#else /* * IA32 has strong memory ordering guarantees, so memory * fences are enabled if and only if the user specifies that @@ -79,6 +92,7 @@ ck_pr_stall(void) { \ __asm__ __volatile__("" ::: "memory"); \ } +#endif /* !CK_MD_RMO */ CK_PR_FENCE(load, "lfence") CK_PR_FENCE(load_depends, "") diff --git a/include/gcc/x86_64/ck_pr.h b/include/gcc/x86_64/ck_pr.h index 3c40353..59abc3c 100644 --- a/include/gcc/x86_64/ck_pr.h +++ b/include/gcc/x86_64/ck_pr.h @@ -32,6 +32,7 @@ #endif #include +#include #include #include @@ -61,6 +62,18 @@ ck_pr_stall(void) return; } +#ifdef CK_MD_RMO +#define CK_PR_FENCE(T, I) \ + CK_CC_INLINE static void \ + ck_pr_fence_strict_##T(void) \ + { \ + __asm__ __volatile__(I ::: "memory"); \ + } \ + CK_CC_INLINE static void ck_pr_fence_##T(void) \ + { \ + __asm__ __volatile__(I ::: "memory"); \ + } +#else /* * IA32 has strong memory ordering guarantees, so memory * fences are enabled if and only if the user specifies that @@ -78,6 +91,7 @@ ck_pr_stall(void) { \ __asm__ __volatile__("" ::: "memory"); \ } +#endif /* !CK_MD_RMO */ CK_PR_FENCE(load, "lfence") CK_PR_FENCE(load_depends, "")