18 byval svreg
as IRVREG
ptr _
21 dim as string label, aux, ostr
26 ostr =
"cmp " + aux +
", 0"
45 byval dvreg
as IRVREG
ptr, _
46 byval svreg
as IRVREG
ptr _
49 dim as string dst, src
53 if( typeIsSigned( dvreg->dtype ) = 0)
then exit sub
55 if( svreg->regFamily = IR_REG_SSE )
then
57 sdsize = typeGetSize( svreg->dtype )
58 outp "sub esp" + COMMA +
str( sdsize )
63 outp "movlpd qword ptr [esp]" + COMMA + src
64 outp "fld qword ptr [esp]"
66 outp "movss dword ptr [esp]" + COMMA + src
67 outp "fld dword ptr [esp]"
70 outp "add esp" + COMMA +
str( sdsize )
84 byval dvreg
as IRVREG
ptr, _
85 byval svreg
as IRVREG
ptr _
88 dim as string dst, src
89 dim as integer sdsize, ddsize
91 dim as string aux, aux8, aux16
92 dim as integer isfree, reg, wasreg
96 sdsize = typeGetSize( svreg->dtype )
97 ddsize = typeGetSize( dvreg->dtype )
100 if( (ddsize = 4)
and (typeIsSigned( dvreg->dtype ) = 0) )
then
102 if( svreg->typ <> IR_VREGTYPE_REG )
then
104 elseif( svreg->regFamily = IR_REG_SSE )
then
105 if( sdsize > 4 )
then
106 outp "movlpd qword ptr [esp], " + src
107 outp "fld qword ptr [esp]"
109 outp "movss dword ptr [esp], " + src
110 outp "fld dword ptr [esp]"
113 outp "fistp qword ptr [esp]"
120 if( ddsize = 2 )
and ( typeIsSigned( dvreg->dtype ) )
then
122 if( svreg->typ <> IR_VREGTYPE_REG )
then
124 elseif( svreg->regFamily = IR_REG_SSE )
then
125 if( sdsize > 4 )
then
126 outp "movlpd qword ptr [esp], " + src
127 outp "fld qword ptr [esp]"
129 outp "movss dword ptr [esp], " + src
130 outp "fld dword ptr [esp]"
138 if( (dvreg->typ = IR_VREGTYPE_REG)
and (ddsize = 4) )
then
151 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
152 if( isfree = FALSE )
then
157 if( svreg->regFamily = IR_REG_FPU_STACK )
then
159 outp "fistp dword ptr [esp]"
160 outp "mov " + aux + COMMA +
"dword ptr [esp]"
163 if( sdsize > 4 )
then
164 outp "cvtsd2si " + aux + COMMA + src
166 outp "cvtss2si " + aux + COMMA + src
170 if( wasreg = FALSE )
Then
171 if( ddsize = 1 )
then
173 outp "mov " + dst + COMMA + aux8
174 elseif( ddsize = 2 )
then
176 outp "mov " + dst + COMMA + aux16
178 outp "mov " + dst + COMMA + aux
180 if( isfree = FALSE )
then
194 byval dvreg
as IRVREG
ptr, _
195 byval svreg
as IRVREG
ptr _
198 dim as string dst, src, aux
204 if( (svreg->typ = IR_VREGTYPE_REG)
or (svreg->typ = IR_VREGTYPE_IMM) )
then
207 if( typeIsSigned( svreg->dtype ) )
then
209 hPrepOperand64( svreg, src, aux )
214 ostr =
"fild " + dtypeTB(svreg->dtype).mname +
" [esp]"
221 hPrepOperand64( svreg, src, aux )
224 outp "fild qword ptr [esp]"
233 if( typeIsSigned( svreg->dtype ) )
then
257 byval dvreg
as IRVREG
ptr, _
258 byval svreg
as IRVREG
ptr _
261 dim as string dst, src, aux
262 dim as integer ddsize, sdsize, reg, isfree
268 ddsize = typeGetSize( dvreg->dtype )
269 sdsize = typeGetSize( svreg->dtype )
272 if( (typeIsSigned( svreg->dtype ) = 0)
and (sdsize = 4) )
then
275 outp "fild qword ptr [esp]"
281 if( (svreg->typ <> IR_VREGTYPE_IMM)
and (sdsize = 4) )
then
291 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
292 if( isfree = FALSE )
then
297 if( svreg->typ = IR_VREGTYPE_IMM )
then
298 outp "mov " + aux + COMMA + src
300 if( typeIsSigned( svreg->dtype ) )
then
305 outp ostr + aux + COMMA + src
309 if( ddsize > 4 )
then
310 outp "cvtsi2sd xmm7" + COMMA + aux
311 outp "movlpd " + dst + COMMA +
"xmm7"
313 outp "cvtsi2ss xmm7" + COMMA + aux
314 outp "movss " + dst + COMMA +
"xmm7"
317 if( isfree = FALSE )
then
325 byval dvreg
as IRVREG
ptr, _
326 byval svreg
as IRVREG
ptr _
329 dim as string dst, src
330 dim as integer ddsize
335 ddsize = typeGetSize( dvreg->dtype )
337 if( ( svreg->vector = 2 )
and ( ddsize > 4 ) )
then
338 outp "movupd " + dst + COMMA + src
342 if( svreg->vector = 2 )
then
343 outp "movlps " + dst + COMMA + src
344 elseif( svreg->vector = 3 )
then
345 outp "movhlps xmm7" + COMMA + src
346 outp "movlps " + dst + COMMA + src
348 outp "movss " + dst + COMMA +
"xmm7"
349 elseif( svreg->vector = 4 )
then
350 outp "movups " + dst + COMMA + src
359 byval dvreg
as IRVREG
ptr, _
360 byval svreg
as IRVREG
ptr _
363 dim as string dst, src
364 dim as integer ddsize, sdsize, src_vec
370 ddsize = typeGetSize( dvreg->dtype )
371 sdsize = typeGetSize( svreg->dtype )
373 src_vec = ( svreg->vector > 0 )
375 if( svreg->typ = IR_VREGTYPE_REG )
then
377 if( svreg->regFamily = IR_REG_FPU_STACK )
then
387 if( ddsize > 4 )
then
388 if( sdsize <= 4 )
then
390 outp "cvtss2sd " + src + COMMA + src
393 outp "movlpd " + dst + COMMA + src
397 if( sdsize > 4 )
then
398 outp "cvtsd2ss " + src + COMMA + src
400 outp "movss " + dst + COMMA + src
404 if( sdsize = ddsize )
then
408 if( ddsize > 4 )
then
409 outp "movupd xmm7" + COMMA + src
410 outp "movupd " + dst + COMMA +
"xmm7"
412 if( svreg->vector = 2 )
then
413 outp "movlps xmm7" + COMMA + src
414 outp "movlps " + dst + COMMA +
"xmm7"
415 elseif( svreg->vector = 3 )
then
416 outp "movups xmm7" + COMMA + src
417 outp "movlps " + dst + COMMA +
"xmm7"
418 outp "unpckhps xmm7, xmm7"
420 outp "movss " + dst + COMMA +
"xmm7"
421 elseif( svreg->vector = 4 )
then
422 outp "movups xmm7" + COMMA + src
423 outp "movups " + dst + COMMA +
"xmm7"
429 if( ddsize > 4 )
then
430 outp "movlpd xmm7" + COMMA + src
431 outp "movlpd " + dst + COMMA +
"xmm7"
433 outp "movss xmm7" + COMMA + src
434 outp "movss " + dst + COMMA +
"xmm7"
438 if( sdsize > 4 )
then
441 outp "cvtpd2ps xmm7" + COMMA + src
442 outp "movlps " + dst + COMMA +
"xmm7"
444 outp "cvtsd2ss xmm7" + COMMA + src
445 outp "movss " + dst + COMMA +
"xmm7"
450 outp "cvtps2pd xmm7" + COMMA + src
451 outp "movupd " + dst + COMMA +
"xmm7"
453 outp "cvtss2sd xmm7" + COMMA + src
454 outp "movlpd " + dst + COMMA +
"xmm7"
466 byval dvreg
as IRVREG
ptr, _
467 byval svreg
as IRVREG
ptr _
470 dim as string dst, src, aux
472 dim as integer ddsize, sdsize
477 sdsize = typeGetSize( svreg->dtype )
479 if( svreg->regFamily = IR_REG_SSE )
then
481 if( svreg->typ = IR_VREGTYPE_REG )
then
483 if( sdsize > 4 )
then
484 outp "movlpd qword ptr [esp]" + COMMA + src
485 outp "fld qword ptr [esp]"
487 outp "movss dword ptr [esp]" + COMMA + src
488 outp "fld dword ptr [esp]"
496 hPrepOperand64( dvreg, dst, aux )
500 if( typeIsSigned( dvreg->dtype )
orelse (dvreg->dtype = FB_DATATYPE_ULONGINT) )
then
504 ostr =
"fistp " + dtypeTB(dvreg->dtype).mname +
" [esp]"
511 outp "push 0x4f800000"
512 outp "fdiv dword ptr [esp]"
513 outp "fistp dword ptr [esp]"
515 outp "fild dword ptr [esp]"
516 outp "push 0x4f800000"
517 outp "fmul dword ptr [esp]"
519 outp "fistp dword ptr [esp]"
533 byval dvreg
as IRVREG
ptr, _
534 byval svreg
as IRVREG
ptr _
537 dim as string dst, src, suffix
538 dim as string aux, aux8_16
539 dim as integer sdsize, ddsize
540 dim as integer isFree, reg, wasReg
542 dim as FBSYMBOL
ptr sym
543 dim as IRVREG
ptr tempVreg
548 sdsize = typeGetSize( svreg->dtype )
549 ddsize = typeGetSize( dvreg->dtype )
552 if( ( typeIsSigned( dvreg->dtype ) = FALSE )
and ( ddsize = 4 ) )
then
554 if( svreg->typ <> IR_VREGTYPE_REG )
then
556 elseif( svreg->regFamily = IR_REG_SSE )
then
557 if( sdsize > 4 )
then
558 outp "movlpd qword ptr [esp]" + COMMA + src
559 outp "fld qword ptr [esp]"
561 outp "movss dword ptr [esp]" + COMMA + src
562 outp "fld dword ptr [esp]"
565 outp "fistp qword ptr [esp]"
571 if( dvreg->typ = IR_VREGTYPE_REG )
Then
575 if( ddsize < 4 )
then
576 dst = *
hGetRegName( FB_DATATYPE_INTEGER, dvreg->reg )
590 isFree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
591 if( isFree = FALSE )
then
596 if( svreg->regFamily = IR_REG_FPU_STACK )
then
598 if( ddsize = 2 )
then
599 outp "fistp word ptr [esp]"
601 outp "fistp dword ptr [esp]"
605 suffix =
chr(
iif( sdsize > 4 , 100, 115 ) )
606 if( typeIsSigned( dvreg->dtype )
and ( ddsize = 2 ) )
then
607 if( svreg->typ <> IR_VREGTYPE_REG )
then
608 if( sdsize > 4 )
then
609 outp "movlpd xmm7" + COMMA + src
611 outp "movss xmm7" + COMMA + src
615 outp "cvtp" + suffix +
"2dq xmm7" + COMMA + src
616 outp "packssdw xmm7, xmm7"
617 outp "movd " + aux + COMMA +
"xmm7"
621 outp "cvts" + suffix +
"2si " + aux + COMMA + src
625 if( wasReg = FALSE )
then
626 if( ddsize = 4 )
then
627 outp "mov " + dst + COMMA + aux
629 outp "mov " + dst + COMMA + aux8_16
631 if( isFree = FALSE )
then
642 byval dvreg
as IRVREG
ptr, _
643 byval svreg
as IRVREG
ptr _
646 dim as string dst, src, aux
648 dim as integer ddsize
653 if( (svreg->typ = IR_VREGTYPE_REG)
or (svreg->typ = IR_VREGTYPE_IMM) )
then
656 if( typeIsSigned( svreg->dtype ) )
then
658 hPrepOperand64( svreg, src, aux )
663 ostr =
"fild " + dtypeTB(svreg->dtype).mname +
" [esp]"
671 hPrepOperand64( svreg, src, aux )
674 outp "fild qword ptr [esp]"
684 if( typeIsSigned( svreg->dtype ) )
then
697 ddsize = typeGetSize( dvreg->dtype )
699 outp "sub esp" + COMMA +
str( ddsize )
700 if( ddsize > 4 )
then
701 outp "fstp qword ptr [esp]"
702 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
704 outp "fstp dword ptr [esp]"
705 outp "movss " + dst + COMMA +
"dword ptr [esp]"
707 outp "add esp" + COMMA +
str( ddsize )
715 byval dvreg
as IRVREG
ptr, _
716 byval svreg
as IRVREG
ptr _
719 dim as string dst, src
720 dim as integer sdsize, ddsize
723 dim as integer isfree, reg
724 dim as FBSYMBOL
ptr sym
725 dim as IRVREG
ptr tempVreg
730 sdsize = typeGetSize( svreg->dtype )
731 ddsize = typeGetSize( dvreg->dtype )
734 if( (typeIsSigned( svreg->dtype ) = 0)
and (sdsize = 4) )
then
739 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
740 if( isfree = FALSE )
then
744 if( ddsize > 4 )
then
746 tempVreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, sym, symbGetOfs( sym ) )
750 tempVreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym, symbGetOfs( sym ) )
756 outp "mov " + aux + COMMA + src
757 outp "and " + aux + COMMA +
"0xFFFF"
758 outp "cvtsi2" + suffix + dst + COMMA + aux
760 outp "mov " + aux + COMMA + src
761 outp "shr " + aux + COMMA +
"16"
762 outp "cvtsi2" + suffix +
"xmm7" + COMMA + aux
765 outp "mul" + suffix +
"xmm7" + COMMA + src
766 outp "add" + suffix + dst + COMMA +
"xmm7"
767 if( isfree = FALSE )
then
773 if( (svreg->typ <> IR_VREGTYPE_IMM)
and (sdsize = 4) )
then
784 isfree =
hIsRegFree( FB_DATACLASS_INTEGER, reg )
785 if( isfree = FALSE )
then
789 if( (svreg->typ = IR_VREGTYPE_IMM)
or (sdsize = 4) )
then
790 outp "mov " + aux + COMMA + src
792 if( typeIsSigned( svreg->dtype ) )
then
793 outp "movsx " + aux + COMMA + src
795 outp "movzx " + aux + COMMA + src
800 if( ddsize > 4 )
then
801 outp "cvtsi2sd " + dst + COMMA + aux
803 outp "cvtsi2ss " + dst + COMMA + aux
805 if( isfree = FALSE )
then
809 if( dvreg->regFamily = IR_REG_SSE )
then exit sub
811 outp "sub esp" + COMMA +
str( ddsize )
812 if( ddsize > 4 )
then
813 outp "movlpd [esp]" + COMMA + dst
814 outp "fld qword ptr [esp]"
816 outp "movss [esp]" + COMMA + dst
817 outp "fld dword ptr [esp]"
819 outp "add esp" + COMMA +
str( ddsize )
828 byval dvreg
as IRVREG
ptr, _
829 byval svreg
as IRVREG
ptr _
832 dim as string src, dst
833 dim as integer sdsize, ddsize
838 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
843 sdsize = typeGetSize( svreg->dtype )
844 ddsize = typeGetSize( dvreg->dtype )
846 if( sdsize = ddsize )
then
847 if( svreg->vector )
then
849 if( ddsize > 4 )
then
850 outp "movupd " + dst + COMMA + src
852 if( svreg->vector = 2 )
then
853 outp "movlps " + dst + COMMA + src
855 outp "movups " + dst + COMMA + src
861 if( ddsize > 4 )
then
862 outp "movlpd " + dst + COMMA + src
864 outp "movss " + dst + COMMA + src
866 elseif( sdsize > 4 )
then
868 if( svreg->vector )
then
869 outp "cvtpd2ps " + dst + COMMA + src
871 outp "cvtsd2ss " + dst + COMMA + src
875 if( svreg->vector )
then
876 outp "cvtps2pd " + dst + COMMA + src
878 outp "cvtss2sd " + dst + COMMA + src
887 byval dvreg
as IRVREG
ptr, _
888 byval svreg
as IRVREG
ptr _
891 dim as string dst, src
892 dim as integer sdsize, ddsize
897 sdsize = typeGetSize( svreg->dtype )
898 ddsize = typeGetSize( dvreg->dtype )
900 if( sdsize > 4 )
and ( ddsize <= 4 )
then
902 if( svreg->vector )
then
903 outp "cvtpd2ps " + dst + COMMA + src
905 outp "cvtsd2ss " + dst + COMMA + src
907 elseif( ddsize > 4 )
and ( sdsize <= 4 )
then
909 if( svreg->vector )
then
910 outp "cvtps2pd " + dst + COMMA + src
912 outp "cvtss2sd " + dst + COMMA + src
915 outp "movaps " + dst + COMMA + src
926 byval dvreg
as IRVREG
ptr _
930 dim as integer ddsize
932 ddsize = typeGetSize( dvreg->dtype )
936 if( ddsize > 4 )
then
937 outp "unpcklpd " + dst + COMMA + dst
939 if( dvreg->vector = 2 )
then
940 outp "unpcklps " + dst + COMMA + dst
942 outp "shufps " + dst + COMMA + dst + COMMA +
"0x0"
953 byval dvreg
as IRVREG
ptr, _
954 byval svreg
as IRVREG
ptr _
957 dim as string dst, src, ostr
958 dim As integer sdsize, ddsize
963 sdsize = typeGetSize( svreg->dtype )
964 ddsize = typeGetSize( dvreg->dtype )
968 if( ddsize > 4 )
then
969 if( sdsize = 4 )
then
971 if( svreg->vector )
then
972 outp "cvtps2pd xmm7" + COMMA + src
974 outp "cvtss2sd xmm7" + COMMA + src
979 if( sdsize > 4 )
then
981 if( svreg->vector )
then
982 outp "cvtpd2ps xmm7" + COMMA + src
984 outp "cvtsd2ss xmm7" + COMMA + src
997 byval dvreg
as IRVREG
ptr, _
998 byval svreg
as IRVREG
ptr _
1001 dim as string dst, src, ostr
1002 dim As integer sdsize, ddsize, returnSize
1007 sdsize = typeGetSize( svreg->dtype )
1008 ddsize = typeGetSize( dvreg->dtype )
1012 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1015 elseif( svreg->regFamily = IR_REG_FPU_STACK )
then
1020 if( returnSize )
then
1021 outp "sub esp" + COMMA +
str( returnSize )
1023 if( returnSize = 8 )
then
1024 outp "fstp qword ptr [esp]"
1025 outp "movlpd " + ostr + COMMA +
"qword ptr [esp]"
1026 elseif( returnSize = 4)
then
1027 outp "fstp dword ptr [esp]"
1028 outp "movss " + ostr + COMMA +
"dword ptr [esp]"
1030 if( returnSize )
then
1031 outp "add esp" + COMMA +
str( returnSize )
1036 if( svreg->vector )
then
1039 if( svreg->typ <> IR_VREGTYPE_REG )
then
1041 if( sdsize > 4 )
then
1042 outp "movupd xmm7" + COMMA + src
1044 if( svreg->vector = 2 )
then
1045 outp "movlps xmm7" + COMMA + src
1047 outp "movups xmm7" + COMMA + src
1058 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
1059 if( ddsize > 4 )
then
1061 outp ostr +
"d " + dst + COMMA + src
1064 outp ostr +
"s " + dst + COMMA + src
1068 outp " implement 'add integer to float'"
1078 byval dvreg
as IRVREG
ptr, _
1079 byval svreg
as IRVREG
ptr _
1082 dim as string dst, src, ostr
1083 dim As integer sdsize, ddsize, returnSize
1088 sdsize = typeGetSize( svreg->dtype )
1089 ddsize = typeGetSize( dvreg->dtype )
1093 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1096 elseif( svreg->regFamily = IR_REG_FPU_STACK )
then
1101 if( returnSize )
then
1102 outp "sub esp" + COMMA +
str( returnSize )
1104 if( returnSize = 8 )
then
1105 outp "fstp qword ptr [esp]"
1106 outp "movlpd " + ostr + COMMA +
"qword ptr [esp]"
1107 elseif( returnSize = 4)
then
1108 outp "fstp dword ptr [esp]"
1109 outp "movss " + ostr + COMMA +
"dword ptr [esp]"
1111 if( returnSize )
then
1112 outp "add esp" + COMMA +
str( returnSize )
1116 if( svreg->vector )
then
1119 if( svreg->typ <> IR_VREGTYPE_REG )
then
1121 if( sdsize > 4 )
then
1122 outp "movupd xmm7" + COMMA + src
1124 if( svreg->vector = 2 )
then
1125 outp "movlps xmm7" + COMMA + src
1127 outp "movups xmm7" + COMMA + src
1138 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
1139 if( ddsize > 4 )
then
1141 outp ostr +
"d " + dst + COMMA + src
1144 outp ostr +
"s " + dst + COMMA + src
1148 outp " implement 'subtract integer from float'"
1157 byval dvreg
as IRVREG
ptr, _
1158 byval svreg
as IRVREG
ptr _
1161 dim as string dst, src, ostr
1162 dim As integer sdsize, ddsize, returnSize
1167 sdsize = typeGetSize( svreg->dtype )
1168 ddsize = typeGetSize( dvreg->dtype )
1172 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1175 elseif( svreg->regFamily = IR_REG_FPU_STACK )
then
1180 if( returnSize )
then
1181 outp "sub esp" + COMMA +
str( returnSize )
1183 if( returnSize = 8 )
then
1184 outp "fstp qword ptr [esp]"
1185 outp "movlpd " + ostr + COMMA +
"qword ptr [esp]"
1186 elseif( returnSize = 4)
then
1187 outp "fstp dword ptr [esp]"
1188 outp "movss " + ostr + COMMA +
"dword ptr [esp]"
1190 if( returnSize )
then
1191 outp "add esp" + COMMA +
str( returnSize )
1195 if( svreg->vector )
then
1198 if( svreg->typ <> IR_VREGTYPE_REG )
then
1200 if( sdsize > 4 )
then
1201 outp "movupd xmm7" + COMMA + src
1203 if( svreg->vector = 2 )
then
1204 outp "movlps xmm7" + COMMA + src
1206 outp "movups xmm7" + COMMA + src
1217 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
1218 if( ddsize > 4 )
then
1220 outp ostr +
"d " + dst + COMMA + src
1223 outp ostr +
"s " + dst + COMMA + src
1227 outp " implement 'multiply float by integer'"
1237 byval dvreg
as IRVREG
ptr, _
1238 byval svreg
as IRVREG
ptr _
1241 dim as string dst, src, ostr
1242 dim As integer sdsize, ddsize, returnSize
1247 sdsize = typeGetSize( svreg->dtype )
1248 ddsize = typeGetSize( dvreg->dtype )
1252 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1255 elseif( svreg->regFamily = IR_REG_FPU_STACK )
then
1260 if( returnSize )
then
1261 outp "sub esp" + COMMA +
str( returnSize )
1263 if( returnSize = 8 )
then
1264 outp "fstp qword ptr [esp]"
1265 outp "movlpd " + ostr + COMMA +
"qword ptr [esp]"
1266 elseif( returnSize = 4)
then
1267 outp "fstp dword ptr [esp]"
1268 outp "movss " + ostr + COMMA +
"dword ptr [esp]"
1270 if( returnSize )
then
1271 outp "add esp" + COMMA +
str( returnSize )
1275 if( svreg->vector )
then
1278 if( svreg->typ <> IR_VREGTYPE_REG )
then
1280 if( sdsize > 4 )
then
1281 outp "movupd xmm7" + COMMA + src
1283 if( svreg->vector = 2 )
then
1284 outp "movlps xmm7" + COMMA + src
1286 outp "movups xmm7" + COMMA + src
1297 if( typeGetClass( svreg->dtype ) = FB_DATACLASS_FPOINT )
then
1298 if( ddsize > 4 )
then
1300 outp ostr +
"d " + dst + COMMA + src
1303 outp ostr +
"s " + dst + COMMA + src
1307 outp " implement 'divide float by integer'"
1317 byval dvreg
as IRVREG
ptr, _
1318 byval svreg
as IRVREG
ptr _
1321 dim as string src, dst, ostr
1322 dim as integer sdsize, ddsize
1323 dim as integer adjustStack
1328 sdsize = typeGetSize( svreg->dtype )
1329 ddsize = typeGetSize( dvreg->dtype )
1332 if( dvreg->typ = IR_VREGTYPE_REG )
then
1335 if( ddsize > 4 )
then
1336 outp "movlpd qword ptr [esp]" + COMMA + dst
1337 outp "fld qword ptr [esp]"
1339 outp "movss dword ptr [esp]" + COMMA + dst
1340 outp "fld dword ptr [esp]"
1346 if( svreg->typ = IR_VREGTYPE_REG )
then
1347 if( adjustStack = FALSE )
then
1351 if( sdsize > 4 )
then
1352 outp "movlpd qword ptr [esp]" + COMMA + src
1353 outp "fld qword ptr [esp]"
1355 outp "movss dword ptr [esp]" + COMMA + src
1356 outp "fld dword ptr [esp]"
1363 if( ddsize > 4 )
then
1364 outp "fstp qword ptr [esp]"
1365 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
1367 outp "fstp dword ptr [esp]"
1368 outp "movss " + dst + COMMA +
"dword ptr [esp]"
1370 if( adjustStack )
then
1378 byval dvreg
as IRVREG
ptr, _
1379 byval svreg
as IRVREG
ptr _
1382 dim as string src, dst, ostr
1383 dim as integer sdsize, ddsize
1384 dim as integer adjustStack
1390 if( dvreg->typ = IR_VREGTYPE_REG )
then
1393 if (ddsize > 4)
then
1394 outp "movlpd qword ptr [esp]" + COMMA + dst
1395 outp "fld qword ptr [esp]"
1397 outp "movss dword ptr [esp]" + COMMA + dst
1398 outp "fld dword ptr [esp]"
1404 if( svreg->typ = IR_VREGTYPE_REG )
then
1405 if( adjustStack = FALSE )
then
1409 if (sdsize > 4)
then
1410 outp "movlpd qword ptr [esp]" + COMMA + src
1411 outp "fld qword ptr [esp]"
1413 outp "movss dword ptr [esp]" + COMMA + src
1414 outp "fld dword ptr [esp]"
1424 outp "fsub st(1), st(0)"
1432 if( ddsize > 4 )
then
1433 outp "fstp qword ptr [esp]"
1434 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
1436 outp "fstp dword ptr [esp]"
1437 outp "movss " + dst + COMMA +
"dword ptr [esp]"
1439 if( adjustStack )
then
1452 byval rvreg
as IRVREG
ptr, _
1453 byval label
as FBSYMBOL
ptr, _
1454 byval mnemonic
as zstring ptr, _
1455 byval mask
as zstring ptr, _
1456 byval dvreg
as IRVREG
ptr, _
1457 byval svreg
as IRVREG
ptr _
1460 dim as string rname, rname8, dst, src, ostr, lname
1461 dim as integer iseaxfree, isedxfree
1462 dim as integer sdsize, ddsize, returnSize
1464 ddsize = typeGetSize( dvreg->dtype )
1465 sdsize = typeGetSize( svreg->dtype )
1470 if( label = NULL )
then
1478 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1481 elseif( svreg->regFamily = IR_REG_FPU_STACK )
then
1486 if( returnSize )
then
1487 outp "sub esp" + COMMA +
str( returnSize )
1489 if( returnSize = 8 )
then
1490 outp "fstp qword ptr [esp]"
1491 outp "movlpd " + ostr + COMMA +
"qword ptr [esp]"
1492 elseif( returnSize = 4)
then
1493 outp "fstp dword ptr [esp]"
1494 outp "movss " + ostr + COMMA +
"dword ptr [esp]"
1496 if( returnSize )
then
1497 outp "add esp" + COMMA +
str( returnSize )
1503 if( ddsize > 4 )
then
1504 if( sdsize > 4 )
then
1505 outp "comisd " + dst + COMMA + src
1507 outp "cvtss2sd xmm7" + COMMA + src
1508 outp "comisd " + dst + COMMA +
"xmm7"
1511 if( sdsize > 4 )
then
1512 outp "cvtss2sd xmm7" + COMMA + dst
1513 outp "comisd xmm7" + COMMA + src
1515 outp "comiss " + dst + COMMA + src
1520 if( rvreg = NULL )
then
1521 ostr =
"j" + *mnemonic
1529 if( env.clopt.cputype >= FB_CPUTYPE_486 )
then
1530 rname8 = *
hGetRegName( FB_DATATYPE_BYTE, rvreg->reg )
1533 if( (rvreg->reg = EMIT_REG_ESI)
or (rvreg->reg = EMIT_REG_EDI) )
then
1535 isedxfree =
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX )
1536 if( isedxfree = FALSE )
then
1537 ostr =
"xchg edx, " + rname
1541 ostr =
"set" + *mnemonic + (TABCHAR +
"dl")
1544 if( isedxfree = FALSE )
then
1545 ostr =
"xchg edx, " + rname
1551 ostr =
"set" + *mnemonic +
" " + rname8
1556 ostr =
"shr " + rname +
", 1"
1559 ostr =
"sbb " + rname + COMMA + rname
1563 ostr =
"mov " + rname +
", -1"
1566 ostr =
"j" + *mnemonic
1569 ostr =
"xor " + rname + COMMA + rname
1583 byval rvreg
as IRVREG
ptr, _
1584 byval label
as FBSYMBOL
ptr, _
1585 byval dvreg
as IRVREG
ptr, _
1586 byval svreg
as IRVREG
ptr _
1589 hCMPF_SSE( rvreg, label,
"a",
"", dvreg, svreg )
1598 byval rvreg
as IRVREG
ptr, _
1599 byval label
as FBSYMBOL
ptr, _
1600 byval dvreg
as IRVREG
ptr, _
1601 byval svreg
as IRVREG
ptr _
1604 hCMPF_SSE( rvreg, label,
"b",
"", dvreg, svreg )
1612 byval rvreg
as IRVREG
ptr, _
1613 byval label
as FBSYMBOL
ptr, _
1614 byval dvreg
as IRVREG
ptr, _
1615 byval svreg
as IRVREG
ptr _
1618 hCMPF_SSE( rvreg, label,
"e",
"", dvreg, svreg )
1626 byval rvreg
as IRVREG
ptr, _
1627 byval label
as FBSYMBOL
ptr, _
1628 byval dvreg
as IRVREG
ptr, _
1629 byval svreg
as IRVREG
ptr _
1632 hCMPF_SSE( rvreg, label,
"ne",
"", dvreg, svreg )
1640 byval rvreg
as IRVREG
ptr, _
1641 byval label
as FBSYMBOL
ptr, _
1642 byval dvreg
as IRVREG
ptr, _
1643 byval svreg
as IRVREG
ptr _
1646 hCMPF_SSE( rvreg, label,
"be",
"", dvreg, svreg )
1654 byval rvreg
as IRVREG
ptr, _
1655 byval label
as FBSYMBOL
ptr, _
1656 byval dvreg
as IRVREG
ptr, _
1657 byval svreg
as IRVREG
ptr _
1660 hCMPF_SSE( rvreg, label,
"ae",
"", dvreg, svreg )
1669 byval dvreg
as IRVREG
ptr _
1672 dim as string dst, src
1673 dim as integer ddsize
1674 dim as FBSYMBOL
ptr sym
1675 dim as IRVREG
ptr tempVreg
1677 ddsize = typeGetSize( dvreg->dtype )
1680 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1681 outp "sub esp" + COMMA +
str( ddsize )
1682 if( ddsize > 4 )
then
1683 outp "fstp qword ptr [esp]"
1684 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
1686 outp "fstp dword ptr [esp]"
1687 outp "movlpd " + dst + COMMA +
"dword ptr [esp]"
1689 outp "add esp" + COMMA +
str( ddsize )
1692 if( ddsize > 4 )
then
1694 tempVreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, sym, symbGetOfs( sym ) )
1697 tempVreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym, symbGetOfs( sym ) )
1699 sym->var_.align = 16
1703 if( ddsize > 4 )
then
1704 outp "xorpd " + dst + COMMA + src
1706 outp "xorps " + dst + COMMA + src
1715 byval dvreg
as IRVREG
ptr _
1722 if( typeGetSize( dvreg->dtype ) > 4 )
then
1723 outp "movhlps xmm7" + COMMA + dst
1724 outp "addsd " + dst + COMMA +
"xmm7"
1726 if( dvreg->vector = 2 )
then
1727 outp "pshufd xmm7" + COMMA + dst + COMMA +
"0x01"
1728 outp "addss " + dst + COMMA +
"xmm7"
1729 elseif( dvreg->vector = 3 )
then
1730 outp "pshufd xmm7" + COMMA + dst + COMMA +
"0x01"
1731 outp "addss " + dst + COMMA +
"xmm7"
1732 outp "movhlps xmm7" + COMMA + dst
1733 outp "addss " + dst + COMMA +
"xmm7"
1734 elseif( dvreg->vector = 4 )
then
1735 outp "movhlps xmm7" + COMMA + dst
1736 outp "addps " + dst + COMMA +
"xmm7"
1737 outp "pshufd xmm7" + COMMA + dst + COMMA +
"0x01"
1738 outp "addss " + dst + COMMA +
"xmm7"
1748 byval dvreg
as IRVREG
ptr _
1751 dim as string dst, src
1752 dim as integer ddsize
1753 dim as FBSYMBOL
ptr sym
1754 dim as IRVREG
ptr tempVreg
1756 ddsize = typeGetSize( dvreg->dtype )
1759 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1760 outp "sub esp" + COMMA +
str( ddsize )
1761 if( ddsize > 4 )
then
1762 outp "fstp qword ptr [esp]"
1763 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
1765 outp "fstp dword ptr [esp]"
1766 outp "movss " + dst + COMMA +
"dword ptr [esp]"
1768 outp "add esp" + COMMA +
str( ddsize )
1771 if( ddsize > 4 )
then
1773 tempVreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, sym, symbGetOfs( sym ) )
1776 tempVreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym, symbGetOfs( sym ) )
1778 sym->var_.align = 16
1782 if( ddsize > 4 )
then
1783 outp "andpd " + dst + COMMA + src
1785 outp "andps " + dst + COMMA + src
1795 byval dvreg
as IRVREG
ptr _
1798 dim as string dst, src
1799 dim as FBSYMBOL
ptr sym
1800 dim as IRVREG
ptr tempVreg
1801 dim as integer ddsize
1803 ddsize = typeGetSize( dvreg->dtype )
1806 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1807 outp "sub esp" + COMMA +
str( ddsize )
1808 if( ddsize > 4 )
then
1809 outp "fstp qword ptr [esp]"
1810 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
1812 outp "fstp dword ptr [esp]"
1813 outp "movlpd " + dst + COMMA +
"dword ptr [esp]"
1815 outp "add esp" + COMMA +
str( ddsize )
1818 if( ddsize > 4 )
then
1819 outp "xorpd xmm7, xmm7"
1820 outp "cmpneqsd xmm7" + COMMA + dst
1823 sym->var_.align = 16
1824 tempVreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, sym, symbGetOfs( sym ) )
1826 outp "orpd " + dst + COMMA + src
1829 sym->var_.align = 16
1830 tempVreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, sym, symbGetOfs( sym ) )
1832 outp "andpd xmm7" + COMMA + src
1834 outp "andpd " + dst + COMMA +
"xmm7"
1836 outp "xorps xmm7, xmm7"
1837 outp "cmpneqss xmm7" + COMMA + dst
1840 sym->var_.align = 16
1841 tempVreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym, symbGetOfs( sym ) )
1843 outp "orps " + dst + COMMA + src
1846 sym->var_.align = 16
1847 tempVreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym, symbGetOfs( sym ) )
1849 outp "andps xmm7" + COMMA + src
1851 outp "andps " + dst + COMMA +
"xmm7"
1859 byval dvreg
as IRVREG
ptr, _
1860 byval iscos
as integer _
1863 dim as integer reg(2), isFree(2), stackSize, i, stackPointer
1864 dim as string dst, src, regName(2)
1865 dim as FBSYMBOL
ptr sym_invSignBitMask, sym_one, sym_piOverTwo, sym_twoOverPI
1866 dim as FBSYMBOL
ptr sym_sin_c0, sym_sin_c1, sym_sin_c2, sym_sin_c3
1867 dim as IRVREG
ptr vReg_invSignBitMask, vReg_one, vReg_piOverTwo, vReg_twoOverPI
1868 dim as IRVREG
ptr vReg_sin_c0, vReg_sin_c1, vReg_sin_c2, vReg_sin_c3
1874 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1879 reg(0) = EMIT_REG_ECX
1882 reg(1) = EMIT_REG_EAX
1884 if(
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_ECX ) )
then
1885 reg(0) = EMIT_REG_ECX
1887 if(
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX ) )
then
1888 reg(1) = EMIT_REG_EDX
1890 elseif(
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX ) )
then
1891 reg(1) = EMIT_REG_EAX
1894 elseif(
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EDX ) )
then
1895 reg(0) = EMIT_REG_EDX
1897 if(
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX ) )
then
1898 reg(1) = EMIT_REG_EAX
1902 if(
hIsRegFree( FB_DATACLASS_INTEGER, EMIT_REG_EAX ) )
then
1903 reg(1) = EMIT_REG_EAX
1909 if( reg(2) = INVALID )
then
1910 reg(2) = EMIT_REG_FP0
1916 stackSize += (4 * (isFree(0)
And 1))
1917 stackSize += (4 * (isFree(1)
And 1))
1918 stackSize += (4 * (isFree(2)
And 1))
1920 regName(0) = *
hGetRegName( FB_DATATYPE_INTEGER, reg(0) )
1921 regName(1) = *
hGetRegName( FB_DATATYPE_INTEGER, reg(1) )
1922 regName(2) = *
hGetRegName( FB_DATATYPE_SINGLE, reg(2) )
1925 sym_invSignBitMask->var_.align = 16
1926 vReg_invSignBitMask = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym_invSignBitMask, symbGetOfs( sym_invSignBitMask ) )
1929 sym_piOverTwo->var_.align = 16
1930 vReg_piOverTwo = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym_piOverTwo, symbGetOfs( sym_piOverTwo ) )
1933 sym_twoOverPI->var_.align = 16
1934 vReg_twoOverPI = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym_twoOverPI, symbGetOfs( sym_twoOverPI ) )
1937 sym_one->var_.align = 16
1938 vReg_one = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym_one, symbGetOfs( sym_one ) )
1941 sym_sin_c0->var_.align = 16
1942 vReg_sin_c0 = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym_sin_c0, symbGetOfs( sym_sin_c0 ) )
1945 sym_sin_c1->var_.align = 16
1946 vReg_sin_c1 = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym_sin_c1, symbGetOfs( sym_sin_c1 ) )
1949 sym_sin_c2->var_.align = 16
1950 vReg_sin_c2 = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym_sin_c2, symbGetOfs( sym_sin_c2 ) )
1953 sym_sin_c3->var_.align = 16
1954 vReg_sin_c3 = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym_sin_c3, symbGetOfs( sym_sin_c3 ) )
1958 outp "sub esp" + COMMA +
str( stackSize )
1960 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
1961 outp "fstp dword ptr [esp]"
1962 outp "movss " + dst + COMMA +
"dword ptr [esp]"
1967 if( isFree(i) = FALSE )
then
1969 outp "mov [esp+" +
str(stackPointer) +
"]" + COMMA + regName(i)
1971 outp "movss [esp+" +
str(stackPointer) +
"]" + COMMA + regName(i)
1977 if( iscos = FALSE )
then
1978 outp "movss [esp]" + COMMA + dst
1981 outp "mulss " + dst + COMMA + src
1983 outp "and dword ptr [esp], 0x80000000"
1986 hPrepOperand( vReg_invSignBitMask, src, FB_DATATYPE_XMMWORD )
1987 outp "andps " + dst + COMMA + src
1989 if( iscos = TRUE )
then
1991 outp "addss " + dst + COMMA + src
1994 outp "mulss " + dst + COMMA + src
1997 outp "cvttss2si " + regName(0) + COMMA + dst
2000 outp "movss xmm7" + COMMA + src
2001 outp "mov " + regName(1) + COMMA + regName(0)
2002 outp "cvtsi2ss " + regName(2) + COMMA + regName(0)
2003 outp "shl " + regName(1) + COMMA +
"30"
2004 outp "not " + regName(0)
2005 outp "and " + regName(1) + COMMA +
"0x80000000"
2006 outp "and " + regName(0) + COMMA +
"0x1"
2007 outp "subss " + dst + COMMA + regName(2)
2008 outp "dec " + regName(0)
2009 outp "minss " + dst + COMMA +
"xmm7"
2010 outp "movd " + regName(2) + COMMA + regName(0)
2011 outp "subss xmm7" + COMMA + dst
2012 outp "andps xmm7" + COMMA + regName(2)
2013 outp "andnps " + regName(2) + COMMA + dst
2014 outp "orps xmm7" + COMMA + regName(2)
2015 if( iscos = FALSE )
then
2016 outp "xor " + regName(1) + COMMA +
"[esp]"
2018 outp "movd " + regName(0) + COMMA +
"xmm7"
2020 outp "mulss xmm7, xmm7"
2022 outp "or " + regName(1) + COMMA + regName(0)
2024 outp "movss " + regName(2) + COMMA +
"xmm7"
2027 outp "mulss xmm7" + COMMA + src
2030 outp "addss xmm7" + COMMA + src
2031 outp "mulss xmm7" + COMMA + regName(2)
2033 outp "movd " + dst + COMMA + regName(1)
2036 outp "addss xmm7" + COMMA + src
2037 outp "mulss xmm7" + COMMA + regName(2)
2040 outp "addss xmm7" + COMMA + src
2041 outp "mulss " + dst + COMMA +
"xmm7"
2045 if( isFree(i) = FALSE )
then
2047 outp "mov " + regName(i) + COMMA +
"[esp+" +
str(stackPointer) +
"]"
2049 outp "movss " + regName(i) + COMMA +
"[esp+" +
str(stackPointer) +
"]"
2055 outp "add esp" + COMMA +
str( stackSize )
2063 byval dvreg
as IRVREG
ptr _
2067 dim as integer ddsize
2069 ddsize = typeGetSize( dvreg->dtype )
2071 if( ( ddsize = 4 )
and ( env.clopt.fpmode = FB_FPMODE_FAST ) )
then
2078 if( dvreg->regFamily = IR_REG_SSE )
then
2079 outp "sub esp" + COMMA +
str( ddsize )
2080 if( ddsize > 4 )
then
2081 outp "movlpd qword ptr [esp]" + COMMA + dst
2082 outp "fld qword ptr [esp]"
2084 outp "movss dword ptr [esp]" + COMMA + dst
2085 outp "fld dword ptr [esp]"
2091 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2092 outp "sub esp" + COMMA +
str( ddsize )
2095 if( ddsize > 4 )
then
2096 outp "fstp qword ptr [esp]"
2097 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2099 outp "fstp dword ptr [esp]"
2100 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2102 outp "add esp" + COMMA +
str( ddsize )
2110 byval dvreg
as IRVREG
ptr _
2114 dim as integer ddsize
2116 ddsize = typeGetSize( dvreg->dtype )
2119 if( dvreg->regFamily = IR_REG_SSE )
then
2120 outp "sub esp" + COMMA +
str( ddsize )
2121 if( ddsize > 4 )
then
2122 outp "movlpd qword ptr [esp]" + COMMA + dst
2123 outp "fld qword ptr [esp]"
2125 outp "movss dword ptr [esp]" + COMMA + dst
2126 outp "fld dword ptr [esp]"
2132 outp "fmul st(0), st(0)"
2138 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2139 outp "sub esp" + COMMA +
str( ddsize )
2142 if( ddsize > 4 )
then
2143 outp "fstp qword ptr [esp]"
2144 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2146 outp "fstp dword ptr [esp]"
2147 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2149 outp "add esp" + COMMA +
str( ddsize )
2157 byval dvreg
as IRVREG
ptr _
2161 dim as integer ddsize
2163 ddsize = typeGetSize( dvreg->dtype )
2165 if( ( ddsize = 4 )
and ( env.clopt.fpmode = FB_FPMODE_FAST ) )
then
2172 if( dvreg->regFamily = IR_REG_SSE )
then
2173 outp "sub esp" + COMMA +
str( ddsize )
2174 if( ddsize > 4 )
then
2175 outp "movlpd qword ptr [esp]" + COMMA + dst
2176 outp "fld qword ptr [esp]"
2178 outp "movss dword ptr [esp]" + COMMA + dst
2179 outp "fld dword ptr [esp]"
2185 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2186 outp "sub esp" + COMMA +
str( ddsize )
2189 if( ddsize > 4 )
then
2190 outp "fstp qword ptr [esp]"
2191 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2193 outp "fstp dword ptr [esp]"
2194 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2196 outp "add esp" + COMMA +
str( ddsize )
2205 byval dvreg
as IRVREG
ptr _
2209 dim as integer ddsize
2211 ddsize = typeGetSize( dvreg->dtype )
2214 if( dvreg->regFamily = IR_REG_SSE )
then
2215 outp "sub esp" + COMMA +
str( ddsize )
2216 if( ddsize > 4 )
then
2217 outp "movlpd qword ptr [esp]" + COMMA + dst
2218 outp "fld qword ptr [esp]"
2220 outp "movss dword ptr [esp]" + COMMA + dst
2221 outp "fld dword ptr [esp]"
2227 outp "fmul st(0), st(0)"
2234 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2235 outp "sub esp" + COMMA +
str( ddsize )
2238 if( ddsize > 4 )
then
2239 outp "fstp qword ptr [esp]"
2240 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2242 outp "fstp dword ptr [esp]"
2243 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2245 outp "add esp" + COMMA +
str( ddsize )
2253 byval dvreg
as IRVREG
ptr _
2257 dim as integer ddsize
2259 ddsize = typeGetSize( dvreg->dtype )
2262 if( dvreg->regFamily = IR_REG_SSE )
then
2263 outp "sub esp" + COMMA +
str( ddsize )
2264 if( ddsize > 4 )
then
2265 outp "movlpd qword ptr [esp]" + COMMA + dst
2266 outp "fld qword ptr [esp]"
2268 outp "movss dword ptr [esp]" + COMMA + dst
2269 outp "fld dword ptr [esp]"
2276 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2277 outp "sub esp" + COMMA +
str( ddsize )
2280 if( ddsize > 4 )
then
2281 outp "fstp qword ptr [esp]"
2282 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2284 outp "fstp dword ptr [esp]"
2285 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2287 outp "add esp" + COMMA +
str( ddsize )
2295 byval dvreg
as IRVREG
ptr _
2299 dim as integer ddsize
2301 ddsize = typeGetSize( dvreg->dtype )
2304 if( dvreg->regFamily = IR_REG_SSE )
then
2305 outp "sub esp" + COMMA +
str( ddsize )
2306 if( ddsize > 4 )
then
2307 outp "movlpd qword ptr [esp]" + COMMA + dst
2308 outp "fld qword ptr [esp]"
2310 outp "movss dword ptr [esp]" + COMMA + dst
2311 outp "fld dword ptr [esp]"
2318 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2319 outp "sub esp" + COMMA +
str( ddsize )
2322 if( ddsize > 4 )
then
2323 outp "fstp qword ptr [esp]"
2324 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2326 outp "fstp dword ptr [esp]"
2327 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2329 outp "add esp" + COMMA +
str( ddsize )
2337 byval dvreg
as IRVREG
ptr _
2341 dim as integer ddsize
2344 ddsize = typeGetSize( dvreg->dtype )
2346 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2347 outp "sub esp" + COMMA +
str( ddsize )
2348 if( ddsize > 4 )
then
2349 outp "fstp qword ptr [esp]"
2350 outp "movlpd " + dst + COMMA +
"dword ptr [esp]"
2352 outp "fstp dword ptr [esp]"
2353 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2357 if( ddsize > 4 )
then
2358 outp "sqrtsd " + dst + COMMA + dst
2360 outp "sqrtss " + dst + COMMA + dst
2363 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2364 outp "add esp" + COMMA +
str( ddsize )
2372 byval dvreg
as IRVREG
ptr _
2376 dim as integer ddsize
2379 ddsize = typeGetSize( dvreg->dtype )
2381 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2382 outp "sub esp" + COMMA +
str( ddsize )
2383 if( ddsize > 4 )
then
2384 outp "fstp qword ptr [esp]"
2385 outp "movlpd " + dst + COMMA +
"dword ptr [esp]"
2387 outp "fstp dword ptr [esp]"
2388 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2392 if( ddsize > 4 )
then
2393 outp "rsqrtsd " + dst + COMMA + dst
2395 outp "rsqrtss " + dst + COMMA + dst
2398 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2399 outp "add esp" + COMMA +
str( ddsize )
2407 byval dvreg
as IRVREG
ptr _
2411 dim as integer ddsize
2414 ddsize = typeGetSize( dvreg->dtype )
2416 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2417 outp "sub esp" + COMMA +
str( ddsize )
2418 if( ddsize > 4 )
then
2419 outp "fstp qword ptr [esp]"
2420 outp "movlpd " + dst + COMMA +
"dword ptr [esp]"
2422 outp "fstp dword ptr [esp]"
2423 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2427 if( ddsize > 4 )
then
2428 outp "rcpsd " + dst + COMMA + dst
2430 outp "rcpss " + dst + COMMA + dst
2433 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2434 outp "add esp" + COMMA +
str( ddsize )
2443 byval dvreg
as IRVREG
ptr _
2449 dim as integer ddsize
2451 ddsize = typeGetSize( dvreg->dtype )
2454 if( dvreg->regFamily = IR_REG_SSE )
then
2455 outp "sub esp" + COMMA +
str( ddsize )
2456 if( ddsize > 4 )
then
2457 outp "movlpd qword ptr [esp]" + COMMA + dst
2458 outp "fld qword ptr [esp]"
2460 outp "movss dword ptr [esp]" + COMMA + dst
2461 outp "fld dword ptr [esp]"
2470 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2471 outp "sub esp" + COMMA +
str( ddsize )
2474 if( ddsize > 4 )
then
2475 outp "fstp qword ptr [esp]"
2476 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2478 outp "fstp dword ptr [esp]"
2479 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2481 outp "add esp" + COMMA +
str( ddsize )
2488 byval dvreg
as IRVREG
ptr _
2492 dim as integer ddsize
2494 ddsize = typeGetSize( dvreg->dtype )
2497 if( dvreg->regFamily = IR_REG_SSE )
then
2498 outp "sub esp" + COMMA +
str( ddsize )
2499 if( ddsize > 4 )
then
2500 outp "movlpd qword ptr [esp]" + COMMA + dst
2501 outp "fld qword ptr [esp]"
2503 outp "movss dword ptr [esp]" + COMMA + dst
2504 outp "fld dword ptr [esp]"
2509 outp "fmulp st(1), st"
2512 outp "fsub st(1), st"
2516 hPUSH(
"0x3f800000" )
2517 outp "fadd dword ptr [esp]"
2523 if( dvreg->regFamily = IR_REG_FPU_STACK )
then
2524 outp "sub esp" + COMMA +
str( ddsize )
2527 if( ddsize > 4 )
then
2528 outp "fstp qword ptr [esp]"
2529 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2531 outp "fstp dword ptr [esp]"
2532 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2534 outp "add esp" + COMMA +
str( ddsize )
2542 byval dvreg
as IRVREG
ptr _
2545 dim as string dst, neg1, suffix
2546 dim as integer ddsize
2547 dim as FBSYMBOL
ptr sym
2548 dim as IRVREG
ptr vreg
2550 ddsize = typeGetSize( dvreg->dtype )
2551 if( ddsize > 4 )
then
2553 vreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, sym, symbGetOfs( sym ) )
2557 vreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, sym, symbGetOfs( sym ) )
2560 sym->var_.align = 16
2567 if( dvreg->regFamily = IR_REG_SSE )
then
2568 if( ddsize > 4 )
then
2569 outp "movlpd qword ptr [esp]" + COMMA + dst
2570 outp "fld qword ptr [esp]"
2572 outp "movss dword ptr [esp]" + COMMA + dst
2573 outp "fld dword ptr [esp]"
2575 outp "movap" + suffix +
"xmm7" + COMMA + dst
2577 if( ddsize > 4 )
then
2578 outp "fst qword ptr [esp]"
2579 outp "movlpd xmm7, qword ptr [esp]"
2581 outp "fst dword ptr [esp]"
2582 outp "movss xmm7, dword ptr [esp]"
2586 outp "fistp qword ptr [esp]"
2587 outp "fild qword ptr [esp]"
2588 outp "fstp " + dtypeTB(dvreg->dtype).mname +
" [esp]"
2589 outp "xorp" + suffix + dst + COMMA + dst
2590 outp "subs" + suffix +
"xmm7" + COMMA +
"[esp]"
2591 outp "cmpnles" + suffix + dst + COMMA +
"xmm7"
2592 outp "andp" + suffix + dst + COMMA + neg1
2593 outp "adds" + suffix + dst + COMMA +
"[esp]"
2603 byval dvreg
as IRVREG
ptr _
2608 dim as string dst, suffix, absval, neg1
2609 dim as integer ddsize
2610 dim as FBSYMBOL
ptr neg1_sym, absval_sym
2611 dim as IRVREG
ptr neg1_vreg, absval_vreg
2613 ddsize = typeGetSize( dvreg->dtype )
2614 if( ddsize > 4 )
then
2616 neg1_vreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, neg1_sym, symbGetOfs( neg1_sym ) )
2619 absval_vreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, absval_sym, symbGetOfs( absval_sym ) )
2624 neg1_vreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, neg1_sym, symbGetOfs( neg1_sym ) )
2627 absval_vreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, absval_sym, symbGetOfs( absval_sym ) )
2632 neg1_sym->var_.align = 16
2633 absval_sym->var_.align = 16
2637 hPrepOperand( absval_vreg, absval, FB_DATATYPE_XMMWORD )
2639 outp "sub esp" + COMMA +
str( ddsize + 8 )
2641 if( dvreg->regFamily = IR_REG_SSE )
then
2642 if( ddsize > 4 )
then
2643 outp "movlpd qword ptr [esp]" + COMMA + dst
2644 outp "fld qword ptr [esp]"
2646 outp "movss dword ptr [esp]" + COMMA + dst
2647 outp "fld dword ptr [esp]"
2650 if( ddsize > 4 )
then
2651 outp "fst qword ptr [esp]"
2652 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2654 outp "fst dword ptr [esp]"
2655 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2659 outp "xorp" + suffix +
"xmm7, xmm7"
2660 if( ddsize > 4 )
then
2661 outp "movlpd [esp+8], xmm7"
2663 outp "movss [esp+8], xmm7"
2666 outp "fistp qword ptr [esp]"
2667 outp "cmpnles" + suffix +
"xmm7" + COMMA + dst
2668 outp "fild qword ptr [esp]"
2669 outp "andp" + suffix +
"xmm7" + COMMA + absval
2670 outp "fstp " + dtypeTB(dvreg->dtype).mname +
" [esp]"
2671 outp "subs" + suffix + dst + COMMA +
"[esp]"
2672 outp "xorp" + suffix + dst + COMMA +
"xmm7"
2673 outp "xorp" + suffix +
"xmm7" + COMMA + neg1
2675 outp "cmplts" + suffix + dst + COMMA +
"[esp+8]"
2676 outp "andp" + suffix + dst + COMMA +
"xmm7"
2677 outp "adds" + suffix + dst + COMMA +
"[esp]"
2678 outp "add esp" + COMMA +
str( ddsize + 8 )
2685 byval dvreg
as IRVREG
ptr _
2690 dim as string dst, suffix, absval, neg1
2691 dim as integer ddsize
2692 dim as FBSYMBOL
ptr neg1_sym, absval_sym
2693 dim as IRVREG
ptr neg1_vreg, absval_vreg
2695 ddsize = typeGetSize( dvreg->dtype )
2696 if( ddsize > 4 )
then
2698 neg1_vreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, neg1_sym, symbGetOfs( neg1_sym ) )
2701 absval_vreg = irAllocVRVAR( FB_DATATYPE_ULONGINT, NULL, absval_sym, symbGetOfs( absval_sym ) )
2706 neg1_vreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, neg1_sym, symbGetOfs( neg1_sym ) )
2709 absval_vreg = irAllocVRVAR( FB_DATATYPE_UINT, NULL, absval_sym, symbGetOfs( absval_sym ) )
2713 neg1_sym->var_.align = 16
2714 absval_sym->var_.align = 16
2718 hPrepOperand( absval_vreg, absval, FB_DATATYPE_XMMWORD )
2720 outp "sub esp" + COMMA +
str( ddsize+8 )
2722 if( dvreg->regFamily = IR_REG_SSE )
then
2723 if( ddsize > 4 )
then
2724 outp "movlpd qword ptr [esp]" + COMMA + dst
2725 outp "fld qword ptr [esp]"
2727 outp "movss dword ptr [esp]" + COMMA + dst
2728 outp "fld dword ptr [esp]"
2731 if( ddsize > 4 )
then
2732 outp "fst qword ptr [esp]"
2733 outp "movlpd " + dst + COMMA +
"qword ptr [esp]"
2735 outp "fst dword ptr [esp]"
2736 outp "movss " + dst + COMMA +
"dword ptr [esp]"
2740 outp "xorp" + suffix +
"xmm7, xmm7"
2741 if( ddsize > 4 )
then
2742 outp "shufpd " + dst + COMMA + dst + COMMA +
"0"
2743 outp "movlpd [esp+8], xmm7"
2745 outp "movlhps " + dst + COMMA + dst
2746 outp "movss [esp+8], xmm7"
2749 outp "fistp qword ptr [esp]"
2750 outp "cmpnles" + suffix +
"xmm7" + COMMA + dst
2751 outp "fild qword ptr [esp]"
2752 outp "andp" + suffix +
"xmm7" + COMMA + absval
2753 outp "fstp " + dtypeTB(dvreg->dtype).mname +
" [esp]"
2754 outp "subs" + suffix + dst + COMMA +
"[esp]"
2755 outp "xorp" + suffix + dst + COMMA +
"xmm7"
2756 outp "xorp" + suffix +
"xmm7" + COMMA + neg1
2758 outp "cmplts" + suffix + dst + COMMA +
"[esp+8]"
2759 outp "andp" + suffix +
"xmm7" + COMMA + dst
2760 if( ddsize > 4 )
then
2761 outp "shufpd " + dst + COMMA + dst + COMMA +
"1"
2763 outp "movhlps " + dst + COMMA + dst
2765 outp "adds" + suffix +
"xmm7" + COMMA +
"[esp]"
2766 outp "subs" + suffix + dst + COMMA +
"xmm7"
2767 outp "add esp" + COMMA +
str( ddsize+8 )
2781 byval svreg
as IRVREG
ptr, _
2782 byval unused
as integer _
2785 dim src
as string, sdsize
as integer
2790 sdsize = typeGetSize( svreg->dtype )
2792 if( svreg->typ <> IR_VREGTYPE_REG )
then
2793 if( svreg->dtype = FB_DATATYPE_SINGLE )
then
2794 ostr =
"push " + src
2798 ostr =
"push " + src
2802 ostr =
"push " + src
2806 ostr =
"sub esp" + COMMA +
str( sdsize )
2810 if( svreg->regFamily = IR_REG_FPU_STACK )
then
2811 ostr =
"fstp " + dtypeTB(svreg->dtype).mname +
" [esp]"
2816 if( sdsize > 4 )
then
2821 outp ostr +
"[esp]" + COMMA + src
2831 byval dvreg
as IRVREG
ptr, _
2832 byval unused
as integer _
2835 dim as string dst, ostr
2836 dim as integer dsize
2840 dsize = typeGetSize( dvreg->dtype )
2842 if( dvreg->typ <> IR_VREGTYPE_REG )
then
2843 if( dvreg->dtype = FB_DATATYPE_SINGLE )
then
2856 if( dsize > 4 )
then
2861 outp ostr + dst + COMMA + dtypeTB(dvreg->dtype).mname +
" [esp]"
2863 outp "add esp, " +
str( dsize )
2873 #define EMIT_CBENTRY(op) @_emit##op##
2878 byval _opFnTB_SSE
as any ptr ptr _
2882 _opFnTB_SSE[EMIT_OP_LOADF2I] = EMIT_CBENTRY(LOADF2I_SSE)
2883 _opFnTB_SSE[EMIT_OP_LOADI2F] = EMIT_CBENTRY(LOADI2F_SSE)
2884 _opFnTB_SSE[EMIT_OP_LOADF2L] = EMIT_CBENTRY(LOADF2L_SSE)
2885 _opFnTB_SSE[EMIT_OP_LOADL2F] = EMIT_CBENTRY(LOADL2F_SSE)
2886 _opFnTB_SSE[EMIT_OP_LOADF2F] = EMIT_CBENTRY(LOADF2F_SSE)
2889 _opFnTB_SSE[EMIT_OP_STORF2I] = EMIT_CBENTRY(STORF2I_SSE)
2890 _opFnTB_SSE[EMIT_OP_STORI2F] = EMIT_CBENTRY(STORI2F_SSE)
2891 _opFnTB_SSE[EMIT_OP_STORF2L] = EMIT_CBENTRY(STORF2L_SSE)
2892 _opFnTB_SSE[EMIT_OP_STORL2F] = EMIT_CBENTRY(STORL2F_SSE)
2893 _opFnTB_SSE[EMIT_OP_STORF2F] = EMIT_CBENTRY(STORF2F_SSE)
2896 _opFnTB_SSE[EMIT_OP_MOVF] = EMIT_CBENTRY(MOVF_SSE)
2897 _opFnTB_SSE[EMIT_OP_ADDF] = EMIT_CBENTRY(ADDF_SSE)
2898 _opFnTB_SSE[EMIT_OP_SUBF] = EMIT_CBENTRY(SUBF_SSE)
2899 _opFnTB_SSE[EMIT_OP_MULF] = EMIT_CBENTRY(MULF_SSE)
2900 _opFnTB_SSE[EMIT_OP_DIVF] = EMIT_CBENTRY(DIVF_SSE)
2902 _opFnTB_SSE[EMIT_OP_ATN2] = EMIT_CBENTRY(ATN2_SSE)
2903 _opFnTB_SSE[EMIT_OP_POW] = EMIT_CBENTRY(POW_SSE)
2906 _opFnTB_SSE[EMIT_OP_CGTF] = EMIT_CBENTRY(CGTF_SSE)
2907 _opFnTB_SSE[EMIT_OP_CLTF] = EMIT_CBENTRY(CLTF_SSE)
2908 _opFnTB_SSE[EMIT_OP_CEQF] = EMIT_CBENTRY(CEQF_SSE)
2909 _opFnTB_SSE[EMIT_OP_CNEF] = EMIT_CBENTRY(CNEF_SSE)
2910 _opFnTB_SSE[EMIT_OP_CGEF] = EMIT_CBENTRY(CGEF_SSE)
2911 _opFnTB_SSE[EMIT_OP_CLEF] = EMIT_CBENTRY(CLEF_SSE)
2914 _opFnTB_SSE[EMIT_OP_NEGF] = EMIT_CBENTRY(NEGF_SSE)
2915 _opFnTB_SSE[EMIT_OP_HADDF] = EMIT_CBENTRY(HADDF_SSE)
2916 _opFnTB_SSE[EMIT_OP_ABSF] = EMIT_CBENTRY(ABSF_SSE)
2917 _opFnTB_SSE[EMIT_OP_SGNF] = EMIT_CBENTRY(SGNF_SSE)
2919 _opFnTB_SSE[EMIT_OP_FIX] = EMIT_CBENTRY(FIX_SSE)
2920 _opFnTB_SSE[EMIT_OP_FRAC] = EMIT_CBENTRY(FRAC_SSE)
2922 _opFnTB_SSE[EMIT_OP_SIN] = EMIT_CBENTRY(SIN_SSE)
2923 _opFnTB_SSE[EMIT_OP_ASIN] = EMIT_CBENTRY(ASIN_SSE)
2924 _opFnTB_SSE[EMIT_OP_COS] = EMIT_CBENTRY(COS_SSE)
2925 _opFnTB_SSE[EMIT_OP_ACOS] = EMIT_CBENTRY(ACOS_SSE)
2926 _opFnTB_SSE[EMIT_OP_TAN] = EMIT_CBENTRY(TAN_SSE)
2927 _opFnTB_SSE[EMIT_OP_ATAN] = EMIT_CBENTRY(ATAN_SSE)
2929 _opFnTB_SSE[EMIT_OP_SQRT] = EMIT_CBENTRY(SQRT_SSE)
2930 _opFnTB_SSE[EMIT_OP_RSQRT] = EMIT_CBENTRY(RSQRT_SSE)
2931 _opFnTB_SSE[EMIT_OP_RCP] = EMIT_CBENTRY(RCP_SSE)
2933 _opFnTB_SSE[EMIT_OP_LOG] = EMIT_CBENTRY(LOG_SSE)
2934 _opFnTB_SSE[EMIT_OP_EXP] = EMIT_CBENTRY(EXP_SSE)
2936 _opFnTB_SSE[EMIT_OP_FLOOR] = EMIT_CBENTRY(FLOOR_SSE)
2937 _opFnTB_SSE[EMIT_OP_SWZREP] = EMIT_CBENTRY(SWZREPF_SSE)
2939 _opFnTB_SSE[EMIT_OP_PUSHF] = EMIT_CBENTRY(PUSHF_SSE)
2940 _opFnTB_SSE[EMIT_OP_POPF] = EMIT_CBENTRY(POPF_SSE)