Skip to content

Commit af3bc33

Browse files
authored
Merge pull request #77 from jayrm/bugfix-875-sse
Fix #875 for -gen gas -fpu sse
2 parents 791f00d + e9e9123 commit af3bc33

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Version 1.06.0
5151
- #841: The unary negation operator gave different result signedness when used on constant instead of non-constant expression. Now the result is always signed.
5252
- Incorrect C++ mangling for BYREF parameters using built-in types
5353
- #844: Fix bug in -gen gcc due to duplicated type (struct) names in the main module and global namespace
54-
- #875: Fix bug where boolean variable to single/double conversion gives wrong sign on -gen gas x86
54+
- #875: Fix bug where boolean variable to single/double conversion gives wrong sign on -gen gas -fpu x87 & sse
5555
- #872: Fix broken boolean bitfield runtime assignments from unsigned values
5656

5757

src/compiler/emit_SSE.bas

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include once "symb.bi"
1414
#include once "emit-private.bi"
1515

16+
dim shared _emitLOADB2F_x86 as sub( byval dvreg as IRVREG ptr, byval svreg as IRVREG ptr )
17+
1618
private sub hULONG2DBL _
1719
( _
1820
byval svreg as IRVREG ptr _
@@ -38,6 +40,29 @@ private sub hULONG2DBL _
3840

3941
end sub
4042

43+
private sub _emitLOADB2F_SSE( byval dvreg as IRVREG ptr, byval svreg as IRVREG ptr )
44+
45+
dim as string dst
46+
dim as integer ddsize = any
47+
48+
'' load source to ST(0)
49+
_emitLOADB2F_x86( dvreg, svreg )
50+
51+
hPrepOperand( dvreg, dst )
52+
ddsize = typeGetSize( dvreg->dtype )
53+
54+
'' pop from FPU STACK and load to SSE register
55+
outp "sub esp" + COMMA + str( ddsize )
56+
if( ddsize > 4 ) then
57+
outp "fstp qword ptr [esp]"
58+
outp "movlpd " + dst + COMMA + "qword ptr [esp]"
59+
else
60+
outp "fstp dword ptr [esp]"
61+
outp "movss " + dst + COMMA + "dword ptr [esp]"
62+
end if
63+
outp "add esp" + COMMA + str( ddsize )
64+
65+
end sub
4166

4267
'':::::
4368
private sub _emitSTORF2L_SSE _
@@ -2882,11 +2907,13 @@ function _init_opFnTB_SSE _
28822907
) as integer
28832908

28842909
'' load
2910+
_emitLOADB2F_x86 = _opFnTB_SSE[EMIT_OP_LOADB2F]
28852911
_opFnTB_SSE[EMIT_OP_LOADF2I] = EMIT_CBENTRY(LOADF2I_SSE)
28862912
_opFnTB_SSE[EMIT_OP_LOADI2F] = EMIT_CBENTRY(LOADI2F_SSE)
28872913
_opFnTB_SSE[EMIT_OP_LOADF2L] = EMIT_CBENTRY(LOADF2L_SSE)
28882914
_opFnTB_SSE[EMIT_OP_LOADL2F] = EMIT_CBENTRY(LOADL2F_SSE)
28892915
_opFnTB_SSE[EMIT_OP_LOADF2F] = EMIT_CBENTRY(LOADF2F_SSE)
2916+
_opFnTB_SSE[EMIT_OP_LOADB2F] = EMIT_CBENTRY(LOADB2F_SSE)
28902917

28912918
'' store
28922919
_opFnTB_SSE[EMIT_OP_STORF2I] = EMIT_CBENTRY(STORF2I_SSE)

0 commit comments

Comments
 (0)