[2/7] configure: Add check_x86asm() helper function to simplify some expressions

Message ID 20180320094930.5424-3-diego@biurrun.de
State Committed
Headers show
Series
  • [1/7] configure: Document available options for the --toolchain parameter
Related show

Commit Message

Diego Biurrun March 20, 2018, 9:49 a.m.
---
 configure | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

Comments

James Almer March 22, 2018, 2 p.m. | #1
On 3/20/2018 6:49 AM, Diego Biurrun wrote:
> ---
>  configure | 32 ++++++++++++++++++++------------
>  1 file changed, 20 insertions(+), 12 deletions(-)
> 
> diff --git a/configure b/configure
> index d8c3b555cc..ce0d791c1b 100755
> --- a/configure
> +++ b/configure
> @@ -808,6 +808,14 @@ test_as(){
>      test_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
>  }
>  
> +test_x86asm(){
> +    log test_x86asm "$@"
> +    echo "$1" > $TMPS
> +    log_file $TMPS
> +    shift 1
> +    test_cmd $x86asmexe $X86ASMFLAGS "$@" -o $TMPO $TMPS
> +}
> +
>  check_cmd(){
>      log check_cmd "$@"
>      cmd=$1
> @@ -844,12 +852,12 @@ check_insn(){
>      check_as ${1}_external "$2"
>  }
>  
> -test_x86asm(){
> -    log test_x86asm "$@"
> -    echo "$1" > $TMPS
> -    log_file $TMPS
> -    shift 1
> -    test_cmd $x86asmexe $X86ASMFLAGS "$@" -o $TMPO $TMPS
> +check_x86asm(){
> +    log check_x86asm "$@"
> +    name=$1
> +    shift

Maybe be explicit it should shift 1.

> +    disable $name
> +    test_x86asm "$@" && enable $name
>  }
>  
>  ld_o(){
> @@ -4421,7 +4429,7 @@ EOF
>              X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) -M $(X86ASM_O) $< > $(@:.o=.d)'
>              X86ASM_DEPFLAGS=
>          fi
> -        test_x86asm "movbe ecx, [5]" && enable x86asm
> +        check_x86asm x86asm "movbe ecx, [5]"
>      }
>  
>      if ! disabled_any asm mmx x86asm; then
> @@ -4437,11 +4445,11 @@ EOF
>              elf*) enabled debug && append X86ASMFLAGS $x86asm_debug ;;
>          esac
>  
> -        test_x86asm "vextracti128 xmm0, ymm0, 0"      || disable avx2_external
> -        test_x86asm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
> -        test_x86asm "vfmadd132ps ymm0, ymm1, ymm2"    || disable fma3_external
> -        test_x86asm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
> -        test_x86asm "CPU amdnop"                      || disable cpunop
> +        check_x86asm avx2_external "vextracti128 xmm0, ymm0, 0"
> +        check_x86asm  xop_external "vpmacsdd xmm0, xmm1, xmm2, xmm3"
> +        check_x86asm fma3_external "vfmadd132ps ymm0, ymm1, ymm2"
> +        check_x86asm fma4_external "vfmaddps ymm0, ymm1, ymm2, ymm3"
> +        check_x86asm cpunop        "CPU amdnop"
>      fi
>  
>      case "$cpu" in
> 

LGTM.
Diego Biurrun March 26, 2018, 4:54 p.m. | #2
On Thu, Mar 22, 2018 at 11:00:52AM -0300, James Almer wrote:
> On 3/20/2018 6:49 AM, Diego Biurrun wrote:
> > --- a/configure
> > +++ b/configure
> > @@ -844,12 +852,12 @@ check_insn(){
> >  
> > +check_x86asm(){
> > +    log check_x86asm "$@"
> > +    name=$1
> > +    shift
> 
> Maybe be explicit it should shift 1.

No, I'd rather drop the '1', most places don't add the redundant '1' to
the shift invocations.

Diego

Patch

diff --git a/configure b/configure
index d8c3b555cc..ce0d791c1b 100755
--- a/configure
+++ b/configure
@@ -808,6 +808,14 @@  test_as(){
     test_cmd $as $CPPFLAGS $ASFLAGS "$@" $AS_C $(as_o $TMPO) $TMPS
 }
 
+test_x86asm(){
+    log test_x86asm "$@"
+    echo "$1" > $TMPS
+    log_file $TMPS
+    shift 1
+    test_cmd $x86asmexe $X86ASMFLAGS "$@" -o $TMPO $TMPS
+}
+
 check_cmd(){
     log check_cmd "$@"
     cmd=$1
@@ -844,12 +852,12 @@  check_insn(){
     check_as ${1}_external "$2"
 }
 
-test_x86asm(){
-    log test_x86asm "$@"
-    echo "$1" > $TMPS
-    log_file $TMPS
-    shift 1
-    test_cmd $x86asmexe $X86ASMFLAGS "$@" -o $TMPO $TMPS
+check_x86asm(){
+    log check_x86asm "$@"
+    name=$1
+    shift
+    disable $name
+    test_x86asm "$@" && enable $name
 }
 
 ld_o(){
@@ -4421,7 +4429,7 @@  EOF
             X86ASMDEP='$(DEPX86ASM) $(X86ASMFLAGS) -M $(X86ASM_O) $< > $(@:.o=.d)'
             X86ASM_DEPFLAGS=
         fi
-        test_x86asm "movbe ecx, [5]" && enable x86asm
+        check_x86asm x86asm "movbe ecx, [5]"
     }
 
     if ! disabled_any asm mmx x86asm; then
@@ -4437,11 +4445,11 @@  EOF
             elf*) enabled debug && append X86ASMFLAGS $x86asm_debug ;;
         esac
 
-        test_x86asm "vextracti128 xmm0, ymm0, 0"      || disable avx2_external
-        test_x86asm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
-        test_x86asm "vfmadd132ps ymm0, ymm1, ymm2"    || disable fma3_external
-        test_x86asm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
-        test_x86asm "CPU amdnop"                      || disable cpunop
+        check_x86asm avx2_external "vextracti128 xmm0, ymm0, 0"
+        check_x86asm  xop_external "vpmacsdd xmm0, xmm1, xmm2, xmm3"
+        check_x86asm fma3_external "vfmadd132ps ymm0, ymm1, ymm2"
+        check_x86asm fma4_external "vfmaddps ymm0, ymm1, ymm2, ymm3"
+        check_x86asm cpunop        "CPU amdnop"
     fi
 
     case "$cpu" in