[FFmpeg-devel] [PATCH 09/11] avcodec/mips: loongson optimize blockdsp with mmi v2

周晓勇 ipfootball at 126.com
Tue May 17 13:14:24 CEST 2016


avcodec/mips/blockdsp_mmi: Version 2 of the optimizations for loongson mmi
    
    1. no longer use the register names directly and optimized code format
    2. to be compatible with O32, specify type of address variable with mips_reg and handle the address variable with PTR_ operator
    






在 2016-05-13 18:06:56,"周晓勇" <ipfootball at 126.com> 写道:

From 9e5ade4c99eb23f72a89f0054f8b5626c9acceb3 Mon Sep 17 00:00:00 2001
From: ZhouXiaoyong <zhouxiaoyong at loongson.cn>
Date: Fri, 13 May 2016 14:30:10 +0800
Subject: [PATCH 09/11] avcodec/mips: loongson optimize blockdsp with mmi v2


---
 libavcodec/mips/blockdsp_mmi.c | 195 ++++++++++++++++++++++-------------------
 1 file changed, 103 insertions(+), 92 deletions(-)


diff --git a/libavcodec/mips/blockdsp_mmi.c b/libavcodec/mips/blockdsp_mmi.c
index 63eaf69..6eb2bd7 100644
--- a/libavcodec/mips/blockdsp_mmi.c
+++ b/libavcodec/mips/blockdsp_mmi.c
@@ -22,126 +22,137 @@
  */
 
 #include "blockdsp_mips.h"
