Browse Source

Merge branch '20130530_portablecpu' into bfgminer

Luke Dashjr 12 years ago
parent
commit
27110c531b
5 changed files with 27 additions and 31 deletions
  1. 19 11
      configure.ac
  2. 3 3
      sha256_sse2_amd64.c
  3. 2 2
      sha256_sse4_amd64.c
  4. 2 1
      x86_64/sha256_sse4_amd64.asm
  5. 1 14
      x86_64/sha256_xmm_amd64.asm

+ 19 - 11
configure.ac

@@ -64,6 +64,7 @@ AC_FUNC_ALLOCA
 
 have_cygwin=false
 have_win32=false
+have_macho=false
 DLOPEN_FLAGS="-ldl"
 WS2_LIBS=""
 MM_LIBS=""
@@ -73,10 +74,12 @@ case $target in
   amd64-* | x86_64-*)
     have_x86_32=false
     have_x86_64=true
+    bitness="64"
     ;;
   i386-* | i486-* | i586-* | i686-* | x86-*)
     have_x86_32=true
     have_x86_64=false
+    bitness="32"
     ;;
   *)
     have_x86_32=false
@@ -98,7 +101,11 @@ case $target in
 	;;
   powerpc-*-darwin*)
     CFLAGS="$CFLAGS -faltivec"
+		have_macho=true
     ;;
+	*-*-darwin*)
+		have_macho=true
+		;;
 esac
 
 
@@ -533,18 +540,19 @@ fi
 if test "x$has_yasm" = "xfalse" ; then
   AC_MSG_NOTICE([yasm is required for the assembly algorithms. They will be skipped.])
 else
-  if test "x$have_x86_64" = xtrue; then
-    if test "x$have_win32" = xtrue; then
-      YASM_FMT="win64"
-    else
-      YASM_FMT="elf64"
-    fi
-  elif test "x$have_win32" = xtrue; then
-    YASM_FMT="coff"
-  else
-    YASM_FMT="elf32"
-  fi
+	if test "x$have_win32$have_cygwin" != "xfalsefalse"; then
+		if test "x$have_x86_64" = xtrue; then
+			YASM_FMT="win64"
+		else
+			YASM_FMT="coff"
+		fi
+	elif test "x$have_macho" = "xtrue"; then
+		YASM_FMT="macho$bitness"
+	else
+		YASM_FMT="elf$bitness"
+	fi
 fi
+
 fi
 
 AM_CONDITIONAL([HAS_YASM], [test x$has_yasm = xtrue])

+ 3 - 3
sha256_sse2_amd64.c

@@ -21,7 +21,7 @@
 #include <stdint.h>
 #include <stdio.h>
 
-extern void sha256_sse2_64_new (__m128i *res, __m128i *res1, __m128i *data, const uint32_t init[8]);
+extern void sha256_sse2_64_new (__m128i *res, __m128i *res1, __m128i *data, const uint32_t init[8])__asm__("sha256_sse2_64_new");
 
 static uint32_t g_sha256_k[]__attribute__((aligned(0x100))) = {
     0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, /*  0 */
@@ -43,11 +43,11 @@ static uint32_t g_sha256_k[]__attribute__((aligned(0x100))) = {
 };
 
 
-const uint32_t sha256_init[8]__attribute__((aligned(0x100))) =
+const uint32_t sha256_init[8]__asm__("sha256_init")__attribute__((aligned(0x100))) =
 {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
 
 __m128i g_4sha256_k[64];
-__m128i sha256_consts_m128i[64]__attribute__((aligned(0x1000)));
+__m128i sha256_consts_m128i[64]__asm__("sha256_consts_m128i")__attribute__((aligned(0x1000)));
 
 bool scanhash_sse2_64(struct thr_info*thr, const unsigned char *pmidstate,
 	unsigned char *pdata,

+ 2 - 2
sha256_sse4_amd64.c

@@ -21,7 +21,7 @@
 #include <stdint.h>
 #include <stdio.h>
 
-extern void CalcSha256_x64_sse4(__m128i *res, __m128i *data, uint32_t init[8]);
+extern void CalcSha256_x64_sse4(__m128i *res, __m128i *data, uint32_t init[8])__asm__("CalcSha256_x64_sse4");
 
 static uint32_t g_sha256_k[] = {
     0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, /*  0 */
@@ -46,7 +46,7 @@ static uint32_t g_sha256_k[] = {
 static uint32_t g_sha256_hinit[8] =
 {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
 
-__m128i g_4sha256_k[64];
+__m128i g_4sha256_k[64]__asm__("g_4sha256_k");
 
 bool scanhash_sse4_64(struct thr_info*thr, const unsigned char *pmidstate,
 	unsigned char *pdata,

+ 2 - 1
x86_64/sha256_sse4_amd64.asm

@@ -166,7 +166,8 @@ LAB_LOOP:
 
 %macro	lab_loop_blk 0
 	movntdqa	xmm6, [data+rax*4]
-	paddd	xmm6, g_4sha256_k[rax*4]
+	movntdqa	xmm1, g_4sha256_k[rax*4]
+	paddd	xmm6, xmm1
 	add	rax, 4
 
 	paddd	xmm6, xmm10	; +h

+ 1 - 14
x86_64/sha256_xmm_amd64.asm

@@ -40,19 +40,10 @@ BITS 64
 
 %define SHA_ROUND_LOOP_UNROLL   16
 
-%ifidn __YASM_OBJFMT__, macho64
-extern _sha256_consts_m128i
-extern _sha256_init
-%else
 extern sha256_consts_m128i
 extern sha256_init
-%endif
 
-%ifidn __YASM_OBJFMT__, macho64
-global _sha256_sse2_64_new
-%else
 global sha256_sse2_64_new
-%endif
 
 %define sr1   xmm6
 %define sr2   xmm1
@@ -227,11 +218,7 @@ global sha256_sse2_64_new
 
 ; _sha256_sse2_64_new hash(rdi), hash1(rsi), data(rdx), init(rcx),
 
-%ifidn __YASM_OBJFMT__, macho64
-_sha256_sse2_64_new:
-%else
 sha256_sse2_64_new:
-%endif
 
     push        rbx
 %ifidn __OUTPUT_FORMAT__,win64
@@ -279,7 +266,7 @@ sha256_sse2_64_new:
     pshufd    rE, rE, 0             ; rE == E
 
 %ifidn __YASM_OBJFMT__, macho64
-    lea       rcx, [_sha256_consts_m128i wrt rip]
+    lea       rcx, [sha256_consts_m128i wrt rip]
 %endif
 
 %%SHAROUND_LOOP: