#ident	"@(#)cg:i386/intrinsics	1.14"


function alloca(x)::x86
{
% mem x
/ALLOCA
	movl	%esp,%ecx
 	subl	x,%esp
	andl	$0xfffffffc,%esp
	movl	%esp,%eax
	pushl	8(%ecx)
	pushl	4(%ecx)
	pushl	(%ecx)
}
function memcpy(x,y,z)::x86
{
% con z==4; mem x,y
	movl	x,%eax
	movl	y,%ecx
	movl	(%ecx), %edx
	movl	%edx, (%eax)
}
function memset(x,y,z)::x86
{
% con y==0,z==4; mem x
	movl	x, %eax
	movl	$0,(%eax)
% con y==0,z==8; mem x
	movl	x, %eax
	movl	$4, %ecx
	movl	$0, (%eax)
	addl	%eax, %ecx
	movl	$0, (%ecx)
% con y==0,z!%4; mem x
/INTRINSIC
	movl	%edi,%edx
	movl	z, %ecx
	xorl	%eax,%eax
	movl	x, %edi
	shrl	$0x2,%ecx
	rep;	sstol 
	movl	%edx,%edi
	movl	x, %eax
/INTRINSICEND
% con z<16; mem x,y
/INTRINSIC
	movl	%edi,%edx
	movl	z, %ecx
	movl	y,%eax
	movl	x, %edi
	rep;	sstob
	movl	%edx,%edi
	movl	x, %eax
/INTRINSICEND
}	
# function abs is valid for all x86 processors in all modes 
#
function abs(x)::x86
{
% con x<0
	movl	x,%eax
	negl	%eax
% con x>=0
	movl	x,%eax
% reg x; lab y
	movl x,%eax
	testl %eax,%eax
	jns  y
	negl %eax
y:
% mem x; lab z
	movl x,%eax
	testl %eax,%eax
	jns  z
	negl %eax
z:
}
function fabs(x):noieee:x86
{
%reg x
	fabs
%mem x
	fldl x
	fabs
}
#
#
function sqrt(x):noieee:x86
{
%reg x
	fsqrt
%mem x
	fldl x
	fsqrt
}
#
#
function exp(x):noieee:x86
{
%reg x
	fldl
	fld1	
	fldl2e	
	fmul	%st(2),%st
	fst	%st(2)
	fprem	
	f2xm1	
	fadd	
	fscale	
	fstp	%st(1)
%mem x
	fldl	x
	fld1	
	fldl2e	
	fmul	%st(2),%st
	fst	%st(2)
	fprem	
	f2xm1	
	fadd	
	fscale	
	fstp	%st(1)
}
function log(x):noieee:x86
{
%reg x
        fldln2
        fldl   
        fyl2x
%mem x
        fldln2
        fldl    x
        fyl2x
}
#
# Following Trignometric functions valid on all x86 processors only in noieee
#
function atan(x):noieee:x86
{
%reg x
        fldl
        fld1
        fpatan
%mem x
        fldl	x
        fld1
        fpatan
}
function cos(x):noieee:x86
{
%reg x
	fcos
%mem x
	fldl x
	fcos
}

function sin(x):noieee:x86
{
%reg x
	fsin
%mem x
	fldl x
	fsin
}
