Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 301780
Collapse All | Expand All

(-)valgrind-3.5.0/configure.in (+18 lines)
Lines 1441-1446 Link Here
1441
AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1441
AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
1442
1442
1443
1443
1444
AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4a])
1445
1446
AC_TRY_COMPILE(, [
1447
  do { 		 
1448
      __asm__ __volatile__("lzcnt %rax,%rax" ); } 
1449
  while (0)
1450
],
1451
[
1452
ac_have_as_sse4a=yes
1453
AC_MSG_RESULT([yes])
1454
], [
1455
ac_have_as_sse4a=no
1456
AC_MSG_RESULT([no])
1457
])
1458
1459
AM_CONDITIONAL(BUILD_SSE4A_TESTS, test x$ac_have_as_sse4a = xyes)
1460
1461
1444
# Check for TLS support in the compiler and linker
1462
# Check for TLS support in the compiler and linker
1445
if test "x${cross_compiling}" = "xno"; then
1463
if test "x${cross_compiling}" = "xno"; then
1446
# Native compilation: check whether running a program using TLS succeeds.
1464
# Native compilation: check whether running a program using TLS succeeds.
(-)valgrind-3.5.0/none/tests/amd64/insn_sse4a.def (+12 lines)
Line 0 Link Here
1
lzcntw r16.uw[0x0468] r16.uw[0] => 1.uw[5]
2
lzcntw m16.uw[0x2642] r16.uw[0] => 1.uw[2]
3
lzcntw r16.uw[0x0000] r16.uw[0] => 1.uw[16]
4
lzcntw r16.uw[0x8000] r16.uw[0] => 1.uw[0]
5
lzcntl r32.ud[0x00072468] r32.ud[0] => 1.ud[13]
6
lzcntl m32.ud[0x75318642] r32.ud[0] => 1.ud[1]
7
lzcntl r32.ud[0x00000000] r32.ud[0] => 1.ud[32]
8
lzcntl r32.ud[0x80000000] r32.ud[0] => 1.ud[0]
9
lzcntq r64.uq[0x1357246813572468] r64.uq[0] => 1.uq[3]
10
lzcntq m64.uq[0x8531864275318642] r64.uq[0] => 1.uq[0]
11
lzcntq m64.uq[0x7531864275318642] r64.uq[0] => 1.uq[1]
12
lzcntq r64.uq[0x0000000000000000] r64.uq[0] => 1.uq[64]
(-)valgrind-3.5.0/none/tests/amd64/Makefile.am (+6 lines)
Lines 12-17 Link Here
12
if BUILD_SSSE3_TESTS
12
if BUILD_SSSE3_TESTS
13
 INSN_TESTS += insn_ssse3
13
 INSN_TESTS += insn_ssse3
14
endif
14
endif
15
if BUILD_SSE4A_TESTS
16
 INSN_TESTS += insn_sse4a test_sse4a_flags
17
endif
18
15
19
16
# Explicitly include insn_sse3 even if ! BUILD_SSE3_TESTS, 
20
# Explicitly include insn_sse3 even if ! BUILD_SSE3_TESTS, 
17
# to avoid packaging screwups if 'make dist' is run on a machine
21
# to avoid packaging screwups if 'make dist' is run on a machine
Lines 96-104 Link Here
96
insn_sse3_LDADD		= -lm
100
insn_sse3_LDADD		= -lm
97
insn_ssse3_SOURCES	= insn_ssse3.def
101
insn_ssse3_SOURCES	= insn_ssse3.def
98
insn_ssse3_LDADD	= -lm
102
insn_ssse3_LDADD	= -lm
103
insn_sse4a_SOURCES	= insn_sse4a.def
99
insn_fpu_SOURCES	= insn_fpu.def
104
insn_fpu_SOURCES	= insn_fpu.def
100
insn_fpu_LDADD		= -lm
105
insn_fpu_LDADD		= -lm
101
fxtract_LDADD		= -lm
106
fxtract_LDADD		= -lm
107
test_sse4a_flags_SOURCES  = test_sse4a_flags.c
102
108
103
.def.c: $(srcdir)/gen_insn_test.pl
109
.def.c: $(srcdir)/gen_insn_test.pl
104
	$(PERL) $(srcdir)/gen_insn_test.pl < $< > $@
110
	$(PERL) $(srcdir)/gen_insn_test.pl < $< > $@
