[x265] [PATCH 2 of 2] x86inc: Make INIT_CPUFLAGS support an arbitrary number of cpuflags
Min Chen
chenm003 at 163.com
Tue Aug 26 21:12:29 CEST 2014
# HG changeset patch
# User Min Chen <chenm003 at 163.com>
# Date 1409080339 25200
# Node ID db45df086273cd428b026ef2a8bf2acc71ecca66
# Parent a93495d3478644292d5f06ebd9083407f6e561cd
x86inc: Make INIT_CPUFLAGS support an arbitrary number of cpuflags
diff -r a93495d34786 -r db45df086273 source/common/x86/x86inc.asm
--- a/source/common/x86/x86inc.asm Tue Aug 26 12:11:56 2014 -0700
+++ b/source/common/x86/x86inc.asm Tue Aug 26 12:12:19 2014 -0700
@@ -92,9 +92,6 @@
default rel
%endif
-; Always use long nops (reduces 0x90 spam in disassembly on x86_32)
-CPU amdnop
-
; Macros to eliminate most code duplication between x86_32 and x86_64:
; Currently this works only for leaf functions which load all their arguments
; into registers at the start, and make no other use of the stack. Luckily that
@@ -758,19 +755,26 @@
%define cpuflag(x) ((cpuflags & (cpuflags_ %+ x)) == (cpuflags_ %+ x))
%define notcpuflag(x) ((cpuflags & (cpuflags_ %+ x)) != (cpuflags_ %+ x))
-; Takes up to 2 cpuflags from the above list.
+; Takes an arbitrary number of cpuflags from the above list.
; All subsequent functions (up to the next INIT_CPUFLAGS) is built for the specified cpu.
; You shouldn't need to invoke this macro directly, it's a subroutine for INIT_MMX &co.
-%macro INIT_CPUFLAGS 0-2
- CPU amdnop
+%macro INIT_CPUFLAGS 0-*
+ %xdefine SUFFIX
+ %undef cpuname
+ %assign cpuflags 0
+
%if %0 >= 1
- %xdefine cpuname %1
- %assign cpuflags cpuflags_%1
- %if %0 >= 2
- %xdefine cpuname %1_%2
- %assign cpuflags cpuflags | cpuflags_%2
- %endif
+ %rep %0
+ %ifdef cpuname
+ %xdefine cpuname cpuname %+ _%1
+ %else
+ %xdefine cpuname %1
+ %endif
+ %assign cpuflags cpuflags | cpuflags_%1
+ %rotate 1
+ %endrep
%xdefine SUFFIX _ %+ cpuname
+
%if cpuflag(avx)
%assign avx_enabled 1
%endif
@@ -781,16 +785,15 @@
%endif
%if cpuflag(aligned)
%define movu mova
- %elifidn %1, sse3
+ %elif cpuflag(sse3) && notcpuflag(ssse3)
%define movu lddqu
%endif
- %if ARCH_X86_64 == 0 && notcpuflag(sse2)
- CPU basicnop
- %endif
+ %endif
+
+ %if ARCH_X86_64 || cpuflag(sse2)
+ CPU amdnop
%else
- %xdefine SUFFIX
- %undef cpuname
- %undef cpuflags
+ CPU basicnop
%endif
%endmacro
More information about the x265-devel
mailing list