add convertSD2SI, mov double dupplicate (without 64 bit support no other way found)

fix conv.i4 for case:    double k = 50.5; int k2 = (int)k;
This commit is contained in:
Trivalik_cp 2011-05-24 20:28:57 +00:00
parent 522e276d05
commit 591e20c7ec
5 changed files with 31 additions and 8 deletions

View file

@ -126,9 +126,11 @@
<Compile Include="ShiftRight.cs" />
<Compile Include="SSE2\ConvertSI2SD.cs" />
<Compile Include="SSE2\ConvertSS2SD.cs" />
<Compile Include="SSE2\ConvertSD2SI.cs" />
<Compile Include="SSE2\MoveSD.cs" />
<Compile Include="SSE2\SqrtSD.cs" />
<Compile Include="SSE2\XorPD.cs" />
<Compile Include="SSE3\MoveDoubleAndDupplicate.cs" />
<Compile Include="SSEAndMMX2\AddPS.cs" />
<Compile Include="SSEAndMMX2\AddSS.cs" />
<Compile Include="SSEAndMMX2\AndPS.cs" />
@ -212,7 +214,7 @@
<Compile Include="x87\IntMul.cs" />
<Compile Include="x87\IntStore.cs" />
<Compile Include="x87\IntStoreAndPop.cs" />
<Compile Include="x87\IntStoreWithTrunc.cs" />
<Compile Include="SSE3\IntStoreWithTrunc.cs" />
<Compile Include="x87\IntSub.cs" />
<Compile Include="x87\IntSubReverse.cs" />
<Compile Include="Xchg.cs" />
@ -258,7 +260,6 @@
<Folder Include="PentiumAndUp\" />
<Folder Include="PentiumMMXAndUp\" />
<Folder Include="PentiumProAndUp\" />
<Folder Include="SSE3\" />
<Folder Include="SSE4a\" />
<Folder Include="SSE4dot1\" />
<Folder Include="SSE4dot2\" />

View file

@ -0,0 +1,7 @@
namespace Cosmos.Compiler.Assembler.X86.SSE
{
[OpCode("CVTSD2SI")]
public class ConvertSD2SI : InstructionWithDestinationAndSource
{
}
}

View file

@ -0,0 +1,7 @@
namespace Cosmos.Compiler.Assembler.X86.SSE
{
[OpCode("MOVDDUP")]
public class MoveDoubleAndDupplicate : InstructionWithDestinationAndSource
{
}
}

View file

@ -17,12 +17,7 @@ namespace Cosmos.IL2CPU.X86.IL
public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
var xSource = Assembler.Stack.Pop();
if (xSource.IsFloat)
{
new CPUx86.SSE.MoveSS { SourceReg = CPUx86.Registers.ESP, DestinationReg = CPUx86.Registers.XMM0, SourceIsIndirect = true };
new CPUx86.SSE.ConvertSS2SI { SourceReg = CPUx86.Registers.XMM0, DestinationReg = CPUx86.Registers.EAX };
new CPUx86.Move { DestinationReg = CPUx86.Registers.ESP, SourceReg = CPUx86.Registers.EAX, DestinationIsIndirect = true };
}
switch( xSource.Size )
{
@ -30,10 +25,23 @@ namespace Cosmos.IL2CPU.X86.IL
case 2:
case 4:
{
if (xSource.IsFloat)
{
new CPUx86.SSE.MoveSS { DestinationReg = CPUx86.Registers.XMM0, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true };
new CPUx86.SSE.ConvertSS2SI { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.XMM0 };
new CPUx86.Move { DestinationReg = CPUx86.Registers.ESP, SourceReg = CPUx86.Registers.EAX, DestinationIsIndirect = true };
}
break;
}
case 8:
{
if (xSource.IsFloat)
{
new CPUx86.SSE.MoveDoubleAndDupplicate { DestinationReg = CPUx86.Registers.XMM0, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true };
new CPUx86.SSE.ConvertSD2SI { DestinationReg = CPUx86.Registers.EAX, SourceReg = CPUx86.Registers.XMM0 };
new CPUx86.Move { DestinationReg = CPUx86.Registers.ESP, SourceReg = CPUx86.Registers.EAX, DestinationIsIndirect = true };
}
new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX };
new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 };
new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX };