Skip to content

Commit 4d58c2f

Browse files
committed
More conv opcodes
1 parent ad7b829 commit 4d58c2f

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,9 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method
835835
case ILOpcode.conv_u2:
836836
case ILOpcode.conv_u4:
837837
case ILOpcode.conv_u8:
838-
{
838+
case ILOpcode.conv_r4:
839+
case ILOpcode.conv_r8:
840+
{
839841
StackEntry popped = stack.Pop();
840842
if (popped.ValueKind.WithNormalizedNativeInt(context) == StackValueKind.Int32)
841843
{
@@ -874,6 +876,12 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method
874876
case ILOpcode.conv_u8:
875877
stack.Push(StackValueKind.Int64, ValueTypeValue.FromInt64((uint)val));
876878
break;
879+
case ILOpcode.conv_r4:
880+
stack.Push(StackValueKind.Float, ValueTypeValue.FromSingle((float)val));
881+
break;
882+
case ILOpcode.conv_r8:
883+
stack.Push(StackValueKind.Float, ValueTypeValue.FromDouble((double)val));
884+
break;
877885
default:
878886
return Status.Fail(methodIL.OwningMethod, opcode);
879887
}
@@ -912,6 +920,12 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method
912920
case ILOpcode.conv_u8:
913921
stack.Push(StackValueKind.Int64, ValueTypeValue.FromInt64(val));
914922
break;
923+
case ILOpcode.conv_r4:
924+
stack.Push(StackValueKind.Float, ValueTypeValue.FromSingle((float)val));
925+
break;
926+
case ILOpcode.conv_r8:
927+
stack.Push(StackValueKind.Float, ValueTypeValue.FromDouble((double)val));
928+
break;
915929
default:
916930
return Status.Fail(methodIL.OwningMethod, opcode);
917931
}
@@ -921,9 +935,36 @@ private Status TryScanMethod(MethodIL methodIL, Value[] parameters, Stack<Method
921935
double val = popped.Value.AsDouble();
922936
switch (opcode)
923937
{
938+
case ILOpcode.conv_i1:
939+
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((sbyte)val));
940+
break;
941+
case ILOpcode.conv_i2:
942+
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((short)val));
943+
break;
944+
case ILOpcode.conv_i4:
945+
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((int)val));
946+
break;
924947
case ILOpcode.conv_i8:
925948
stack.Push(StackValueKind.Int64, ValueTypeValue.FromInt64((long)val));
926949
break;
950+
case ILOpcode.conv_u1:
951+
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((byte)val));
952+
break;
953+
case ILOpcode.conv_u2:
954+
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((ushort)val));
955+
break;
956+
case ILOpcode.conv_u4:
957+
stack.Push(StackValueKind.Int32, ValueTypeValue.FromInt32((int)val));
958+
break;
959+
case ILOpcode.conv_u8:
960+
stack.Push(StackValueKind.Int64, ValueTypeValue.FromInt64((long)val));
961+
break;
962+
case ILOpcode.conv_r4:
963+
stack.Push(StackValueKind.Float, ValueTypeValue.FromSingle((float)val));
964+
break;
965+
case ILOpcode.conv_r8:
966+
stack.Push(StackValueKind.Float, ValueTypeValue.FromDouble(val));
967+
break;
927968
default:
928969
return Status.Fail(methodIL.OwningMethod, opcode);
929970
}

0 commit comments

Comments
 (0)