5
# Intel x86-MMX assembly code translator to MIPS Loongson2{E,F}
9
# author: pancake <youterm.com>
26
$regs{"ecx"} = "t3"; # counter
36
for $a (keys(%regs)) {
38
eval ("\$str=~s/$a/$regs{$a}/gei;");
43
$str=~s/movd\s+\(%(.+)\)\s*,\s*%([^\s]+)/"ldc1 \$$1, \$$2"/ge;
44
#$str=~s/psrad\s+\$(.+)\s*,\s*%([^\s]+)/li \$t1, \$f18, \$t1psraw \$$2, \$$2, \$$1"/ge;
46
$str=~s/ret/jr \$ra\nnop/g;
47
$str=~s/movq\s+(\d+)\(%(.+)\)\s*,\s*%([^\s]+)/ldc1 \$$3, $1 (\$$2)/g;
48
$str=~s/movq\s+%\[(.+)\]\s*,\s*%([^\s]+)/ldc1 \$$2, 0($1)/g;
49
$str=~s/movq\s+%(.+)\s*,\s*%\[([^\s]+)\]/sdc1 \$$1, 0($2)/g;
50
$str=~s/movq\s+%(.+)\s*,\s*(\d+)\(%([^\s]+)\)/sdc1 \$$1, $2(\$$3)/g;
51
$str=~s/movq\s+%(.+)\s*,\s*%([^\s]+)/mov\.d \$$2, \$$1/g;
52
$str=~s/pmullw\s+%\[(.+)\]\s*,\s*%([^\s]+)/ldc1 \$f20, 0($1)\npmullh \$$2, \$$2, \$f20/g;
53
$str=~s/pmullw\s+%(.+)\s*,\s*%([^\s]+)/pmullh \$$2, \$$2, \$$1/g; ## IS THIS OK ?
54
$str=~s/psraw\s+\$(.+)\s*,\s*%([^\s]+)/li \$t2, $1\ndmtc1 \$t2, \$f18\npsrah \$$2, \$$2, \$f18/g;
55
$str=~s/psubw\s+%(.+)\s*,\s*%([^\s]+)/psubh \$$2, \$$2, \$$1/g;
56
$str=~s/paddw\s+%(.+)\s*,\s*%([^\s]+)/paddh \$$2, \$$2, \$$1/g;
57
$str=~s/movl\s+\$(\d+)\s*,\s*%([^\s]+)/li \$$2, $1/g;
58
$str=~s/psllw\s+\$(\d+)\s*,\s*%([^\s]+)/li \$t1, $1\ndmtc1 \$t1, \$f18\npsllh \$$2, \$$2, \$f18/g;
59
$str=~s/punpcklwd\s+%(.+)\s*,\s*%([^\s]+)/punpcklhw \$$2, \$$2, \$$1/g;
60
$str=~s/punpckhwd\s+%(.+)\s*,\s*%([^\s]+)/punpckhhw \$$2, \$$2, \$$1/g;
61
$str=~s/punpckldq\s+%(.+)\s*,\s*%([^\s]+)/punpcklwd \$$2, \$$2, \$$1/g;
62
$str=~s/punpckhdq\s+%(.+)\s*,\s*%([^\s]+)/punpckhwd \$$2, \$$2, \$$1/g;
63
$str=~s/packssdw\s+%(.+)\s*,\s*%([^\s]+)/packsswh \$$2, \$$2, \$$1/g;
64
$str=~s/packuswb\s+%(.+)\s*,\s*%([^\s]+)/packushb \$$2, \$$2, \$$1/g;
65
$str=~s/addl\s+\$(\d+), %([^\s]+)/addi \$$2, \$$2, $1/g;
66
$str=~s/subl\s+\$(\d+), %([^\s]+)/addi \$$2, \$$2, -$1/g;
67
$str=~s/[^\d]0\((.*)\)/$1/g;
71
# punpckldq %mm7, %mm1
72
# punpckhdq %mm7, %mm1
77
print "$str\n" if ($str);