1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
|
--- src/lib/asm_blend.S
+++ src/lib/asm_blend.S
@@ -85,21 +85,10 @@
.type PT_(imlib_mmx_reshade_copy_rgba_to_rgba,@function)
.globl PR_(imlib_mmx_reshade_copy_rgb_to_rgba)
.type PT_(imlib_mmx_reshade_copy_rgb_to_rgba,@function)
-
-/*\ Some useful masks \*/
-m0X000000: .byte 0, 0, 0, 0, 0, 0, 255, 0
-m10000000: .byte 0, 0, 0, 0, 0, 0, 0, 1
-m00XXXXXX: .byte 255, 255, 255, 255, 255, 255, 0, 0
-mVX000000: .byte 0, 0, 0, 0, 0, 0, 255, 127
-mV0000000: .byte 0, 0, 0, 0, 0, 0, 0, 128
-m0XXX0XXX: .byte 255, 255, 255, 0, 255, 255, 255, 0
-mX000X000: .byte 0, 0, 0, 255, 0, 0, 0, 255
-m10001000: .byte 0, 0, 0, 1, 0, 0, 0, 1
-m000V0V0V: .byte 127, 0, 127, 0, 127, 0, 0, 0
-mI0000000: .byte 0, 0, 0, 0, 0, 0, 0, 64
-m0VVV0VVV: .byte 127, 127, 127, 0, 127, 127, 127, 0
-c1: .word 0x1, 0x1, 0x1, 0x1
+#include "asm_loadimmq.S"
+
+
/*\ MMX register use:
|*| %mm1 = Source value
|*| %mm2 = Destination value
@@ -162,7 +151,8 @@ PR_(imlib_mmx_blend_rgba_to_rgb):
ENTER
pxor %mm4, %mm4
- movq c1, %mm5
+ LOAD_IMMQ(c1, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
LOOP_START
1:
@@ -218,9 +208,10 @@ PR_(imlib_mmx_blend_rgba_to_rgba):
ENTER
pxor %mm4, %mm4
- movq m0X000000, %mm5
- movq m00XXXXXX, %mm6
- movq c1, %mm7
+ LOAD_IMMQ(m0X000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ LOAD_IMMQ(c1, %mm7)
+ CLEANUP_IMMQ_LOADS(3)
LOOP_START
1:
@@ -272,8 +263,9 @@ SIZE(imlib_mmx_blend_rgba_to_rgba)
PR_(imlib_mmx_copy_rgba_to_rgb):
ENTER
- movq m0XXX0XXX, %mm5
- movq mX000X000, %mm6
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ LOAD_IMMQ(mX000X000, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
/*\ Two at a time: last item is at %ecx = 0 \*/
subl $4, %esi
@@ -342,7 +334,8 @@ SIZE(imlib_mmx_copy_rgba_to_rgba)
PR_(imlib_mmx_copy_rgb_to_rgba):
ENTER
- movq mX000X000, %mm5
+ LOAD_IMMQ(mX000X000, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -415,8 +408,9 @@ PR_(imlib_mmx_add_blend_rgba_to_rgba):
ENTER
pxor %mm4, %mm4
- movq mVX000000, %mm5
- movq m00XXXXXX, %mm6
+ LOAD_IMMQ(mVX000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
LOOP_START
1:
@@ -463,7 +457,8 @@ SIZE(imlib_mmx_add_blend_rgba_to_rgba)
PR_(imlib_mmx_add_copy_rgba_to_rgb):
ENTER
- movq m0XXX0XXX, %mm5
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -533,7 +528,8 @@ SIZE(imlib_mmx_add_copy_rgba_to_rgba)
PR_(imlib_mmx_add_copy_rgb_to_rgba):
ENTER
- movq mX000X000, %mm5
+ LOAD_IMMQ(mX000X000, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -613,8 +609,9 @@ PR_(imlib_mmx_subtract_blend_rgba_to_rgb
ENTER
pxor %mm4, %mm4
- movq mV0000000, %mm5
- movq m00XXXXXX, %mm6
+ LOAD_IMMQ(mV0000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
LOOP_START
1:
@@ -661,7 +658,8 @@ SIZE(imlib_mmx_subtract_blend_rgba_to_rg
PR_(imlib_mmx_subtract_copy_rgba_to_rgb):
ENTER
- movq m0XXX0XXX, %mm5
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -699,7 +697,8 @@ SIZE(imlib_mmx_subtract_copy_rgba_to_rgb
PR_(imlib_mmx_subtract_copy_rgba_to_rgba):
ENTER
- movq mX000X000, %mm5
+ LOAD_IMMQ(mX000X000, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -741,7 +740,8 @@ SIZE(imlib_mmx_subtract_copy_rgba_to_rgb
PR_(imlib_mmx_subtract_copy_rgb_to_rgba):
ENTER
- movq mX000X000, %mm5
+ LOAD_IMMQ(mX000X000, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -780,7 +780,8 @@ PR_(imlib_mmx_reshade_blend_rgba_to_rgb)
ENTER
pxor %mm4, %mm4
- movq m000V0V0V, %mm6
+ LOAD_IMMQ(m000V0V0V, %mm6)
+ CLEANUP_IMMQ_LOADS(1)
LOOP_START
1:
@@ -823,9 +824,10 @@ PR_(imlib_mmx_reshade_blend_rgba_to_rgba
ENTER
pxor %mm4, %mm4
- movq mI0000000, %mm5
- movq m000V0V0V, %mm6
- movq m00XXXXXX, %mm7
+ LOAD_IMMQ(mI0000000, %mm5)
+ LOAD_IMMQ(m000V0V0V, %mm6)
+ LOAD_IMMQ(m00XXXXXX, %mm7)
+ CLEANUP_IMMQ_LOADS(3)
LOOP_START
1:
@@ -875,8 +877,9 @@ PR_(imlib_mmx_reshade_copy_rgba_to_rgb):
ENTER
pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ LOAD_IMMQ(m0VVV0VVV, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
subl $4, %esi
subl $4, %edi
@@ -939,8 +942,9 @@ PR_(imlib_mmx_reshade_copy_rgba_to_rgba)
ENTER
pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ LOAD_IMMQ(m0VVV0VVV, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
subl $4, %esi
subl $4, %edi
@@ -1004,9 +1008,10 @@ PR_(imlib_mmx_reshade_copy_rgb_to_rgba):
ENTER
pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
- movq mX000X000, %mm7
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ LOAD_IMMQ(m0VVV0VVV, %mm6)
+ LOAD_IMMQ(mX000X000, %mm7)
+ CLEANUP_IMMQ_LOADS(3)
subl $4, %esi
subl $4, %edi
--- src/lib/asm_blend_cmod.S
+++ src/lib/asm_blend_cmod.S
@@ -112,21 +112,9 @@
.type PT_(imlib_mmx_reshade_copy_rgba_to_rgba_cmod,@function)
.globl PR_(imlib_mmx_reshade_copy_rgb_to_rgba_cmod)
.type PT_(imlib_mmx_reshade_copy_rgb_to_rgba_cmod,@function)
-
-/*\ Some useful masks \*/
-m0X000000: .byte 0, 0, 0, 0, 0, 0, 255, 0
-m10000000: .byte 0, 0, 0, 0, 0, 0, 0, 1
-m00XXXXXX: .byte 255, 255, 255, 255, 255, 255, 0, 0
-mVX000000: .byte 0, 0, 0, 0, 0, 0, 255, 127
-mV0000000: .byte 0, 0, 0, 0, 0, 0, 0, 128
-m0XXX0XXX: .byte 255, 255, 255, 0, 255, 255, 255, 0
-mX000X000: .byte 0, 0, 0, 255, 0, 0, 0, 255
-m10001000: .byte 0, 0, 0, 1, 0, 0, 0, 1
-m000V0V0V: .byte 127, 0, 127, 0, 127, 0, 0, 0
-mI0000000: .byte 0, 0, 0, 0, 0, 0, 0, 64
-m0VVV0VVV: .byte 127, 127, 127, 0, 127, 127, 127, 0
-c1: .word 0x1, 0x1, 0x1, 0x1
+#include "asm_loadimmq.S"
+
/*\ MMX register use:
|*| %mm1 = Source value
|*| %mm2 = Destination value
@@ -364,7 +352,8 @@ PR_(imlib_mmx_blend_rgba_to_rgb_cmod):
ENTER
pxor %mm4, %mm4
- movq c1, %mm5
+ LOAD_IMMQ(c1, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
LOOP_START
1:
@@ -420,9 +409,10 @@ PR_(imlib_mmx_blend_rgba_to_rgba_cmod):
ENTER
pxor %mm4, %mm4
- movq m0X000000, %mm5
- movq m00XXXXXX, %mm6
- movq c1, %mm7
+ LOAD_IMMQ(m0X000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ LOAD_IMMQ(c1, %mm7)
+ CLEANUP_IMMQ_LOADS(3)
LOOP_START
1:
@@ -475,7 +465,8 @@ PR_(imlib_mmx_blend_rgb_to_rgb_cmod):
ENTER
pxor %mm4, %mm4
- movq c1, %mm5
+ LOAD_IMMQ(c1, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
/*\ Load alpha beforehand, as it's always amap(0xff) \*/
movzbl amap_ff, %eax
@@ -519,9 +510,10 @@ PR_(imlib_mmx_blend_rgb_to_rgba_cmod):
ENTER
pxor %mm4, %mm4
- movq m0X000000, %mm5
- movq m00XXXXXX, %mm6
- movq c1, %mm7
+ LOAD_IMMQ(m0X000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ LOAD_IMMQ(c1, %mm7)
+ CLEANUP_IMMQ_LOADS(3)
LOOP_START
1:
@@ -688,8 +680,9 @@ PR_(imlib_mmx_add_blend_rgba_to_rgba_cmo
ENTER
pxor %mm4, %mm4
- movq mVX000000, %mm5
- movq m00XXXXXX, %mm6
+ LOAD_IMMQ(mVX000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
LOOP_START
1:
@@ -778,8 +771,9 @@ PR_(imlib_mmx_add_blend_rgb_to_rgba_cmod
ENTER
pxor %mm4, %mm4
- movq mVX000000, %mm5
- movq m00XXXXXX, %mm6
+ LOAD_IMMQ(mVX000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
LOOP_START
1:
@@ -826,7 +820,8 @@ SIZE(imlib_mmx_add_blend_rgb_to_rgba_cmo
PR_(imlib_mmx_add_copy_rgba_to_rgb_cmod):
ENTER
- movq m0XXX0XXX, %mm5
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -970,8 +965,9 @@ PR_(imlib_mmx_subtract_blend_rgba_to_rgb
ENTER
pxor %mm4, %mm4
- movq mV0000000, %mm5
- movq m00XXXXXX, %mm6
+ LOAD_IMMQ(mV0000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
LOOP_START
1:
@@ -1060,8 +1056,9 @@ PR_(imlib_mmx_subtract_blend_rgb_to_rgba
ENTER
pxor %mm4, %mm4
- movq mV0000000, %mm5
- movq m00XXXXXX, %mm6
+ LOAD_IMMQ(mV0000000, %mm5)
+ LOAD_IMMQ(m00XXXXXX, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
LOOP_START
1:
@@ -1108,7 +1105,8 @@ SIZE(imlib_mmx_subtract_blend_rgb_to_rgb
PR_(imlib_mmx_subtract_copy_rgba_to_rgb_cmod):
ENTER
- movq m0XXX0XXX, %mm5
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -1146,7 +1144,8 @@ SIZE(imlib_mmx_subtract_copy_rgba_to_rgb
PR_(imlib_mmx_subtract_copy_rgba_to_rgba_cmod):
ENTER
- movq mX000X000, %mm5
+ LOAD_IMMQ(mX000X000, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -1188,7 +1187,8 @@ SIZE(imlib_mmx_subtract_copy_rgba_to_rgb
PR_(imlib_mmx_subtract_copy_rgb_to_rgba_cmod):
ENTER
- movq mX000X000, %mm5
+ LOAD_IMMQ(mX000X000, %mm5)
+ CLEANUP_IMMQ_LOADS(1)
subl $4, %esi
subl $4, %edi
@@ -1227,7 +1227,8 @@ PR_(imlib_mmx_reshade_blend_rgba_to_rgb_
ENTER
pxor %mm4, %mm4
- movq m000V0V0V, %mm6
+ LOAD_IMMQ(m000V0V0V, %mm6)
+ CLEANUP_IMMQ_LOADS(1)
LOOP_START
1:
@@ -1270,9 +1271,10 @@ PR_(imlib_mmx_reshade_blend_rgba_to_rgba
ENTER
pxor %mm4, %mm4
- movq mI0000000, %mm5
- movq m000V0V0V, %mm6
- movq m00XXXXXX, %mm7
+ LOAD_IMMQ(mI0000000, %mm5)
+ LOAD_IMMQ(m000V0V0V, %mm6)
+ LOAD_IMMQ(m00XXXXXX, %mm7)
+ CLEANUP_IMMQ_LOADS(3)
LOOP_START
1:
@@ -1322,7 +1324,8 @@ PR_(imlib_mmx_reshade_blend_rgb_to_rgb_c
ENTER
pxor %mm4, %mm4
- movq m000V0V0V, %mm6
+ LOAD_IMMQ(m000V0V0V, %mm6)
+ CLEANUP_IMMQ_LOADS(1)
/*\ Load alpha beforehand, as it's always amap(0xff) \*/
movzbl amap_ff, %eax
@@ -1365,9 +1368,10 @@ PR_(imlib_mmx_reshade_blend_rgb_to_rgba_
ENTER
pxor %mm4, %mm4
- movq mI0000000, %mm5
- movq m000V0V0V, %mm6
- movq m00XXXXXX, %mm7
+ LOAD_IMMQ(mI0000000, %mm5)
+ LOAD_IMMQ(m000V0V0V, %mm6)
+ LOAD_IMMQ(m00XXXXXX, %mm7)
+ CLEANUP_IMMQ_LOADS(3)
LOOP_START
1:
@@ -1417,8 +1421,9 @@ PR_(imlib_mmx_reshade_copy_rgba_to_rgb_c
ENTER
pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ LOAD_IMMQ(m0VVV0VVV, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
subl $4, %esi
subl $4, %edi
@@ -1481,8 +1486,9 @@ PR_(imlib_mmx_reshade_copy_rgba_to_rgba_
ENTER
pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ LOAD_IMMQ(m0VVV0VVV, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
subl $4, %esi
subl $4, %edi
@@ -1546,8 +1552,9 @@ PR_(imlib_mmx_reshade_copy_rgb_to_rgba_c
ENTER
pxor %mm4, %mm4
- movq m0XXX0XXX, %mm5
- movq m0VVV0VVV, %mm6
+ LOAD_IMMQ(m0XXX0XXX, %mm5)
+ LOAD_IMMQ(m0VVV0VVV, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
subl $4, %esi
subl $4, %edi
--- /dev/null
+++ src/lib/asm_loadimmq.S
@@ -0,0 +1,77 @@
+/*\ constants and macros for x86 assembly files. \*/
+
+
+/*\ Constants for asm_blend.S and asm_blend_cmod.S \*/
+/* m0X000000: .byte 0, 0, 0, 0, 0, 0, 255, 0 */
+#define m0X000000_H 0x00FF0000
+#define m0X000000_L 0x00000000
+/* m10000000: .byte 0, 0, 0, 0, 0, 0, 0, 1 */
+#define m10000000_H 0x01000000
+#define m10000000_L 0x00000000
+/* m00XXXXXX: .byte 255, 255, 255, 255, 255, 255, 0, 0 */
+#define m00XXXXXX_H 0x0000FFFF
+#define m00XXXXXX_L 0xFFFFFFFF
+/* mVX000000: .byte 0, 0, 0, 0, 0, 0, 255, 127 */
+#define mVX000000_H 0x7FFF0000
+#define mVX000000_L 0x00000000
+/* mV0000000: .byte 0, 0, 0, 0, 0, 0, 0, 128 */
+#define mV0000000_H 0x80000000
+#define mV0000000_L 0x00000000
+/* m0XXX0XXX: .byte 255, 255, 255, 0, 255, 255, 255, 0 */
+#define m0XXX0XXX_H 0x00FFFFFF
+#define m0XXX0XXX_L 0x00FFFFFF
+/* mX000X000: .byte 0, 0, 0, 255, 0, 0, 0, 255 */
+#define mX000X000_H 0xFF000000
+#define mX000X000_L 0xFF000000
+/* m10001000: .byte 0, 0, 0, 1, 0, 0, 0, 1 */
+#define m10001000_H 0x01000000
+#define m10001000_L 0x01000000
+/* m000V0V0V: .byte 127, 0, 127, 0, 127, 0, 0, 0 */
+#define m000V0V0V_H 0x0000007F
+#define m000V0V0V_L 0x007F007F
+/* mI0000000: .byte 0, 0, 0, 0, 0, 0, 0, 64 */
+#define mI0000000_H 0x40000000
+#define mI0000000_L 0x00000000
+/* m0VVV0VVV: .byte 127, 127, 127, 0, 127, 127, 127, 0 */
+#define m0VVV0VVV_H 0x007F7F7F
+#define m0VVV0VVV_L 0x007F7F7F
+/* c1: .word 0x1, 0x1, 0x1, 0x1 */
+#define c1_H 0x00010001
+#define c1_L 0x00010001
+
+
+/*\ Constants for asm_rgba.S \*/
+/* m_rb: .long 0x00f800f8, 0x00f800f8 */
+#define m_rb_H 0x00f800f8
+#define m_rb_L 0x00f800f8
+/* m_r: .long 0xf800f800, 0xf800f800 */
+#define m_r_H 0xf800f800
+#define m_r_L 0xf800f800
+/* m_g6: .long 0x0000fc00, 0x0000fc00 */
+#define m_g6_H 0x0000fc00
+#define m_g6_L 0x0000fc00
+/* m_g5: .long 0x0000f800, 0x0000f800 */
+#define m_g5_H 0x0000f800
+#define m_g5_L 0x0000f800
+/*\ Multiply constants to fake two shifts at once \*/
+/* mul_rgb565: .long 0x20000004, 0x20000004 */
+#define mul_rgb565_H 0x20000004
+#define mul_rgb565_L 0x20000004
+/* mul_bgr565: .long 0x00042000, 0x00042000 */
+#define mul_bgr565_H 0x00042000
+#define mul_bgr565_L 0x00042000
+/* mul_rgb555: .long 0x20000008, 0x20000008 */
+#define mul_rgb555_H 0x20000008
+#define mul_rgb555_L 0x20000008
+/* mul_bgr555: .long 0x00082000, 0x00082000 */
+#define mul_bgr555_H 0x00082000
+#define mul_bgr555_L 0x00082000
+
+
+/*\ Load an 8-byte constant to an mmx register \*/
+#define LOAD_IMMQ(mask, reg) \
+ pushl $mask##_H ;\
+ pushl $mask##_L ;\
+ movq (%esp), reg
+#define CLEANUP_IMMQ_LOADS(num_loaded) \
+ addl $ num_loaded * 8, %esp
--- src/lib/asm_rgba.S
+++ src/lib/asm_rgba.S
@@ -55,16 +55,7 @@
.globl PR_(imlib_get_cpuid)
.type PT_(imlib_get_cpuid,@function)
-/*\ Some useful masks \*/
-m_rb: .long 0x00f800f8, 0x00f800f8
-m_r: .long 0xf800f800, 0xf800f800
-m_g6: .long 0x0000fc00, 0x0000fc00
-m_g5: .long 0x0000f800, 0x0000f800
-/*\ Multiply constants to fake two shifts at once \*/
-mul_rgb565: .long 0x20000004, 0x20000004
-mul_bgr565: .long 0x00042000, 0x00042000
-mul_rgb555: .long 0x20000008, 0x20000008
-mul_bgr555: .long 0x00082000, 0x00082000
+#include "asm_loadimmq.S"
/*\ Common code \*/
/*\ Save registers, load common parameters \*/
@@ -114,18 +105,21 @@ mul_bgr555: .long 0x00082000, 0x00082000
PR_(imlib_mmx_bgr565_fast):
- movq mul_bgr565, %mm7 /*\ This constant is the only difference \*/
+ LOAD_IMMQ(mul_bgr565, %mm7) /*\ This constant is the only difference \*/
+ CLEANUP_IMMQ_LOADS(1)
jmp .rgb565_fast_entry
SIZE(imlib_mmx_bgr565_fast)
PR_(imlib_mmx_rgb565_fast):
- movq mul_rgb565, %mm7
+ LOAD_IMMQ(mul_rgb565, %mm7)
+ CLEANUP_IMMQ_LOADS(1)
.rgb565_fast_entry:
ENTER
- movq m_rb, %mm5
- movq m_g6, %mm6
+ LOAD_IMMQ(m_rb, %mm5)
+ LOAD_IMMQ(m_g6, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
LOOP_START
@@ -193,18 +187,21 @@ SIZE(imlib_mmx_rgb565_fast)
PR_(imlib_mmx_bgr555_fast):
- movq mul_bgr555, %mm7 /*\ This constant is the only difference \*/
+ LOAD_IMMQ(mul_bgr555, %mm7) /*\ This constant is the only difference \*/
+ CLEANUP_IMMQ_LOADS(1)
jmp .rgb555_fast_entry
SIZE(imlib_mmx_bgr555_fast)
PR_(imlib_mmx_rgb555_fast):
- movq mul_rgb555, %mm7
+ LOAD_IMMQ(mul_rgb555, %mm7)
+ CLEANUP_IMMQ_LOADS(1)
.rgb555_fast_entry:
ENTER
- movq m_rb, %mm5
- movq m_g5, %mm6
+ LOAD_IMMQ(m_rb, %mm5)
+ LOAD_IMMQ(m_g5, %mm6)
+ CLEANUP_IMMQ_LOADS(2)
LOOP_START
|