+#include "libavutil/mips/asmdefs.h"
 
 void ff_fill_block16_mmi(uint8_t *block, uint8_t value, int line_size, int h)
 {
+    double ftmp[1];
+
     __asm__ volatile (
-        "move $8, %3                \r\n"
-        "move $9, %0                \r\n"
-        "dmtc1 %1, $f2              \r\n"
-        "punpcklbh $f2, $f2, $f2    \r\n"
-        "punpcklbh $f2, $f2, $f2    \r\n"
-        "punpcklbh $f2, $f2, $f2    \r\n"
-        "1:                         \r\n"
-        "gssdlc1 $f2, 7($9)         \r\n"
-        "gssdrc1 $f2, 0($9)         \r\n"
-        "gssdlc1 $f2, 15($9)        \r\n"
-        "gssdrc1 $f2, 8($9)         \r\n"
-        "daddi $8, $8, -1           \r\n"
-        "daddu $9, $9, %2           \r\n"
-        "bnez $8, 1b                \r\n"
-        ::"r"(block),"r"(value),"r"(line_size),"r"(h)
-        : "$8","$9"
+        "mtc1       %[value],   %[ftmp0]                                \n\t"
+        "punpcklbh  %[ftmp0],   %[ftmp0],       %[ftmp0]                \n\t"
+        "punpcklbh  %[ftmp0],   %[ftmp0],       %[ftmp0]                \n\t"
+        "punpcklbh  %[ftmp0],   %[ftmp0],       %[ftmp0]                \n\t"
+        "1:                                                             \n\t"
+        "gssdlc1    %[ftmp0],   0x07(%[block])                          \n\t"
+        "gssdrc1    %[ftmp0],   0x00(%[block])                          \n\t"
+        PTR_ADDI    "%[h],      %[h],           -0x01                   \n\t"
+        "gssdlc1    %[ftmp0],   0x0f(%[block])                          \n\t"
+        "gssdrc1    %[ftmp0],   0x08(%[block])                          \n\t"
+        PTR_ADDU   "%[block],   %[block],       %[line_size]            \n\t"
+        "bnez       %[h],       1b                                      \n\t"
+        : [block]"+&r"(block),              [h]"+&r"(h),
+          [ftmp0]"=&f"(ftmp[0])
+        : [value]"r"(value),                [line_size]"r"((mips_reg)line_size)
+        : "memory"
     );
 }
 
 void ff_fill_block8_mmi(uint8_t *block, uint8_t value, int line_size, int h)
 {
+    double ftmp0;
+
     __asm__ volatile (
-        "move $8, %3                \r\n"
-        "move $9, %0                \r\n"
-        "dmtc1 %1, $f2              \r\n"
-        "punpcklbh $f2, $f2, $f2    \r\n"
-        "punpcklbh $f2, $f2, $f2    \r\n"
-        "punpcklbh $f2, $f2, $f2    \r\n"
-        "1:                         \r\n"
-        "gssdlc1 $f2, 7($9)         \r\n"
-        "gssdrc1 $f2, 0($9)         \r\n"
-        "daddi $8, $8, -1           \r\n"
-        "daddu $9, $9, %2           \r\n"
-        "bnez $8, 1b                \r\n"
-        ::"r"(block),"r"(value),"r"(line_size),"r"(h)
-        : "$8","$9"
+        "mtc1       %[value],   %[ftmp0]                                \n\t"
+        "punpcklbh  %[ftmp0],   %[ftmp0],       %[ftmp0]                \n\t"
+        "punpcklbh  %[ftmp0],   %[ftmp0],       %[ftmp0]                \n\t"
+        "punpcklbh  %[ftmp0],   %[ftmp0],       %[ftmp0]                \n\t"
+        "1:                                                             \n\t"
+        "gssdlc1    %[ftmp0],   0x07(%[block])                          \n\t"
+        "gssdrc1    %[ftmp0],   0x00(%[block])                          \n\t"
+        PTR_ADDI   "%[h],       %[h],           -0x01                   \n\t"
+        PTR_ADDU   "%[block],   %[block],       %[line_size]            \n\t"
+        "bnez       %[h],       1b                                      \n\t"
+        : [block]"+&r"(block),              [h]"+&r"(h),
+          [ftmp0]"=&f"(ftmp0)
+        : [value]"r"(value),                [line_size]"r"((mips_reg)line_size)
+        : "memory"
     );
 }
 
 void ff_clear_block_mmi(int16_t *block)
 {
+    double ftmp[2];
+
     __asm__ volatile (
-        "xor $f0, $f0, $f0              \r\n"
-        "xor $f2, $f2, $f2              \r\n"
-        "gssqc1 $f0, $f2,   0(%0)       \r\n"
-        "gssqc1 $f0, $f2,  16(%0)       \r\n"
-        "gssqc1 $f0, $f2,  32(%0)       \r\n"
-        "gssqc1 $f0, $f2,  48(%0)       \r\n"
-        "gssqc1 $f0, $f2,  64(%0)       \r\n"
-        "gssqc1 $f0, $f2,  80(%0)       \r\n"
-        "gssqc1 $f0, $f2,  96(%0)       \r\n"
-        "gssqc1 $f0, $f2, 112(%0)       \r\n"
-        ::"r"(block)
+        "xor        %[ftmp0],   %[ftmp0],       %[ftmp0]                \n\t"
+        "xor        %[ftmp1],   %[ftmp1],       %[ftmp1]                \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x00(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x10(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x20(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x30(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x40(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x50(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x60(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x70(%[block])          \n\t"
+        : [ftmp0]"=&f"(ftmp[0]),            [ftmp1]"=&f"(ftmp[1])
+        : [block]"r"(block)
         : "memory"
     );
 }
 
 void ff_clear_blocks_mmi(int16_t *block)
 {
+    double ftmp[2];
+
     __asm__ volatile (
-        "xor $f0, $f0, $f0              \r\n"
-        "xor $f2, $f2, $f2              \r\n"
-        "gssqc1 $f0, $f2,   0(%0)       \r\n"
-        "gssqc1 $f0, $f2,  16(%0)       \r\n"
-        "gssqc1 $f0, $f2,  32(%0)       \r\n"
-        "gssqc1 $f0, $f2,  48(%0)       \r\n"
-        "gssqc1 $f0, $f2,  64(%0)       \r\n"
-        "gssqc1 $f0, $f2,  80(%0)       \r\n"
-        "gssqc1 $f0, $f2,  96(%0)       \r\n"
-        "gssqc1 $f0, $f2, 112(%0)       \r\n"
+        "xor        %[ftmp0],   %[ftmp0],       %[ftmp0]                \n\t"
+        "xor        %[ftmp1],   %[ftmp1],       %[ftmp1]                \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x00(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x10(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x20(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x30(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x40(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x50(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x60(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x70(%[block])          \n\t"
 
-        "gssqc1 $f0, $f2, 128(%0)       \r\n"
-        "gssqc1 $f0, $f2, 144(%0)       \r\n"
-        "gssqc1 $f0, $f2, 160(%0)       \r\n"
-        "gssqc1 $f0, $f2, 176(%0)       \r\n"
-        "gssqc1 $f0, $f2, 192(%0)       \r\n"
-        "gssqc1 $f0, $f2, 208(%0)       \r\n"
-        "gssqc1 $f0, $f2, 224(%0)       \r\n"
-        "gssqc1 $f0, $f2, 240(%0)       \r\n"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x80(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x90(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0xa0(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0xb0(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0xc0(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0xd0(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0xe0(%[block])          \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0xf0(%[block])          \n\t"
 
-        "gssqc1 $f0, $f2, 256(%0)       \r\n"
-        "gssqc1 $f0, $f2, 272(%0)       \r\n"
-        "gssqc1 $f0, $f2, 288(%0)       \r\n"
-        "gssqc1 $f0, $f2, 304(%0)       \r\n"
-        "gssqc1 $f0, $f2, 320(%0)       \r\n"
-        "gssqc1 $f0, $f2, 336(%0)       \r\n"
-        "gssqc1 $f0, $f2, 352(%0)       \r\n"
-        "gssqc1 $f0, $f2, 368(%0)       \r\n"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x100(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x110(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x120(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x130(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x140(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x150(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x160(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x170(%[block])         \n\t"
 
-        "gssqc1 $f0, $f2, 384(%0)       \r\n"
-        "gssqc1 $f0, $f2, 400(%0)       \r\n"
-        "gssqc1 $f0, $f2, 416(%0)       \r\n"
-        "gssqc1 $f0, $f2, 432(%0)       \r\n"
-        "gssqc1 $f0, $f2, 448(%0)       \r\n"
-        "gssqc1 $f0, $f2, 464(%0)       \r\n"
-        "gssqc1 $f0, $f2, 480(%0)       \r\n"
-        "gssqc1 $f0, $f2, 496(%0)       \r\n"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x180(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x190(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x1a0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x1b0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x1c0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x1d0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x1e0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x1f0(%[block])         \n\t"
 
-        "gssqc1 $f0, $f2, 512(%0)       \r\n"
-        "gssqc1 $f0, $f2, 528(%0)       \r\n"
-        "gssqc1 $f0, $f2, 544(%0)       \r\n"
-        "gssqc1 $f0, $f2, 560(%0)       \r\n"
-        "gssqc1 $f0, $f2, 576(%0)       \r\n"
-        "gssqc1 $f0, $f2, 592(%0)       \r\n"
-        "gssqc1 $f0, $f2, 608(%0)       \r\n"
-        "gssqc1 $f0, $f2, 624(%0)       \r\n"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x200(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x210(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x220(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x230(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x240(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x250(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x260(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x270(%[block])         \n\t"
 
-        "gssqc1 $f0, $f2, 640(%0)       \r\n"
-        "gssqc1 $f0, $f2, 656(%0)       \r\n"
-        "gssqc1 $f0, $f2, 672(%0)       \r\n"
-        "gssqc1 $f0, $f2, 688(%0)       \r\n"
-        "gssqc1 $f0, $f2, 704(%0)       \r\n"
-        "gssqc1 $f0, $f2, 720(%0)       \r\n"
-        "gssqc1 $f0, $f2, 736(%0)       \r\n"
-        "gssqc1 $f0, $f2, 752(%0)       \r\n"
-        ::"r"(block)
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x280(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x290(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x2a0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x2b0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x2c0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x2d0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x2e0(%[block])         \n\t"
+        "gssqc1     %[ftmp0],   %[ftmp1],       0x2f0(%[block])         \n\t"
+        : [ftmp0]"=&f"(ftmp[0]),            [ftmp1]"=&f"(ftmp[1])
+        : [block]"r"((mips_reg)block)
         : "memory"
     );
 }
-- 
2.1.0



More information about the ffmpeg-devel mailing list