(-)valgrind-3.5.0/none/tests/amd64/test_sse4a_flags.c (+79 lines)
Line 0 Link Here
1
2
/* Derived from: */
3
4
/*
5
 *  amd64 CPU test
6
 *
7
 *  Copyright (c) 2010 Gert Wollny
8
 *
9
 *  This program is free software; you can redistribute it and/or modify
10
 *  it under the terms of the GNU General Public License as published by
11
 *  the Free Software Foundation; either version 2 of the License, or
12
 *  (at your option) any later version.
13
 *
14
 *  This program is distributed in the hope that it will be useful,
15
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 *  GNU General Public License for more details.
18
 *
19
 *  You should have received a copy of the GNU General Public License
20
 *  along with this program; if not, write to the Free Software
21
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22
 */
23
24
#include <stdio.h>
25
26
#define CARRY_FLAG   0x0001
27
#define ZERO_FLAG    0x0040
28
#define FLAG_MASK (CARRY_FLAG|ZERO_FLAG)
29
30
int test_LZCNT_flags(long value, short expect)
31
{
32
	short eflags; 
33
	asm ("mov %1,%%rax\n"
34
	     "lzcnt %%rax,%%rax\n"
35
	     "pushf\n"
36
	     "pop %0\n" 
37
	     : "=r" (eflags), "=m" (value)
38
		);		
39
	printf("flags = %d (%d) ", eflags & FLAG_MASK, eflags); 
40
	return ((eflags & FLAG_MASK) == expect); 
41
}
42
43
44
void test_zero_sets_C()
45
{
46
	printf("zero_sets_C ... "); 
47
	
48
	if (test_LZCNT_flags(0UL, CARRY_FLAG)) 
49
		printf("ok\n"); 
50
	else 
51
		printf("not ok\n"); 
52
}
53
54
void test_FFFF_sets_Z()
55
{
56
	printf("0xFF..._sets Z ... "); 
57
	if (test_LZCNT_flags(-1L, ZERO_FLAG)) 
58
		printf("ok\n"); 
59
	else 
60
		printf("not ok\n"); 
61
}
62
63
void test_normal_no_C_or_Z()
64
{
65
	printf("positive values set no flag ... "); 
66
	if (test_LZCNT_flags(321L, 0)) 
67
		printf("ok\n"); 
68
	else 
69
		printf("not ok\n"); 
70
}
71
72
int main(int argc, char **args) 
73
{
74
	test_zero_sets_C(); 
75
	test_FFFF_sets_Z(); 
76
	test_normal_no_C_or_Z(); 
77
78
	return 0; 
79
}
(-)valgrind-3.5.0/VEX/priv/guest_amd64_toIR.c (-3 / +122 lines)
Lines 7325-7330 Link Here
7325
7325
7326
7326
7327
7327
7328
/* Handle LZCNT in terms of BSR */
7329
static
7330
ULong dis_LZCNT ( VexAbiInfo* vbi,
7331
		  Prefix pfx, Int sz, Long delta)
