#include <config.h>
#include "asm.h"
#ifdef DO_MMX_ASM
#define src 8(%ebp)
#define sw 12(%ebp)
#define dst 16(%ebp)
#define dw 20(%ebp)
#define w 24(%ebp)
#define h 28(%ebp)
#define cm 32(%ebp)
.text
.align 8
FN_(imlib_mmx_blend_rgba_to_rgb)
FN_(imlib_mmx_blend_rgba_to_rgba)
FN_(imlib_mmx_copy_rgba_to_rgb)
FN_(imlib_mmx_copy_rgba_to_rgba)
FN_(imlib_mmx_copy_rgb_to_rgba)
FN_(imlib_mmx_add_blend_rgba_to_rgb)
FN_(imlib_mmx_add_blend_rgba_to_rgba)
FN_(imlib_mmx_add_copy_rgba_to_rgb)
FN_(imlib_mmx_add_copy_rgba_to_rgba)
FN_(imlib_mmx_add_copy_rgb_to_rgba)
FN_(imlib_mmx_subtract_blend_rgba_to_rgb)
FN_(imlib_mmx_subtract_blend_rgba_to_rgba)
FN_(imlib_mmx_subtract_copy_rgba_to_rgb)
FN_(imlib_mmx_subtract_copy_rgba_to_rgba)
FN_(imlib_mmx_subtract_copy_rgb_to_rgba)
FN_(imlib_mmx_reshade_blend_rgba_to_rgb)
FN_(imlib_mmx_reshade_blend_rgba_to_rgba)
FN_(imlib_mmx_reshade_copy_rgba_to_rgb)
FN_(imlib_mmx_reshade_copy_rgba_to_rgba)
FN_(imlib_mmx_reshade_copy_rgb_to_rgba)
#include "asm_loadimmq.S"
#define ENTER \
pushl %ebp ;\
movl %esp, %ebp ;\
pushl %ebx ;\
pushl %ecx ;\
pushl %edx ;\
pushl %edi ;\
pushl %esi ;\
movl h, %edx ;\
movl w, %ebx ;\
movl src, %esi ;\
movl dst, %edi ;\
leal (%esi, %ebx, 4), %esi ;\
leal (%edi, %ebx, 4), %edi ;\
negl %ebx ;\
jz 9f ;\
incl %edx ;\
decl %edx ;\
jz 9f ;\
decl %edx ;\
#define LOOP_START \
8: ;\
movl %ebx, %ecx
#define LOOP_END \
movl sw, %ecx ;\
leal (%esi, %ecx, 4), %esi ;\
movl dw, %ecx ;\
leal (%edi, %ecx, 4), %edi ;\
decl %edx ;\
jns 8b
#define LEAVE \
9: ;\
emms ;\
popl %esi ;\
popl %edi ;\
popl %edx ;\
popl %ecx ;\
popl %ebx ;\
movl %ebp, %esp ;\
popl %ebp ;\
ret
PR_(imlib_mmx_blend_rgba_to_rgb):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(c1, %mm5)
CLEANUP_IMMQ_LOADS(1)
LOOP_START
1:
movd (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 4), %mm2
movq %mm1, %mm3
punpcklbw %mm3, %mm3
punpckhwd %mm3, %mm3
punpckhdq %mm3, %mm3
psrlw $1, %mm3
psrlq $16, %mm3
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
psubw %mm2, %mm1
psllw $1, %mm1
paddw %mm5, %mm1
pmulhw %mm3, %mm1
paddw %mm1, %mm2
packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
SIZE(imlib_mmx_blend_rgba_to_rgb)
PR_(imlib_mmx_blend_rgba_to_rgba):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(m0X000000, %mm5)
LOAD_IMMQ(m00XXXXXX, %mm6)
LOAD_IMMQ(c1, %mm7)
CLEANUP_IMMQ_LOADS(3)
LOOP_START
1:
movd (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 4), %mm2
movq %mm2, %mm3
pxor %mm6, %mm3
paddusb %mm1, %mm3
punpcklbw %mm3, %mm3
punpckhwd %mm3, %mm3
punpckhdq %mm3, %mm3
psrlw $1, %mm3
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
movq %mm1, %mm0
pand %mm5, %mm0
psubw %mm2, %mm1
psllw $1, %mm1
paddw %mm7, %mm1
pmulhw %mm3, %mm1
pand %mm6, %mm1
por %mm0, %mm1
paddw %mm1, %mm2
packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
SIZE(imlib_mmx_blend_rgba_to_rgba)
PR_(imlib_mmx_copy_rgba_to_rgb):
ENTER
LOAD_IMMQ(m0XXX0XXX, %mm5)
LOAD_IMMQ(mX000X000, %mm6)
CLEANUP_IMMQ_LOADS(2)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
pand %mm5, %mm1
pand %mm6, %mm2
por %mm1, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
pand %mm5, %mm1
pand %mm6, %mm2
por %mm1, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_copy_rgba_to_rgb)
PR_(imlib_mmx_copy_rgba_to_rgba):
ENTER
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq %mm1, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd %mm1, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_copy_rgba_to_rgba)
PR_(imlib_mmx_copy_rgb_to_rgba):
ENTER
LOAD_IMMQ(mX000X000, %mm5)
CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
por %mm5, %mm1
movq %mm1, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
por %mm5, %mm1
movd %mm1, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_copy_rgb_to_rgba)
PR_(imlib_mmx_add_blend_rgba_to_rgb):
ENTER
pxor %mm4, %mm4
LOOP_START
1:
movd (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 4), %mm2
movq %mm1, %mm3
punpcklbw %mm3, %mm3
punpckhwd %mm3, %mm3
punpckhdq %mm3, %mm3
psrlw $1, %mm3
psrlq $16, %mm3
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
psllw $1, %mm1
pmulhw %mm3, %mm1
paddw %mm1, %mm2
packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
SIZE(imlib_mmx_add_blend_rgba_to_rgb)
PR_(imlib_mmx_add_blend_rgba_to_rgba):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(mVX000000, %mm5)
LOAD_IMMQ(m00XXXXXX, %mm6)
CLEANUP_IMMQ_LOADS(2)
LOOP_START
1:
movd (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 4), %mm2
movq %mm2, %mm3
pxor %mm6, %mm3
paddusb %mm1, %mm3
punpcklbw %mm3, %mm3
punpckhwd %mm3, %mm3
punpckhdq %mm3, %mm3
psrlw $1, %mm3
por %mm5, %mm3
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
psllw $1, %mm1
pmulhw %mm3, %mm1
paddw %mm1, %mm2
packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
SIZE(imlib_mmx_add_blend_rgba_to_rgba)
PR_(imlib_mmx_add_copy_rgba_to_rgb):
ENTER
LOAD_IMMQ(m0XXX0XXX, %mm5)
CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
pand %mm5, %mm1
paddusb %mm1, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
pand %mm5, %mm1
paddusb %mm1, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_add_copy_rgba_to_rgb)
PR_(imlib_mmx_add_copy_rgba_to_rgba):
ENTER
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
paddusb %mm1, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
paddusb %mm1, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_add_copy_rgba_to_rgba)
PR_(imlib_mmx_add_copy_rgb_to_rgba):
ENTER
LOAD_IMMQ(mX000X000, %mm5)
CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
paddusb %mm1, %mm2
por %mm5, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
paddusb %mm1, %mm2
por %mm5, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_add_copy_rgb_to_rgba)
PR_(imlib_mmx_subtract_blend_rgba_to_rgb):
ENTER
pxor %mm4, %mm4
LOOP_START
1:
movd (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 4), %mm2
movq %mm1, %mm3
punpcklbw %mm3, %mm3
punpckhwd %mm3, %mm3
punpckhdq %mm3, %mm3
psrlw $1, %mm3
psrlq $16, %mm3
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
psllw $1, %mm1
pmulhw %mm3, %mm1
psubw %mm1, %mm2
packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
SIZE(imlib_mmx_subtract_blend_rgba_to_rgb)
PR_(imlib_mmx_subtract_blend_rgba_to_rgba):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(mV0000000, %mm5)
LOAD_IMMQ(m00XXXXXX, %mm6)
CLEANUP_IMMQ_LOADS(2)
LOOP_START
1:
movd (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 4), %mm2
movq %mm2, %mm3
pxor %mm6, %mm3
paddusb %mm1, %mm3
punpcklbw %mm3, %mm3
punpckhwd %mm3, %mm3
punpckhdq %mm3, %mm3
psrlw $1, %mm3
psrlq $16, %mm3
por %mm5, %mm3
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
psllw $1, %mm1
pmulhw %mm3, %mm1
psubw %mm1, %mm2
packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
SIZE(imlib_mmx_subtract_blend_rgba_to_rgba)
PR_(imlib_mmx_subtract_copy_rgba_to_rgb):
ENTER
LOAD_IMMQ(m0XXX0XXX, %mm5)
CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
pand %mm5, %mm1
psubusb %mm1, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
pand %mm5, %mm1
psubusb %mm1, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_subtract_copy_rgba_to_rgb)
PR_(imlib_mmx_subtract_copy_rgba_to_rgba):
ENTER
LOAD_IMMQ(mX000X000, %mm5)
CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
pxor %mm5, %mm2
psubusb %mm1, %mm2
pxor %mm5, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
pxor %mm5, %mm2
psubusb %mm1, %mm2
pxor %mm5, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_subtract_copy_rgba_to_rgba)
PR_(imlib_mmx_subtract_copy_rgb_to_rgba):
ENTER
LOAD_IMMQ(mX000X000, %mm5)
CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
psubusb %mm1, %mm2
por %mm5, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
psubusb %mm1, %mm2
por %mm5, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_subtract_copy_rgb_to_rgba)
PR_(imlib_mmx_reshade_blend_rgba_to_rgb):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(m000V0V0V, %mm6)
CLEANUP_IMMQ_LOADS(1)
LOOP_START
1:
movd (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 4), %mm2
movq %mm1, %mm3
punpcklbw %mm3, %mm3
punpckhwd %mm3, %mm3
punpckhdq %mm3, %mm3
psrlw $1, %mm3
psrlq $16, %mm3
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
psubw %mm6, %mm1
psllw $2, %mm1
pmulhw %mm3, %mm1
paddw %mm1, %mm2
packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
SIZE(imlib_mmx_reshade_blend_rgba_to_rgb)
PR_(imlib_mmx_reshade_blend_rgba_to_rgba):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(mI0000000, %mm5)
LOAD_IMMQ(m000V0V0V, %mm6)
LOAD_IMMQ(m00XXXXXX, %mm7)
CLEANUP_IMMQ_LOADS(3)
LOOP_START
1:
movd (%esi, %ecx, 4), %mm1
movd (%edi, %ecx, 4), %mm2
movq %mm2, %mm3
pxor %mm7, %mm3
paddusb %mm1, %mm3
punpcklbw %mm3, %mm3
punpckhwd %mm3, %mm3
punpckhdq %mm3, %mm3
psrlw $1, %mm3
psrlq $16, %mm3
por %mm5, %mm3
punpcklbw %mm4, %mm1
punpcklbw %mm4, %mm2
psubw %mm6, %mm1
psllw $2, %mm1
pmulhw %mm3, %mm1
paddw %mm1, %mm2
packuswb %mm4, %mm2
movd %mm2, (%edi, %ecx, 4)
incl %ecx
js 1b
LOOP_END
LEAVE
SIZE(imlib_mmx_reshade_blend_rgba_to_rgba)
PR_(imlib_mmx_reshade_copy_rgba_to_rgb):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(m0XXX0XXX, %mm5)
LOAD_IMMQ(m0VVV0VVV, %mm6)
CLEANUP_IMMQ_LOADS(2)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
movq %mm1, %mm3
psubusb %mm6, %mm1
paddusb %mm1, %mm1
paddusb %mm6, %mm3
pxor %mm5, %mm3
paddusb %mm3, %mm3
pand %mm5, %mm1
pand %mm5, %mm3
paddusb %mm1, %mm2
psubusb %mm3, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
movq %mm1, %mm3
psubusb %mm6, %mm1
paddusb %mm1, %mm1
paddusb %mm6, %mm3
pxor %mm5, %mm3
paddusb %mm3, %mm3
pand %mm5, %mm1
pand %mm5, %mm3
paddusb %mm1, %mm2
psubusb %mm3, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_reshade_copy_rgba_to_rgb)
PR_(imlib_mmx_reshade_copy_rgba_to_rgba):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(m0XXX0XXX, %mm5)
LOAD_IMMQ(m0VVV0VVV, %mm6)
CLEANUP_IMMQ_LOADS(2)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
movq %mm1, %mm3
psubusb %mm6, %mm1
movq %mm1, %mm0
pand %mm5, %mm0
paddusb %mm0, %mm1
paddusb %mm6, %mm3
pxor %mm5, %mm3
paddusb %mm3, %mm3
pand %mm5, %mm3
paddusb %mm1, %mm2
psubusb %mm3, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
movq %mm1, %mm3
psubusb %mm6, %mm1
movq %mm1, %mm0
pand %mm5, %mm0
paddusb %mm0, %mm1
paddusb %mm6, %mm3
pxor %mm5, %mm3
paddusb %mm3, %mm3
pand %mm5, %mm3
paddusb %mm1, %mm2
psubusb %mm3, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_reshade_copy_rgba_to_rgba)
PR_(imlib_mmx_reshade_copy_rgb_to_rgba):
ENTER
pxor %mm4, %mm4
LOAD_IMMQ(m0XXX0XXX, %mm5)
LOAD_IMMQ(m0VVV0VVV, %mm6)
LOAD_IMMQ(mX000X000, %mm7)
CLEANUP_IMMQ_LOADS(3)
subl $4, %esi
subl $4, %edi
LOOP_START
incl %ecx
jz 2f
1:
movq (%esi, %ecx, 4), %mm1
movq (%edi, %ecx, 4), %mm2
movq %mm1, %mm3
psubusb %mm6, %mm1
paddusb %mm1, %mm1
paddusb %mm6, %mm3
pxor %mm5, %mm3
paddusb %mm3, %mm3
paddusb %mm1, %mm2
psubusb %mm3, %mm2
por %mm7, %mm2
movq %mm2, (%edi, %ecx, 4)
addl $2, %ecx
js 1b
jnz 3f
2:
movd (%esi), %mm1
movd (%edi), %mm2
movq %mm1, %mm3
psubusb %mm6, %mm1
paddusb %mm1, %mm1
paddusb %mm6, %mm3
pxor %mm5, %mm3
paddusb %mm3, %mm3
paddusb %mm1, %mm2
psubusb %mm3, %mm2
por %mm7, %mm2
movd %mm2, (%edi)
3:
LOOP_END
LEAVE
SIZE(imlib_mmx_reshade_copy_rgb_to_rgba)
#endif
#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif