build/ck_pr: Add configurable memory models.

ck_pring
Samy Al Bahra 12 years ago
parent 2ced93ca08
commit a1dc38f20e

27
configure vendored

@ -95,6 +95,7 @@ generate()
-e "s#@POINTER_PACK_ENABLE@#$POINTER_PACK_ENABLE#g" \ -e "s#@POINTER_PACK_ENABLE@#$POINTER_PACK_ENABLE#g" \
-e "s#@VMA_BITS@#$VMA_BITS_R#g" \ -e "s#@VMA_BITS@#$VMA_BITS_R#g" \
-e "s#@VMA_BITS_VALUE@#$VMA_BITS_VALUE_R#g" \ -e "s#@VMA_BITS_VALUE@#$VMA_BITS_VALUE_R#g" \
-e "s#@MM@#$MM#g" \
$1 > $2 $1 > $2
} }
@ -114,6 +115,7 @@ generate_stdout()
echo " CORES = $CORES" echo " CORES = $CORES"
echo " POINTER_PACK = $POINTER_PACK_ENABLE" echo " POINTER_PACK = $POINTER_PACK_ENABLE"
echo " VMA_BITS = $VMA_BITS" echo " VMA_BITS = $VMA_BITS"
echo " MEMORY_MODEL = $MM"
echo echo
echo "Headers will be installed in $HEADERS" echo "Headers will be installed in $HEADERS"
echo "Libraries will be installed in $LIBRARY" echo "Libraries will be installed in $LIBRARY"
@ -139,6 +141,7 @@ for option in $*; do
echo "The following options will modify code generation." echo "The following options will modify code generation."
echo " --cores=N Specify number of cores available on target machine" echo " --cores=N Specify number of cores available on target machine"
echo " --enable-pointer-packing Assumes address encoding is subset of pointer range" 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 " --vma-bits=N Specify valid number of VMA bits"
echo echo
echo "The following environment variables may be used:" echo "The following environment variables may be used:"
@ -150,6 +153,23 @@ for option in $*; do
echo "Report bugs to ${MAINTAINER}." echo "Report bugs to ${MAINTAINER}."
exit $EXIT_SUCCESS 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=*)
VMA_BITS=$value VMA_BITS=$value
;; ;;
@ -259,16 +279,19 @@ printf "Detecting machine architecture..."
PLATFORM=`uname -m 2> /dev/null` PLATFORM=`uname -m 2> /dev/null`
case $PLATFORM in case $PLATFORM in
"macppc"|"Power Macintosh"|"powerpc") "macppc"|"Power Macintosh"|"powerpc")
MM="${MM:-"CK_MD_RMO"}"
PLATFORM=ppc PLATFORM=ppc
ENVIRONMENT=32 ENVIRONMENT=32
LDFLAGS="-m32 $LDFLAGS" LDFLAGS="-m32 $LDFLAGS"
;; ;;
"sun4u"|"sun4v"|"sparc64") "sun4u"|"sun4v"|"sparc64")
MM="${MM:-"CK_MD_TSO"}"
PLATFORM=sparcv9 PLATFORM=sparcv9
ENVIRONMENT=64 ENVIRONMENT=64
LDFLAGS="-m64 $LDFLAGS" LDFLAGS="-m64 $LDFLAGS"
;; ;;
i386|i486|i586|i686|i586_i686|pentium*|athlon*|k5|k6|k6_2|k6_3) i386|i486|i586|i686|i586_i686|pentium*|athlon*|k5|k6|k6_2|k6_3)
MM="${MM:-"CK_MD_TSO"}"
case $SYSTEM in case $SYSTEM in
darwin) darwin)
ENVIRONMENT=64 ENVIRONMENT=64
@ -317,8 +340,10 @@ case $PLATFORM in
PLATFORM=x86_64 PLATFORM=x86_64
ENVIRONMENT=64 ENVIRONMENT=64
LDFLAGS="-m64 $LDFLAGS" LDFLAGS="-m64 $LDFLAGS"
MM="${MM:-"CK_MD_TSO"}"
;; ;;
"i86pc") "i86pc")
MM="${MM:-"CK_MD_TSO"}"
ISA=`isainfo -n 2> /dev/null || echo i386` ISA=`isainfo -n 2> /dev/null || echo i386`
case "$ISA" in case "$ISA" in
"amd64") "amd64")
@ -333,11 +358,13 @@ case $PLATFORM in
esac esac
;; ;;
"ppc64") "ppc64")
MM="${MM:-"CK_MD_RMO"}"
PLATFORM=ppc64 PLATFORM=ppc64
ENVIRONMENT=64 ENVIRONMENT=64
;; ;;
*) *)
PLATFORM= PLATFORM=
MM="${MM:-"CK_MD_RMO"}"
;; ;;
esac esac

