~ubuntu-branches/ubuntu/trusty/libdv/trusty

« back to all changes in this revision

Viewing changes to libdv/transpose_x86_64.S

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Kobras
  • Date: 2006-09-26 14:22:15 UTC
  • mfrom: (1.3.1 upstream) (3.1.4 edgy)
  • Revision ID: james.westby@ubuntu.com-20060926142215-q2arp4stpw6lrb5p
Tags: 1.0.0-1
* New upstream version.
* Removed patches:
  + [01_changelog_update_CVS]
  + [10_amd64_linkage_fix_CVS]
  + [10_inline_fixes_CVS]
  + [20_no_exec_stack_CVS]
  + [30_unload_memleak_fix_CVS]
  + [40_playdv_exit_fix_CVS]
  + [50_gcc41_asm_constraint_fixes_CVS]
    All of the above are part of the new upstream version.
* debian/control: In Build-Depends, remove alternative dependencies on
  obsolete SDL and X packages.
* debian/control: Complies with version 3.7.2 of Debian policy.
* debian/libdv4.README.Debian: Document lack of position-independent code
  in i386 version of libdv's shared library as mandated by recent versions
  of Debian policy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.section .note.GNU-stack, "", @progbits
 
2
 
 
3
.text
 
4
 
 
5
.global _dv_transpose_mmx_x86_64
 
6
.hidden _dv_transpose_mmx_x86_64
 
7
.type   _dv_transpose_mmx_x86_64,@function
 
8
_dv_transpose_mmx_x86_64:
 
9
        
 
10
/* extern void _dv_transpose_mmx_x86_64(short * dst); */
 
11
        
 
12
        /* argument dst=rdi */
 
13
        
 
14
        push    %r12
 
15
        push    %rbx
 
16
        push    %rcx
 
17
        push    %rdx
 
18
 
 
19
        mov     %rdi, %r11      # dst
 
20
 
 
21
        mov     $8, %rbx        # rbx is x_size
 
22
        mov     %rbx, %rcx
 
23
        mov     %r11, %r12      # pointer to the matrix
 
24
 
 
25
        sal     $2, %rcx
 
26
        mov     %rbx, %rax
 
27
        add     %rbx, %rcx
 
28
        sub     $4, %rax        # rax is the inner loop variable
 
29
 
 
30
        add     %rbx, %rcx      # rcx is 6*row size
 
31
        mov     %rax, %rdx      # rdx is the outer loop variable
 
32
 
 
33
do_4x4_block_where_x_equals_y: 
 
34
 
 
35
        movq    (%r11), %mm0            # m03:m02|m01:m00 - first line
 
36
 
 
37
        movq    (%r11,%rbx,4), %mm2     # m23:m22|m21:m20 - third line
 
38
        movq    %mm0, %mm6              # copy first line
 
39
 
 
40
        punpcklwd (%r11,%rbx,2), %mm0
 
41
        # m11:m01|m10:m00 - interleave first and second lines
 
42
        movq    %mm2, %mm7              # copy third line
 
43
 
 
44
        punpcklwd (%r11,%rcx,), %mm2
 
45
        # m31:m21|m30:m20 - interleave third and fourth lines
 
46
        movq    %mm0, %mm4              # copy first intermediate result
 
47
 
 
48
        movq    (%r11,%rbx,2), %mm1     # m13:m12|m11:m10 - second line
 
49
        punpckldq %mm2, %mm0
 
50
        # m30:m20|m10:m00 - interleave to produce result 1
 
51
 
 
52
        movq    (%r11,%rcx,), %mm3      # m33:m32|m31:m30 - fourth line
 
53
        punpckhdq %mm2, %mm4
 
54
        # m31:m21|m11:m01 - interleave to produce result 2
 
55
 
 
56
        movq    %mm0, (%r11)            # write result 1
 
57
        punpckhwd %mm1, %mm6
 
58
        # m13:m03|m12:m02 - interleave first and second lines
 
59
 
 
60
        movq    %mm4, (%r11,%rbx,2)     # write result 2
 
61
        punpckhwd %mm3, %mm7
 
62
        # m33:m23|m32:m22 - interleave third and fourth lines
 
63
 
 
64
        movq    %mm6, %mm5              # copy first intermediate result
 
65
        punpckldq %mm7, %mm6
 
66
        # m32:m22|m12:m02 - interleave to produce result 3
 
67
 
 
68
        lea     (%r12,%rbx,8), %r12
 
69
        # reload r12 to point to a 4x4 set 4 rows down
 
70
        punpckhdq %mm7, %mm5
 
71
        # m33:m23|m13:m03 - interleave to produce result 4
 
72
 
 
73
        movq    %mm6, (%r11,%rbx,4)     # write result 3
 
74
 
 
75
        movq    %mm5, (%r11,%rcx,)      # write result 4
 
76
 
 
77
        cmp     $0, %rdx
 
78
        # check to see if the number of rows left is zero
 
79
        je      all_done_ready_to_exit
 
80
        #last time through you are done and ready to exit
 
81
 
 
82
do_4x4_blocks_x_and_y_not_equal: 
 
83
 
 
84
# transpose the two mirror image 4x4 sets so that the writes 
 
85
# can be done without overwriting unused data 
 
86
 
 
87
        movq    8(%r11), %mm0           # m03:m02|m01:m00 - first line
 
