Update spec to build Qt 5.0
[profile/ivi/qtbase.git] / src / gui / painting / qt_mips_asm_dsp.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 MIPS Technologies, www.mips.com, author Damir Tatalovic <dtatalovic@mips.com>
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.  For licensing terms and
14 ** conditions see http://qt.digia.com/licensing.  For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights.  These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file.  Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QT_MIPS_ASM_DSP_H
43 #define QT_MIPS_ASM_DSP_H
44
45 #if 0
46 #pragma qt_sync_stop_processing
47 #endif
48
49 #define zero $0
50 #define AT   $1
51 #define v0   $2
52 #define v1   $3
53 #define a0   $4
54 #define a1   $5
55 #define a2   $6
56 #define a3   $7
57 #define t0   $8
58 #define t1   $9
59 #define t2   $10
60 #define t3   $11
61 #define t4   $12
62 #define t5   $13
63 #define t6   $14
64 #define t7   $15
65 #define s0   $16
66 #define s1   $17
67 #define s2   $18
68 #define s3   $19
69 #define s4   $20
70 #define s5   $21
71 #define s6   $22
72 #define s7   $23
73 #define t8   $24
74 #define t9   $25
75 #define k0   $26
76 #define k1   $27
77 #define gp   $28
78 #define sp   $29
79 #define fp   $30
80 #define s8   $30
81 #define ra   $31
82
83 /*
84  * LEAF_MIPS32R2 - declare leaf_mips32r2 routine
85  */
86 #define LEAF_MIPS32R2(symbol)                           \
87                 .globl  symbol;                         \
88                 .align  2;                              \
89                 .type   symbol,@function;               \
90                 .ent    symbol,0;                       \
91 symbol:         .frame  sp, 0, ra;                      \
92                 .set    arch=mips32r2;                  \
93                 .set    noreorder;
94
95 /*
96  * LEAF_MIPS_DSP - declare leaf_mips_dsp routine
97  */
98 #define LEAF_MIPS_DSP(symbol)                           \
99 LEAF_MIPS32R2(symbol)                                   \
100                 .set    dsp;
101
102 /*
103  * LEAF_MIPS_DSPR2 - declare leaf_mips_dspr2 routine
104  */
105 #define LEAF_MIPS_DSPR2(symbol)                         \
106 LEAF_MIPS32R2(symbol)                                   \
107                 .set   dspr2;
108
109 /*
110  * END - mark end of function
111  */
112 #define END(function)                                   \
113                 .set    reorder;                        \
114                 .end    function;                       \
115                 .size   function,.-function
116
117 /*
118  * BYTE_MUL operation on two pixels (in_1 and in_2) with two
119  * multiplicator bytes, repl_a1 and repl_a2, which should be
120  * prepered with:
121  *   replv.ph   repl_a1, a1
122  *   replv.ph   repl_a2, a2
123  * to became such as:
124  *   repl_a1 = | 00 | a1 | 00 | a1 |
125  *   repl_a2 = | 00 | a2 | 00 | a2 |
126  *
127  * rounding_factor must have following value:
128  *   li    rounding_factor, 0x00800080
129  *
130  * scratch(n) - temporary registers
131  *
132  * in_const: 1 -> (default) causes that in_1, in_2
133  *           registers will remain unchanged after usage
134  *           0 -> (or anything different then 1) causes
135  *           that registers repl_a1, repl_a2 remain
136  *           unchanged after usage
137  */
138 .macro BYTE_MUL_x2 in_1, in_2, out_1, out_2                 \
139                    repl_a1, repl_a2, rounding_factor,       \
140                    scratch1, scratch2, scratch3, scratch4,  \
141                    in_const = 1
142     muleu_s.ph.qbl    \scratch1, \in_1,     \repl_a1
143     muleu_s.ph.qbr    \scratch2, \in_1,     \repl_a1
144     muleu_s.ph.qbl    \scratch3, \in_2,     \repl_a2
145     muleu_s.ph.qbr    \scratch4, \in_2,     \repl_a2
146
147 .if \in_const == 1
148     preceu.ph.qbla    \repl_a1,  \scratch1
149     preceu.ph.qbla    \repl_a2,  \scratch2
150     preceu.ph.qbla    \out_1,    \scratch3
151     preceu.ph.qbla    \out_2,    \scratch4
152
153     addu              \scratch1,  \repl_a1, \scratch1
154     addu              \scratch2,  \repl_a2, \scratch2
155 .else
156     preceu.ph.qbla    \in_1,      \scratch1
157     preceu.ph.qbla    \in_2,      \scratch2
158     preceu.ph.qbla    \out_1,     \scratch3
159     preceu.ph.qbla    \out_2,     \scratch4
160
161     addu              \scratch1,  \in_1,    \scratch1
162     addu              \scratch2,  \in_2,    \scratch2
163 .endif
164
165     addu              \out_1,     \out_1,   \scratch3
166     addu              \out_2,     \out_2,   \scratch4
167
168     addu              \scratch1,  \scratch1, \rounding_factor
169     addu              \scratch2,  \scratch2, \rounding_factor
170     addu              \scratch3,  \out_1,    \rounding_factor
171     addu              \scratch4,  \out_2,    \rounding_factor
172
173     precrq.qb.ph      \out_1,     \scratch1, \scratch2
174     precrq.qb.ph      \out_2,     \scratch3, \scratch4
175
176 .endm
177
178 /*
179  * BYTE_MUL operation on one pixel (in_1) with
180  * multiplicator byte, repl_a1, which should be
181  * prepered with:
182  *   replv.ph   repl_a1, a1
183  * to became such as:
184  *   repl_a1 = | 00 | a1 | 00 | a1 |
185  *
186  * rounding_factor must have following value:
187  *   li    rounding_factor, 0x00800080
188  *
189  * scratch(n) - temporary registers
190  */
191 .macro BYTE_MUL in_1, out_1,                            \
192                 repl_a1, rounding_factor,               \
193                 scratch1, scratch2, scratch3, scratch4
194     muleu_s.ph.qbl    \scratch1, \in_1,     \repl_a1
195     muleu_s.ph.qbr    \scratch2, \in_1,     \repl_a1
196
197     preceu.ph.qbla    \scratch3, \scratch1
198     preceu.ph.qbla    \scratch4, \scratch2
199
200     addu              \scratch1, \scratch1, \scratch3
201     addu              \scratch1, \scratch1, \rounding_factor
202
203     addu              \scratch2, \scratch2, \scratch4
204     addu              \scratch2, \scratch2, \rounding_factor
205
206     precrq.qb.ph      \out_1,    \scratch1, \scratch2
207
208 .endm
209
210 /*
211  * macro for INTERPOLATE_PIXEL_255 operation
212  * in_1 - First value to multiply
213  * mul_1 - Multiplicator byte for first value
214  * in_2 - Second value to multiply
215  * mul_2 - Multiplicator byte for second value
216  * rounding_factor and andi_factor should be prepared
217  * as:
218  *     li     rounding_factor, 0x00800080
219  *     li     andi_factor,     0xff00ff00
220  * scratch(n) - temporary registers
221  */
222 .macro INTERPOLATE_PIXEL_255 in_1, mul_1,                            \
223                              in_2, mul_2,                            \
224                              out_1,                                  \
225                              rounding_factor, andi_factor            \
226                              scratch1, scratch2, scratch3, scratch4
227 # x part
228     preceu.ph.qbra    \scratch1, \in_1
229     preceu.ph.qbra    \scratch2, \in_2
230     mul               \scratch1, \scratch1, \mul_1
231     mul               \scratch2, \scratch2, \mul_2
232 # x>>8 part
233     preceu.ph.qbla    \scratch3, \in_1
234     preceu.ph.qbla    \scratch4, \in_2
235     mul               \scratch3, \scratch3, \mul_1
236     mul               \scratch4, \scratch4, \mul_2
237 # x part
238     addu              \scratch1, \scratch1, \scratch2
239     preceu.ph.qbla    \scratch2, \scratch1
240     addu              \scratch1, \scratch1, \scratch2
241     addu              \scratch1, \scratch1, \rounding_factor
242     preceu.ph.qbla    \scratch1, \scratch1
243 # x>>8 part
244     addu              \scratch3, \scratch3, \scratch4
245     preceu.ph.qbla    \scratch4, \scratch3
246     addu              \scratch3, \scratch3, \scratch4
247     addu              \scratch3, \scratch3, \rounding_factor
248     and               \scratch3, \scratch3, \andi_factor
249
250     or                \out_1,    \scratch1, \scratch3
251 .endm
252
253 #endif // QT_MIPS_ASM_DSP_H