@ -37,10 +37,14 @@
#ifndef @POINTER_PACK_ENABLE@ #ifndef @POINTER_PACK_ENABLE@
#define @POINTER_PACK_ENABLE@ #define @POINTER_PACK_ENABLE@
#endif #endif /* @POINTER_PACK_ENABLE@ */
#ifndef @VMA_BITS@ #ifndef @VMA_BITS@
#define @VMA_BITS@ @VMA_BITS_VALUE@ #define @VMA_BITS@ @VMA_BITS_VALUE@
#endif #endif /* @VMA_BITS@ */
#ifndef @MM@
#define @MM@
#endif /* @MM@ */
#endif /* _CK_MD_H */ #endif /* _CK_MD_H */

@ -33,6 +33,7 @@
#endif #endif
#include <ck_cc.h> #include <ck_cc.h>
#include <ck_md.h>
/* /*
* The following represent supported atomic operations. * The following represent supported atomic operations.
@ -54,9 +55,7 @@ ck_pr_stall(void)
return; return;
} }
/* #ifdef CK_MD_RMO
* We must assume RMO.
*/
#define CK_PR_FENCE(T, I) \ #define CK_PR_FENCE(T, I) \
CK_CC_INLINE static void \ CK_CC_INLINE static void \
ck_pr_fence_strict_##T(void) \ ck_pr_fence_strict_##T(void) \
@ -67,6 +66,18 @@ ck_pr_stall(void)
{ \ { \
__asm__ __volatile__(I ::: "memory"); \ __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(load_depends, "")
CK_PR_FENCE(store, "eieio") CK_PR_FENCE(store, "eieio")

@ -32,6 +32,7 @@
#endif #endif
#include <ck_cc.h> #include <ck_cc.h>
#include <ck_md.h>
/* /*
* The following represent supported atomic operations. * The following represent supported atomic operations.
@ -53,9 +54,7 @@ ck_pr_stall(void)
return; return;
} }
/* #if defined(CK_MD_RMO)
* We must assume RMO.
*/
#define CK_PR_FENCE(T, I) \ #define CK_PR_FENCE(T, I) \
CK_CC_INLINE static void \ CK_CC_INLINE static void \
ck_pr_fence_strict_##T(void) \ ck_pr_fence_strict_##T(void) \
@ -66,6 +65,18 @@ ck_pr_stall(void)
{ \ { \
__asm__ __volatile__(I ::: "memory"); \ __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(load_depends, "")
CK_PR_FENCE(store, "eieio") CK_PR_FENCE(store, "eieio")

@ -33,6 +33,7 @@
#endif #endif
#include <ck_cc.h> #include <ck_cc.h>
#include <ck_md.h>
#include <ck_stdint.h> #include <ck_stdint.h>
#include <stdbool.h> #include <stdbool.h>
@ -62,6 +63,18 @@ ck_pr_stall(void)
return; 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 * IA32 has strong memory ordering guarantees, so memory
* fences are enabled if and only if the user specifies that * fences are enabled if and only if the user specifies that
@ -79,6 +92,7 @@ ck_pr_stall(void)
{ \ { \
__asm__ __volatile__("" ::: "memory"); \ __asm__ __volatile__("" ::: "memory"); \
} }
#endif /* !CK_MD_RMO */
CK_PR_FENCE(load, "lfence") CK_PR_FENCE(load, "lfence")
CK_PR_FENCE(load_depends, "") CK_PR_FENCE(load_depends, "")

@ -32,6 +32,7 @@
#endif #endif
#include <ck_cc.h> #include <ck_cc.h>
#include <ck_md.h>
#include <ck_stdint.h> #include <ck_stdint.h>
#include <stdbool.h> #include <stdbool.h>
@ -61,6 +62,18 @@ ck_pr_stall(void)
return; 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 * IA32 has strong memory ordering guarantees, so memory
* fences are enabled if and only if the user specifies that * fences are enabled if and only if the user specifies that
@ -78,6 +91,7 @@ ck_pr_stall(void)
{ \ { \
__asm__ __volatile__("" ::: "memory"); \ __asm__ __volatile__("" ::: "memory"); \
} }
#endif /* !CK_MD_RMO */
CK_PR_FENCE(load, "lfence") CK_PR_FENCE(load, "lfence")
CK_PR_FENCE(load_depends, "") CK_PR_FENCE(load_depends, "")

Loading…
Cancel
Save