[FFmpeg-devel] [PATCH v7 1/3] mips: improve detection of ISAs, FPU and ASEs (DSP, MSA)

Vicente Olivert Riera Vincent.Riera at imgtec.com
Wed Feb 24 17:38:20 CET 2016


Signed-off-by: Vicente Olivert Riera <Vincent.Riera at imgtec.com>
---
Changes v6 -> v7:
 - Do not pass -msoft-float. Leave the mipsfpu handling as it was
   before, so nothing changes. This could be improbed in the future.

Changes v5 -> v6:
 - Multiple changes:
   - Use separate if blocks when detecting the MIPS ISA, this way when a block
     disables one ISA it will be detected by the next one. Before the elif was
     preventing this to be done.
   - Don't use check_cflags and use only check_ldflags instead, which will
     check if that flag is valid for compiling and linking. The compiler may
     accept some cflags for compiling but not for linking, so if we check first
     for the cflags it will succeed, and the cflags will be added to the CFLAGS
     variable despite of the check_ldflags failing after that. This can cause
     problems because of having multiple incompatible cflags enabled at the same
     time.
   - Check if mipsfpu has been disabled, and if so, then use -msoft-float. This
     way we override the compiler default behavious which can be building for
     hard-float.
   - Explicitly disable the features that fail any check by adding "|| disable
     $feature" at the end of the checks chain.

Changes v4 -> v5:
 - Check for msa.h and disable msa if not found.

Changes v3 -> v4:
 - Nothing.

Changes v2 -> v3:
 - Nothing.

Changes v1 -> v2:
 - Add a block of code for mipsdspr2 which was previously placed in the
   first patch of this series causing a syntax error in the configure
   script.
   https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2015-November/183444.html

 configure | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 83 insertions(+), 18 deletions(-)

diff --git a/configure b/configure
index 857b683..ee0d00f 100755
--- a/configure
+++ b/configure
@@ -5076,27 +5076,92 @@ elif enabled mips; then
     enabled mmi && check_inline_asm mmi '"punpcklhw $f0, $f0, $f0"'
 
     # Enable minimum ISA based on selected options
-    if enabled mips64 && (enabled mipsdsp || enabled mipsdspr2); then
-        add_cflags "-mips64r2"
-        add_asflags "-mips64r2"
-    elif enabled mips64 && enabled mipsfpu && disabled loongson2 && disabled loongson3; then
-        add_cflags "-mips64"
-        add_asflags "-mips64"
-    elif enabled mipsdsp || enabled mipsdspr2; then
-        add_cflags "-mips32r2 -mfp32"
-        add_asflags "-mips32r2 -mfp32"
+    if enabled mips64; then
+        if enabled mips64r6; then
+            check_ldflags "-mips64r6" &&
+            add_cflags "-mips64r6" &&
+            add_asflags "-mips64r6" &&
+            check_inline_asm mips64r6 '"dlsa $0, $0, $0, 1"' ||
+            disable mips64r6
+        fi
+        if disabled mips64r6 && enabled mips64r2; then
+            check_ldflags "-mips64r2" &&
+            add_cflags "-mips64r2" &&
+            add_asflags "-mips64r2" &&
+            check_inline_asm mips64r2 '"dext $0, $0, 0, 1"' ||
+            disable mips64r2
+        fi
+        if disabled mips64r6 && disabled mips64r2; then
+            check_ldflags "-mips64" &&
+            add_cflags "-mips64" &&
+            add_asflags "-mips64" &&
+            check_inline_asm mips64r1 '"daddi $0, $0, 0"' ||
+            disable mips64r1
+        fi
+    else
+        if enabled mips32r6; then
+            check_ldflags "-mips32r6" &&
+            add_cflags "-mips32r6" &&
+            add_asflags "-mips32r6" &&
+            check_inline_asm mips32r6 '"aui $0, $0, 0"' ||
+            disable mips32r6
+        fi
+        if disabled mips32r6 && enabled mips32r2; then
+            check_ldflags "-mips32r2" &&
+            add_cflags "-mips32r2" &&
+            add_asflags "-mips32r2" &&
+            check_inline_asm mips32r2 '"ext $0, $0, 0, 1"' ||
+            disable mips32r2
+        fi
+        if disabled mips32r6 && disabled mips32r2; then
+            check_ldflags "-mips32" &&
+            add_cflags "-mips32" &&
+            add_asflags "-mips32" &&
+            check_inline_asm mips32r1 '"addi $0, $0, 0"' ||
+            disable mips32r1
+        fi
     fi
 
-    enabled mipsdsp && add_cflags "-mdsp" && add_asflags "-mdsp" &&
-     check_inline_asm mipsdsp '"addu.qb $t0, $t1, $t2"'
-    enabled mipsdspr2 && add_cflags "-mdspr2" && add_asflags "-mdspr2" &&
-     check_inline_asm mipsdspr2 '"absq_s.qb $t0, $t1"'
-    enabled mipsfpu   && add_cflags "-mhard-float" && add_asflags "-mhard-float" &&
-     check_inline_asm mipsfpu   '"madd.d $f0, $f2, $f4, $f6"'
-    enabled msa       && check_cflags "-mmsa" && check_ldflags "-mmsa" &&
-     check_inline_asm msa       '"addvi.b $w0, $w1, 1"'
+    # MIPS FPU
+    if enabled mipsfpu; then
+        check_ldflags "-mhard-float" &&
+        add_cflags "-mhard-float" &&
+        add_asflags "-mhard-float" &&
+        check_inline_asm mipsfpu '"cvt.d.l $f0, $f2"' ||
+        disable mipsfpu
+    fi
+
+    # MSA and DSP support require ISA revision level 2 or greater
+    if enabled mips32r2 || enabled mips64r2 || enabled mips32r6 || enabled mips64r6; then
+        # MSA must be used with -mfp64 and -mhard-float
+        if enabled mipsfpu; then
+            if enabled msa; then
+                check_ldflags "-mfp64 -mmsa" &&
+                add_cflags "-mfp64 -mmsa" &&
+                add_asflags "-mfp64 -mmsa" &&
+                check_inline_asm msa '"addvi.b $w0, $w1, 1"' &&
+                check_header msa.h ||
+                disable msa
+            fi
+        else
+            disable msa
+        fi
 
-    enabled msa && add_asflags "-mmsa"
+        if enabled mipsdsp; then
+            check_ldflags "-mdsp" &&
+            add_cflags "-mdsp" &&
+            add_asflags "-mdsp" &&
+            check_inline_asm mipsdsp '"addu.qb $t0, $t1, $t2"' ||
+            disable mipsdsp
+        fi
+        if enabled mipsdspr2; then
+            check_ldflags "-mdspr2" &&
+            add_cflags "-mdspr2" &&
+            add_asflags "-mdspr2" &&
+            check_inline_asm mipsdspr2 '"absq_s.qb $t0, $t1"' ||
+            disable mipsdspr2
+        fi
+    fi
 
 elif enabled parisc; then
 
-- 
2.4.10



More information about the ffmpeg-devel mailing list