88
 
 
89
        movq    8(%r11,%rbx,4), %mm2     # m23:m22|m21:m20 - third line
 
90
        movq    %mm0, %mm6              # copy first line
 
91
 
 
92
        punpcklwd 8(%r11,%rbx,2), %mm0
 
93
        # m11:m01|m10:m00 - interleave first and second lines
 
94
        movq    %mm2, %mm7              # copy third line
 
95
 
 
96
        punpcklwd 8(%r11,%rcx,), %mm2
 
97
        # m31:m21|m30:m20 - interleave third and fourth lines
 
98
        movq    %mm0, %mm4              # copy first intermediate result
 
99
# all references for second 4 x 4 block are referred by "n" instead of "m"
 
100
        movq    (%r12), %mm1            # n03:n02|n01:n00 - first line 
 
101
        punpckldq %mm2, %mm0
 
102
        # m30:m20|m10:m00 - interleave to produce first result
 
103
 
 
104
        movq    (%r12,%rbx,4), %mm3     # n23:n22|n21:n20 - third line
 
105
        punpckhdq %mm2, %mm4
 
106
        # m31:m21|m11:m01 - interleave to produce second result
 
107
 
 
108
        punpckhwd 8(%r11,%rbx,2), %mm6
 
109
        # m13:m03|m12:m02 - interleave first and second lines
 
110
        movq    %mm1, %mm2              # copy first line
 
111
 
 
112
        punpckhwd 8(%r11,%rcx,), %mm7
 
113
        # m33:m23|m32:m22 - interleave third and fourth lines
 
114
        movq    %mm6, %mm5              # copy first intermediate result
 
115
 
 
116
        movq    %mm0, (%r12)            # write result 1
 
117
        punpckhdq %mm7, %mm5
 
118
        # m33:m23|m13:m03 - produce third result
 
119
 
 
120
        punpcklwd (%r12,%rbx,2), %mm1
 
121
        # n11:n01|n10:n00 - interleave first and second lines
 
122
        movq    %mm3, %mm0              # copy third line
 
123
 
 
124
        punpckhwd (%r12,%rbx,2), %mm2
 
125
        # n13:n03|n12:n02 - interleave first and second lines
 
126
 
 
127
        movq    %mm4, (%r12,%rbx,2)     # write result 2 out
 
128
        punpckldq %mm7, %mm6
 
129
        # m32:m22|m12:m02 - produce fourth result
 
130
 
 
131
        punpcklwd (%r12,%rcx,), %mm3
 
132
        # n31:n21|n30:n20 - interleave third and fourth lines
 
133
        movq    %mm1, %mm4              # copy first intermediate result
 
134
 
 
135
        movq    %mm6, (%r12,%rbx,4)     # write result 3 out
 
136
        punpckldq %mm3, %mm1
 
137
        # n30:n20|n10:n00 - produce first result
 
138
 
 
139
        punpckhwd (%r12,%rcx,), %mm0
 
140
        # n33:n23|n32:n22 - interleave third and fourth lines
 
141
        movq    %mm2, %mm6              # copy second intermediate result
 
142
 
 
143
        movq    %mm5, (%r12,%rcx,)      # write result 4 out
 
144
        punpckhdq %mm3, %mm4
 
145
        # n31:n21|n11:n01- produce second result
 
146
 
 
147
        movq    %mm1, 8(%r11)
 
148
        # write result 5 out - (first result for other 4 x 4 block)
 
149
        punpckldq %mm0, %mm2
 
150
        # n32:n22|n12:n02- produce third result
 
151
 
 
152
        movq    %mm4, 8(%r11,%rbx,2)     # write result 6 out
 
153
        punpckhdq %mm0, %mm6
 
154
        # n33:n23|n13:n03 - produce fourth result
 
155
 
 
156
        movq    %mm2, 8(%r11,%rbx,4)     # write result 7 out
 
157
 
 
158
        movq    %mm6, 8(%r11,%rcx,)     # write result 8 out
 
159
 
 
160
        add     $8, %r11
 
161
        # increment r11 to point to next 4 x 4 block in same row
 
162
        lea     (%r12,%rbx,8), %r12
 
163
        # increment r12 to point to next 4 x 4 block below current one
 
164
 
 
165
        sub     $4, %rax                # decrement inner loop variable
 
166
        jnz     do_4x4_blocks_x_and_y_not_equal
 
167
        # rax points to start of the second row in block we just finished
 
168
 
 
169
        sal     %rdx
 
170
        lea     8(%r11,%rbx,8), %r11     # reload r11 to point four rows down
 
171
 
 
172
        sub     %rdx, %r11
 
173
        # subtract the number of bytes in last row 
 
174
        # now we point to spot where row = col 
 
175
        sub     $8, %rdx                # sub 4 from row number
 
176
 
 
177
        sar     %rdx
 
178
        mov     %r11, %r12
 
179
 
 
180
        mov     %rdx, %rax
 
181
        # reset x_size to outer loop variable to start new row
 
182
        
 
183
        jmp     do_4x4_block_where_x_equals_y
 
184
 
 
185
all_done_ready_to_exit:
 
186
        
 
187
        pop     %rdx
 
188
        pop     %rcx
 
189
        pop     %rbx
 
190
        pop     %r12
 
191
 
 
192
        ret     $0