Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix SIMD intrinsics handling in crossgen2 #27853

Merged
merged 2 commits into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,10 @@ public static bool IsVectorType(DefType type)
type.Name == "Vector128`1" ||
type.Name == "Vector256`1");
}

public static bool IsVectorOfTType(DefType type)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For #23899, I had added this as InteropTypes.IsSystemNumericsVectorT, as that appears to be where a fair number of the other IsType checks live

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure which location is better. Your methods are also a bit different as they require the TypeSystemContext parameter. So maybe keeping both versions makes sense. There was already the IsVectorType here, so adding the IsVectorOfTypeT to the same place felt ok.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InteropTypes only handles types interesting for interop (as the name implies). Up until Tanner's change it was exclusively used in generating/figuring out marshalling. Crossgen2 doesn't have a central MscorlibBinder equivalent (as it exists in CoreCLR).

We place these as close to the usage as possible. Centralized locations tend to end up with orphaned entries.

{
return type.IsIntrinsic && type.Namespace == "System.Numerics" && type.Name == "Vector`1";
}
}
}
9 changes: 9 additions & 0 deletions src/tools/crossgen2/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,15 @@ private uint getMethodAttribsInternal(MethodDesc method)
result |= CorInfoFlag.CORINFO_FLG_FINAL;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#if READYTORUN ?

#if READYTORUN
// Check for SIMD intrinsics
DefType owningDefType = method.OwningType as DefType;
if (owningDefType != null && VectorFieldLayoutAlgorithm.IsVectorOfTType(owningDefType))
{
throw new RequiresRuntimeJitException("This function is using SIMD intrinsics, their size is machine specific");
}
#endif

// Check for hardware intrinsics
if (HardwareIntrinsicHelpers.IsHardwareIntrinsic(method))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using ILCompiler;
using Internal.TypeSystem;

namespace Internal.JitInterface
Expand Down Expand Up @@ -261,16 +262,8 @@ private static bool ClassifyEightBytes(TypeDesc typeDesc,
InstantiatedType instantiatedType = typeDesc as InstantiatedType;
if (instantiatedType != null)
{
string typeName = instantiatedType.Name;
string namespaceName = instantiatedType.Namespace;

if (typeName == "Vector256`1" || typeName == "Vector128`1" || typeName == "Vector64`1")
{
Debug.Assert(namespaceName == "System.Runtime.Intrinsics");
return false;
}

if ((typeName == "Vector`1") && (namespaceName == "System.Numerics"))
if (VectorFieldLayoutAlgorithm.IsVectorType(instantiatedType) ||
VectorFieldLayoutAlgorithm.IsVectorOfTType(instantiatedType))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public override FieldLayoutAlgorithm GetLayoutAlgorithmForType(DefType type)
throw new NotImplementedException();
else if (type.IsRuntimeDeterminedType)
throw new NotImplementedException();
else if (type.IsIntrinsic && (type.Name == "Vector`1") && (type.Namespace == "System.Numerics"))
else if (VectorIntrinsicFieldLayoutAlgorithm.IsVectorOfTType(type))
{
return _vectorFieldLayoutAlgorithm;
}
Expand Down