Path: blob/master/3rdparty/libwebp/src/dsp/mips_macro.h
16348 views
// Copyright 2014 Google Inc. All Rights Reserved.1//2// Use of this source code is governed by a BSD-style license3// that can be found in the COPYING file in the root of the source4// tree. An additional intellectual property rights grant can be found5// in the file PATENTS. All contributing project authors may6// be found in the AUTHORS file in the root of the source tree.7// -----------------------------------------------------------------------------8//9// MIPS common macros1011#ifndef WEBP_DSP_MIPS_MACRO_H_12#define WEBP_DSP_MIPS_MACRO_H_1314#if defined(__GNUC__) && defined(__ANDROID__) && LOCAL_GCC_VERSION == 0x40915#define WORK_AROUND_GCC16#endif1718#define STR(s) #s19#define XSTR(s) STR(s)2021// O0[31..16 | 15..0] = I0[31..16 | 15..0] + I1[31..16 | 15..0]22// O1[31..16 | 15..0] = I0[31..16 | 15..0] - I1[31..16 | 15..0]23// O - output24// I - input (macro doesn't change it)25#define ADD_SUB_HALVES(O0, O1, \26I0, I1) \27"addq.ph %[" #O0 "], %[" #I0 "], %[" #I1 "] \n\t" \28"subq.ph %[" #O1 "], %[" #I0 "], %[" #I1 "] \n\t"2930// O - output31// I - input (macro doesn't change it)32// I[0/1] - offset in bytes33#define LOAD_IN_X2(O0, O1, \34I0, I1) \35"lh %[" #O0 "], " #I0 "(%[in]) \n\t" \36"lh %[" #O1 "], " #I1 "(%[in]) \n\t"3738// I0 - location39// I1..I9 - offsets in bytes40#define LOAD_WITH_OFFSET_X4(O0, O1, O2, O3, \41I0, I1, I2, I3, I4, I5, I6, I7, I8, I9) \42"ulw %[" #O0 "], " #I1 "+" XSTR(I9) "*" #I5 "(%[" #I0 "]) \n\t" \43"ulw %[" #O1 "], " #I2 "+" XSTR(I9) "*" #I6 "(%[" #I0 "]) \n\t" \44"ulw %[" #O2 "], " #I3 "+" XSTR(I9) "*" #I7 "(%[" #I0 "]) \n\t" \45"ulw %[" #O3 "], " #I4 "+" XSTR(I9) "*" #I8 "(%[" #I0 "]) \n\t"4647// O - output48// IO - input/output49// I - input (macro doesn't change it)50#define MUL_SHIFT_SUM(O0, O1, O2, O3, O4, O5, O6, O7, \51IO0, IO1, IO2, IO3, \52I0, I1, I2, I3, I4, I5, I6, I7) \53"mul %[" #O0 "], %[" #I0 "], %[kC2] \n\t" \54"mul %[" #O1 "], %[" #I0 "], %[kC1] \n\t" \55"mul %[" #O2 "], %[" #I1 "], %[kC2] \n\t" \56"mul %[" #O3 "], %[" #I1 "], %[kC1] \n\t" \57"mul %[" #O4 "], %[" #I2 "], %[kC2] \n\t" \58"mul %[" #O5 "], %[" #I2 "], %[kC1] \n\t" \59"mul %[" #O6 "], %[" #I3 "], %[kC2] \n\t" \60"mul %[" #O7 "], %[" #I3 "], %[kC1] \n\t" \61"sra %[" #O0 "], %[" #O0 "], 16 \n\t" \62"sra %[" #O1 "], %[" #O1 "], 16 \n\t" \63"sra %[" #O2 "], %[" #O2 "], 16 \n\t" \64"sra %[" #O3 "], %[" #O3 "], 16 \n\t" \65"sra %[" #O4 "], %[" #O4 "], 16 \n\t" \66"sra %[" #O5 "], %[" #O5 "], 16 \n\t" \67"sra %[" #O6 "], %[" #O6 "], 16 \n\t" \68"sra %[" #O7 "], %[" #O7 "], 16 \n\t" \69"addu %[" #IO0 "], %[" #IO0 "], %[" #I4 "] \n\t" \70"addu %[" #IO1 "], %[" #IO1 "], %[" #I5 "] \n\t" \71"subu %[" #IO2 "], %[" #IO2 "], %[" #I6 "] \n\t" \72"subu %[" #IO3 "], %[" #IO3 "], %[" #I7 "] \n\t"7374// O - output75// I - input (macro doesn't change it)76#define INSERT_HALF_X2(O0, O1, \77I0, I1) \78"ins %[" #O0 "], %[" #I0 "], 16, 16 \n\t" \79"ins %[" #O1 "], %[" #I1 "], 16, 16 \n\t"8081// O - output82// I - input (macro doesn't change it)83#define SRA_16(O0, O1, O2, O3, \84I0, I1, I2, I3) \85"sra %[" #O0 "], %[" #I0 "], 16 \n\t" \86"sra %[" #O1 "], %[" #I1 "], 16 \n\t" \87"sra %[" #O2 "], %[" #I2 "], 16 \n\t" \88"sra %[" #O3 "], %[" #I3 "], 16 \n\t"8990// temp0[31..16 | 15..0] = temp8[31..16 | 15..0] + temp12[31..16 | 15..0]91// temp1[31..16 | 15..0] = temp8[31..16 | 15..0] - temp12[31..16 | 15..0]92// temp0[31..16 | 15..0] = temp0[31..16 >> 3 | 15..0 >> 3]93// temp1[31..16 | 15..0] = temp1[31..16 >> 3 | 15..0 >> 3]94// O - output95// I - input (macro doesn't change it)96#define SHIFT_R_SUM_X2(O0, O1, O2, O3, O4, O5, O6, O7, \97I0, I1, I2, I3, I4, I5, I6, I7) \98"addq.ph %[" #O0 "], %[" #I0 "], %[" #I4 "] \n\t" \99"subq.ph %[" #O1 "], %[" #I0 "], %[" #I4 "] \n\t" \100"addq.ph %[" #O2 "], %[" #I1 "], %[" #I5 "] \n\t" \101"subq.ph %[" #O3 "], %[" #I1 "], %[" #I5 "] \n\t" \102"addq.ph %[" #O4 "], %[" #I2 "], %[" #I6 "] \n\t" \103"subq.ph %[" #O5 "], %[" #I2 "], %[" #I6 "] \n\t" \104"addq.ph %[" #O6 "], %[" #I3 "], %[" #I7 "] \n\t" \105"subq.ph %[" #O7 "], %[" #I3 "], %[" #I7 "] \n\t" \106"shra.ph %[" #O0 "], %[" #O0 "], 3 \n\t" \107"shra.ph %[" #O1 "], %[" #O1 "], 3 \n\t" \108"shra.ph %[" #O2 "], %[" #O2 "], 3 \n\t" \109"shra.ph %[" #O3 "], %[" #O3 "], 3 \n\t" \110"shra.ph %[" #O4 "], %[" #O4 "], 3 \n\t" \111"shra.ph %[" #O5 "], %[" #O5 "], 3 \n\t" \112"shra.ph %[" #O6 "], %[" #O6 "], 3 \n\t" \113"shra.ph %[" #O7 "], %[" #O7 "], 3 \n\t"114115// precrq.ph.w temp0, temp8, temp2116// temp0 = temp8[31..16] | temp2[31..16]117// ins temp2, temp8, 16, 16118// temp2 = temp8[31..16] | temp2[15..0]119// O - output120// IO - input/output121// I - input (macro doesn't change it)122#define PACK_2_HALVES_TO_WORD(O0, O1, O2, O3, \123IO0, IO1, IO2, IO3, \124I0, I1, I2, I3) \125"precrq.ph.w %[" #O0 "], %[" #I0 "], %[" #IO0 "] \n\t" \126"precrq.ph.w %[" #O1 "], %[" #I1 "], %[" #IO1 "] \n\t" \127"ins %[" #IO0 "], %[" #I0 "], 16, 16 \n\t" \128"ins %[" #IO1 "], %[" #I1 "], 16, 16 \n\t" \129"precrq.ph.w %[" #O2 "], %[" #I2 "], %[" #IO2 "] \n\t" \130"precrq.ph.w %[" #O3 "], %[" #I3 "], %[" #IO3 "] \n\t" \131"ins %[" #IO2 "], %[" #I2 "], 16, 16 \n\t" \132"ins %[" #IO3 "], %[" #I3 "], 16, 16 \n\t"133134// preceu.ph.qbr temp0, temp8135// temp0 = 0 | 0 | temp8[23..16] | temp8[7..0]136// preceu.ph.qbl temp1, temp8137// temp1 = temp8[23..16] | temp8[7..0] | 0 | 0138// O - output139// I - input (macro doesn't change it)140#define CONVERT_2_BYTES_TO_HALF(O0, O1, O2, O3, O4, O5, O6, O7, \141I0, I1, I2, I3) \142"preceu.ph.qbr %[" #O0 "], %[" #I0 "] \n\t" \143"preceu.ph.qbl %[" #O1 "], %[" #I0 "] \n\t" \144"preceu.ph.qbr %[" #O2 "], %[" #I1 "] \n\t" \145"preceu.ph.qbl %[" #O3 "], %[" #I1 "] \n\t" \146"preceu.ph.qbr %[" #O4 "], %[" #I2 "] \n\t" \147"preceu.ph.qbl %[" #O5 "], %[" #I2 "] \n\t" \148"preceu.ph.qbr %[" #O6 "], %[" #I3 "] \n\t" \149"preceu.ph.qbl %[" #O7 "], %[" #I3 "] \n\t"150151// temp0[31..16 | 15..0] = temp0[31..16 | 15..0] + temp8[31..16 | 15..0]152// temp0[31..16 | 15..0] = temp0[31..16 <<(s) 7 | 15..0 <<(s) 7]153// temp1..temp7 same as temp0154// precrqu_s.qb.ph temp0, temp1, temp0:155// temp0 = temp1[31..24] | temp1[15..8] | temp0[31..24] | temp0[15..8]156// store temp0 to dst157// IO - input/output158// I - input (macro doesn't change it)159#define STORE_SAT_SUM_X2(IO0, IO1, IO2, IO3, IO4, IO5, IO6, IO7, \160I0, I1, I2, I3, I4, I5, I6, I7, \161I8, I9, I10, I11, I12, I13) \162"addq.ph %[" #IO0 "], %[" #IO0 "], %[" #I0 "] \n\t" \163"addq.ph %[" #IO1 "], %[" #IO1 "], %[" #I1 "] \n\t" \164"addq.ph %[" #IO2 "], %[" #IO2 "], %[" #I2 "] \n\t" \165"addq.ph %[" #IO3 "], %[" #IO3 "], %[" #I3 "] \n\t" \166"addq.ph %[" #IO4 "], %[" #IO4 "], %[" #I4 "] \n\t" \167"addq.ph %[" #IO5 "], %[" #IO5 "], %[" #I5 "] \n\t" \168"addq.ph %[" #IO6 "], %[" #IO6 "], %[" #I6 "] \n\t" \169"addq.ph %[" #IO7 "], %[" #IO7 "], %[" #I7 "] \n\t" \170"shll_s.ph %[" #IO0 "], %[" #IO0 "], 7 \n\t" \171"shll_s.ph %[" #IO1 "], %[" #IO1 "], 7 \n\t" \172"shll_s.ph %[" #IO2 "], %[" #IO2 "], 7 \n\t" \173"shll_s.ph %[" #IO3 "], %[" #IO3 "], 7 \n\t" \174"shll_s.ph %[" #IO4 "], %[" #IO4 "], 7 \n\t" \175"shll_s.ph %[" #IO5 "], %[" #IO5 "], 7 \n\t" \176"shll_s.ph %[" #IO6 "], %[" #IO6 "], 7 \n\t" \177"shll_s.ph %[" #IO7 "], %[" #IO7 "], 7 \n\t" \178"precrqu_s.qb.ph %[" #IO0 "], %[" #IO1 "], %[" #IO0 "] \n\t" \179"precrqu_s.qb.ph %[" #IO2 "], %[" #IO3 "], %[" #IO2 "] \n\t" \180"precrqu_s.qb.ph %[" #IO4 "], %[" #IO5 "], %[" #IO4 "] \n\t" \181"precrqu_s.qb.ph %[" #IO6 "], %[" #IO7 "], %[" #IO6 "] \n\t" \182"usw %[" #IO0 "], " XSTR(I13) "*" #I9 "(%[" #I8 "]) \n\t" \183"usw %[" #IO2 "], " XSTR(I13) "*" #I10 "(%[" #I8 "]) \n\t" \184"usw %[" #IO4 "], " XSTR(I13) "*" #I11 "(%[" #I8 "]) \n\t" \185"usw %[" #IO6 "], " XSTR(I13) "*" #I12 "(%[" #I8 "]) \n\t"186187#define OUTPUT_EARLY_CLOBBER_REGS_10() \188: [temp1]"=&r"(temp1), [temp2]"=&r"(temp2), [temp3]"=&r"(temp3), \189[temp4]"=&r"(temp4), [temp5]"=&r"(temp5), [temp6]"=&r"(temp6), \190[temp7]"=&r"(temp7), [temp8]"=&r"(temp8), [temp9]"=&r"(temp9), \191[temp10]"=&r"(temp10)192193#define OUTPUT_EARLY_CLOBBER_REGS_18() \194OUTPUT_EARLY_CLOBBER_REGS_10(), \195[temp11]"=&r"(temp11), [temp12]"=&r"(temp12), [temp13]"=&r"(temp13), \196[temp14]"=&r"(temp14), [temp15]"=&r"(temp15), [temp16]"=&r"(temp16), \197[temp17]"=&r"(temp17), [temp18]"=&r"(temp18)198199#endif // WEBP_DSP_MIPS_MACRO_H_200201202