Home | History | Annotate | Line # | Download | only in i386
      1      1.1  joerg // This file is dual licensed under the MIT and the University of Illinois Open
      2      1.1  joerg // Source Licenses. See LICENSE.TXT for details.
      3      1.1  joerg 
      4      1.1  joerg #include "../assembly.h"
      5      1.1  joerg 
      6      1.1  joerg // di_int __ashldi3(di_int input, int count);
      7      1.1  joerg 
      8      1.1  joerg // This routine has some extra memory traffic, loading the 64-bit input via two
      9      1.1  joerg // 32-bit loads, then immediately storing it back to the stack via a single 64-bit
     10      1.1  joerg // store.  This is to avoid a write-small, read-large stall.
     11      1.1  joerg // However, if callers of this routine can be safely assumed to store the argument
     12      1.1  joerg // via a 64-bt store, this is unnecessary memory traffic, and should be avoided.
     13      1.1  joerg // It can be turned off by defining the TRUST_CALLERS_USE_64_BIT_STORES macro.
     14      1.1  joerg 
     15      1.1  joerg #ifdef __i386__
     16      1.1  joerg #ifdef __SSE2__
     17      1.1  joerg 
     18      1.1  joerg .text
     19  1.1.1.2  joerg .balign 4
     20      1.1  joerg DEFINE_COMPILERRT_FUNCTION(__ashldi3)
     21      1.1  joerg 	movd	  12(%esp),		%xmm2	// Load count
     22      1.1  joerg #ifndef TRUST_CALLERS_USE_64_BIT_STORES
     23      1.1  joerg 	movd	   4(%esp),		%xmm0
     24      1.1  joerg 	movd	   8(%esp),		%xmm1
     25      1.1  joerg 	punpckldq	%xmm1,		%xmm0	// Load input
     26      1.1  joerg #else
     27      1.1  joerg 	movq	   4(%esp),		%xmm0	// Load input
     28      1.1  joerg #endif
     29      1.1  joerg 	psllq		%xmm2,		%xmm0	// shift input by count
     30      1.1  joerg 	movd		%xmm0,		%eax
     31      1.1  joerg 	psrlq		$32,		%xmm0
     32      1.1  joerg 	movd		%xmm0,		%edx
     33      1.1  joerg 	ret
     34      1.1  joerg END_COMPILERRT_FUNCTION(__ashldi3)
     35      1.1  joerg 
     36      1.1  joerg #else // Use GPRs instead of SSE2 instructions, if they aren't available.
     37      1.1  joerg 
     38      1.1  joerg .text
     39  1.1.1.2  joerg .balign 4
     40      1.1  joerg DEFINE_COMPILERRT_FUNCTION(__ashldi3)
     41      1.1  joerg 	movl	  12(%esp),		%ecx	// Load count
     42      1.1  joerg 	movl	   8(%esp),		%edx	// Load high
     43      1.1  joerg 	movl	   4(%esp),		%eax	// Load low
     44      1.1  joerg 
     45      1.1  joerg 	testl		$0x20,		%ecx	// If count >= 32
     46      1.1  joerg 	jnz		1f			//    goto 1
     47      1.1  joerg 	shldl		%cl, %eax,	%edx	// left shift high by count
     48      1.1  joerg 	shll		%cl,		%eax	// left shift low by count
     49      1.1  joerg 	ret
     50      1.1  joerg 
     51      1.1  joerg 1:	movl		%eax,		%edx	// Move low to high
     52      1.1  joerg 	xorl		%eax,		%eax	// clear low
     53      1.1  joerg 	shll		%cl,		%edx	// shift high by count - 32
     54      1.1  joerg 	ret
     55      1.1  joerg END_COMPILERRT_FUNCTION(__ashldi3)
     56      1.1  joerg 
     57      1.1  joerg #endif // __SSE2__
     58      1.1  joerg #endif // __i386__
     59