7332
{
7333
   Bool   isReg;
7334
   UChar  modrm;
7335
   HChar  dis_buf[50];
7336
7337
   IRType ty    = szToITy(sz);
7338
   IRTemp src   = newTemp(ty);
7339
   IRTemp dst   = newTemp(ty);
7340
   IRTemp src64 = newTemp(Ity_I64);
7341
   IRTemp dst64 = newTemp(Ity_I64);
7342
   IRTemp src8  = newTemp(Ity_I8);
7343
   IRTemp dst8  = newTemp(Ity_I8);
7344
7345
   vassert(sz == 8 || sz == 4 || sz == 2);
7346
7347
   ULong maxbit = 8 * sz -1;  
7348
7349
   modrm = getUChar(delta);
7350
   isReg = epartIsReg(modrm);
7351
   if (isReg) {
7352
      delta++;
7353
      assign( src, getIRegE(sz, pfx, modrm) );
7354
   } else {
7355
      Int    len;
7356
      IRTemp addr = disAMode( &len, vbi, pfx, delta, dis_buf, 0 );
7357
      delta += len;
7358
      assign( src, loadLE(ty, mkexpr(addr)) );
7359
   }
7360
7361
   DIP("lzcnt %s, %s\n",
7362
       ( isReg ? nameIRegE(sz, pfx, modrm) : dis_buf ), 
7363
       nameIRegG(sz, pfx, modrm));
7364
7365
   /* First, widen src to 64 bits if it is not already. */
7366
   assign( src64, widenUto64(mkexpr(src)) );
7367
7368
   /* make a zero expression iff src64 is zero */
7369
   assign( src8,
7370
           unop(Iop_1Uto8, 
7371
                binop(Iop_CmpNE64,
7372
                      mkexpr(src64), mkU64(0))) );
7373
7374
   /* clean all flags */ 
7375
   stmt( IRStmt_Put( OFFB_CC_OP,   mkU64(AMD64G_CC_OP_COPY) ));
7376
   stmt( IRStmt_Put( OFFB_CC_DEP2, mkU64(0) ));
7377
7378
7379
   /* Hack: Execute the operation by using BSR 
7380
      Iff the input value is zero, store the size of 
7381
      the operant in the 
7382
      result. otherwise store sieof(src)-1-BSR(src).  
7383
    */
7384
   assign( dst64,
7385
           IRExpr_Mux0X( 
7386
              mkexpr(src8),
7387
              /* src == 0 -- set result to width of src */
7388
              mkU64(8 * sz),
7389
              /* src != 0 */
7390
	      binop(Iop_Sub64, 
7391
		    mkU64(maxbit), 
7392
		    binop(Iop_Sub64, 
7393
                         mkU64(63), 
7394
			  unop(Iop_Clz64, mkexpr(src64)))
7395
		      )
7396
		   )
7397
         );
7398
7399
   assign( dst8,
7400
           unop(Iop_1Uto8, 
7401
                binop(Iop_CmpNE64,
7402
                      mkexpr(dst64), mkU64(0))) );
7403
7404
   /* set c flag if src is zero and z flag if dst is zero */
7405
   stmt( IRStmt_Put( 
7406
            OFFB_CC_DEP1, 
7407
	    binop(Iop_Or64, 
7408
		  IRExpr_Mux0X( 
7409
                       mkexpr(src8),
7410
                          /* src==0 */
7411
                          mkU64(AMD64G_CC_MASK_C),
7412
                          /* src!=0 */
7413
                          mkU64(0)
7414
                       ),
7415
		  IRExpr_Mux0X( 
7416
                        mkexpr(dst8),
7417
                        /* dst==0 */
7418
                        mkU64(AMD64G_CC_MASK_Z),
7419
                        /* dst!=0 */
7420
                        mkU64(0)
7421
                       )
7422
               )
7423
          )
7424
      );  
7425
7426
7427
   if (sz == 2)
7428
      assign( dst, unop(Iop_64to16, mkexpr(dst64)) );
7429
   else
7430
   if (sz == 4)
7431
      assign( dst, unop(Iop_64to32, mkexpr(dst64)) );
7432
   else
7433
      assign( dst, mkexpr(dst64) );
7434
7435
   /* dump result back */
7436
   putIRegG( sz, pfx, modrm, mkexpr(dst) );
7437
7438
   return delta;
7439
}
7440
7441
7328
/* Handle BSF/BSR.  Only v-size seems necessary. */
7442
/* Handle BSF/BSR.  Only v-size seems necessary. */
7329
static
7443
static
7330
ULong dis_bs_E_G ( VexAbiInfo* vbi,
7444
ULong dis_bs_E_G ( VexAbiInfo* vbi,
Lines 15348-15356 Link Here
15348
         if (haveF2orF3(pfx)) goto decode_failure;
15462
         if (haveF2orF3(pfx)) goto decode_failure;
15349
         delta = dis_bs_E_G ( vbi, pfx, sz, delta, True );
15463
         delta = dis_bs_E_G ( vbi, pfx, sz, delta, True );
15350
         break;
15464
         break;
15351
      case 0xBD: /* BSR Gv,Ev */
15465
      case 0xBD: 
15352
         if (haveF2orF3(pfx)) goto decode_failure;
15466
	 if (haveF3(pfx)) 
15353
         delta = dis_bs_E_G ( vbi, pfx, sz, delta, False );
15467
           delta = dis_LZCNT ( vbi, pfx, sz, delta );
15468
         else if (haveF2(pfx)) 
15469
           goto decode_failure;
15470
         else
15471
            /* BSR Gv,Ev */
15472
           delta = dis_bs_E_G ( vbi, pfx, sz, delta, False );
15354
         break;
15473
         break;
15355
15474
15356
      /* =-=-=-=-=-=-=-=-=- BSWAP -=-=-=-=-=-=-=-=-=-=-= */
15475
      /* =-=-=-=-=-=-=-=-=- BSWAP -=-=-=-=-=-=-=-=-=-=-= */

Return to bug 301780