ps2 optimizations update patch by (Leon van Stuivenberg <leonvs at iae dot nl>)
[libav.git] / libavcodec / ps2 / mmi.h
1 #ifndef __mmi_H
2 #define __mmi_H
3
4 #define align16 __attribute__ ((aligned (16)))
5
6 /*
7 #define r0 $zero
8 #define r1 $at //assembler!
9 #define r2 $v0 //return
10 #define r3 $v1 //return
11 #define r4 $a0 //arg
12 #define r5 $a1 //arg
13 #define r6 $a2 //arg
14 #define r7 $a3 //arg
15 #define r8 $t0 //temp
16 #define r9 $t1 //temp
17 #define r10 $t2 //temp
18 #define r11 $t3 //temp
19 #define r12 $t4 //temp
20 #define r13 $t5 //temp
21 #define r14 $t6 //temp
22 #define r15 $t7 //temp
23 #define r16 $s0 //saved temp
24 #define r17 $s1 //saved temp
25 #define r18 $s2 //saved temp
26 #define r19 $s3 //saved temp
27 #define r20 $s4 //saved temp
28 #define r21 $s5 //saved temp
29 #define r22 $s6 //saved temp
30 #define r23 $s7 //saved temp
31 #define r24 $t8 //temp
32 #define r25 $t9 //temp
33 #define r26 $k0 //kernel
34 #define r27 $k1 //kernel
35 #define r28 $gp //global ptr
36 #define r29 $sp //stack ptr
37 #define r30 $fp //frame ptr
38 #define r31 $ra //return addr
39 */
40
41
42 #define lq(base, off, reg) \
43 __asm__ __volatile__ ("lq " #reg ", %0("#base ")" : : "i" (off) )
44
45 #define lq2(mem, reg) \
46 __asm__ __volatile__ ("lq " #reg ", %0" : : "r" (mem))
47
48 #define sq(reg, off, base) \
49 __asm__ __volatile__ ("sq " #reg ", %0("#base ")" : : "i" (off) )
50
51 /*
52 #define ld(base, off, reg) \
53 __asm__ __volatile__ ("ld " #reg ", " #off "("#base ")")
54 */
55
56 #define ld3(base, off, reg) \
57 __asm__ __volatile__ (".word %0" : : "i" ( 0xdc000000 | (base<<21) | (reg<<16) | (off)))
58
59 #define ldr3(base, off, reg) \
60 __asm__ __volatile__ (".word %0" : : "i" ( 0x6c000000 | (base<<21) | (reg<<16) | (off)))
61
62 #define ldl3(base, off, reg) \
63 __asm__ __volatile__ (".word %0" : : "i" ( 0x68000000 | (base<<21) | (reg<<16) | (off)))
64
65 /*
66 #define sd(reg, off, base) \
67 __asm__ __volatile__ ("sd " #reg ", " #off "("#base ")")
68 */
69 //seems assembler has bug encoding mnemonic 'sd', so DIY
70 #define sd3(reg, off, base) \
71 __asm__ __volatile__ (".word %0" : : "i" ( 0xfc000000 | (base<<21) | (reg<<16) | (off)))
72
73 #define sw(reg, off, base) \
74 __asm__ __volatile__ ("sw " #reg ", " #off "("#base ")")
75
76 #define sq2(reg, mem) \
77 __asm__ __volatile__ ("sq " #reg ", %0" : : "m" (*(mem)))
78
79 #define pinth(rs, rt, rd) \
80 __asm__ __volatile__ ("pinth " #rd ", " #rs ", " #rt )
81
82 #define phmadh(rs, rt, rd) \
83 __asm__ __volatile__ ("phmadh " #rd ", " #rs ", " #rt )
84
85 #define pcpyud(rs, rt, rd) \
86 __asm__ __volatile__ ("pcpyud " #rd ", " #rs ", " #rt )
87
88 #define pcpyld(rs, rt, rd) \
89 __asm__ __volatile__ ("pcpyld " #rd ", " #rs ", " #rt )
90
91 #define pcpyh(rt, rd) \
92 __asm__ __volatile__ ("pcpyh " #rd ", " #rt )
93
94 #define paddw(rs, rt, rd) \
95 __asm__ __volatile__ ("paddw " #rd ", " #rs ", " #rt )
96
97 #define pextlw(rs, rt, rd) \
98 __asm__ __volatile__ ("pextlw " #rd ", " #rs ", " #rt )
99
100 #define pextuw(rs, rt, rd) \
101 __asm__ __volatile__ ("pextuw " #rd ", " #rs ", " #rt )
102
103 #define pextlh(rs, rt, rd) \
104 __asm__ __volatile__ ("pextlh " #rd ", " #rs ", " #rt )
105
106 #define pextuh(rs, rt, rd) \
107 __asm__ __volatile__ ("pextuh " #rd ", " #rs ", " #rt )
108
109 #define psubw(rs, rt, rd) \
110 __asm__ __volatile__ ("psubw " #rd ", " #rs ", " #rt )
111
112 #define psraw(rt, sa, rd) \
113 __asm__ __volatile__ ("psraw " #rd ", " #rt ", %0" : : "i"(sa) )
114
115 #define ppach(rs, rt, rd) \
116 __asm__ __volatile__ ("ppach " #rd ", " #rs ", " #rt )
117
118 #define ppacb(rs, rt, rd) \
119 __asm__ __volatile__ ("ppacb " #rd ", " #rs ", " #rt )
120
121 #define prevh(rt, rd) \
122 __asm__ __volatile__ ("prevh " #rd ", " #rt )
123
124 #define pmulth(rs, rt, rd) \
125 __asm__ __volatile__ ("pmulth " #rd ", " #rs ", " #rt )
126
127 #define pmaxh(rs, rt, rd) \
128 __asm__ __volatile__ ("pmaxh " #rd ", " #rs ", " #rt )
129
130 #define pminh(rs, rt, rd) \
131 __asm__ __volatile__ ("pminh " #rd ", " #rs ", " #rt )
132
133 #define pinteh(rs, rt, rd) \
134 __asm__ __volatile__ ("pinteh " #rd ", " #rs ", " #rt )
135
136 #define paddh(rs, rt, rd) \
137 __asm__ __volatile__ ("paddh " #rd ", " #rs ", " #rt )
138
139 #define psubh(rs, rt, rd) \
140 __asm__ __volatile__ ("psubh " #rd ", " #rs ", " #rt )
141
142 #define psrah(rt, sa, rd) \
143 __asm__ __volatile__ ("psrah " #rd ", " #rt ", %0" : : "i"(sa) )
144
145 #define pmfhl_uw(rd) \
146 __asm__ __volatile__ ("pmfhl.uw " #rd)
147
148 #define pextlb(rs, rt, rd) \
149 __asm__ __volatile__ ("pextlb " #rd ", " #rs ", " #rt )
150
151 #endif
152