1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
7 #ifdef FEATURE_HW_INTRINSICS
9 //------------------------------------------------------------------------
10 // impUnsupportedHWIntrinsic: returns a node for an unsupported HWIntrinsic
13 // helper - JIT helper ID for the exception to be thrown
14 // method - method handle of the intrinsic function.
15 // sig - signature of the intrinsic call
16 // mustExpand - true if the intrinsic must return a GenTree*; otherwise, false
19 // a gtNewMustThrowException if mustExpand is true; otherwise, nullptr
21 GenTree* Compiler::impUnsupportedHWIntrinsic(unsigned helper,
22 CORINFO_METHOD_HANDLE method,
23 CORINFO_SIG_INFO* sig,
26 // We've hit some error case and may need to return a node for the given error.
28 // When `mustExpand=false`, we are attempting to inline the intrinsic directly into another method. In this
29 // scenario, we need to return `nullptr` so that a GT_CALL to the intrinsic is emitted instead. This is to
30 // ensure that everything continues to behave correctly when optimizations are enabled (e.g. things like the
31 // inliner may expect the node we return to have a certain signature, and the `MustThrowException` node won't
34 // When `mustExpand=true`, we are in a GT_CALL to the intrinsic and are attempting to JIT it. This will generally
35 // be in response to an indirect call (e.g. done via reflection) or in response to an earlier attempt returning
36 // `nullptr` (under `mustExpand=false`). In that scenario, we are safe to return the `MustThrowException` node.
40 for (unsigned i = 0; i < sig->numArgs; i++)
45 return gtNewMustThrowException(helper, JITtype2varType(sig->retType), sig->retTypeClass);
53 CORINFO_CLASS_HANDLE Compiler::gtGetStructHandleForHWSIMD(var_types simdType, var_types simdBaseType)
55 if (simdType == TYP_SIMD16)
60 return Vector128FloatHandle;
62 return Vector128DoubleHandle;
64 return Vector128IntHandle;
66 return Vector128UShortHandle;
68 return Vector128UByteHandle;
70 return Vector128ShortHandle;
72 return Vector128ByteHandle;
74 return Vector128LongHandle;
76 return Vector128UIntHandle;
78 return Vector128ULongHandle;
80 assert(!"Didn't find a class handle for simdType");
84 else if (simdType == TYP_SIMD32)
89 return Vector256FloatHandle;
91 return Vector256DoubleHandle;
93 return Vector256IntHandle;
95 return Vector256UShortHandle;
97 return Vector256UByteHandle;
99 return Vector256ShortHandle;
101 return Vector256ByteHandle;
103 return Vector256LongHandle;
105 return Vector256UIntHandle;
107 return Vector256ULongHandle;
109 assert(!"Didn't find a class handle for simdType");
112 #endif // _TARGET_XARCH_
113 #ifdef _TARGET_ARM64_
114 else if (simdType == TYP_SIMD8)
116 switch (simdBaseType)
119 return Vector64FloatHandle;
121 return Vector64UIntHandle;
123 return Vector64UShortHandle;
125 return Vector64UByteHandle;
127 return Vector64ShortHandle;
129 return Vector64ByteHandle;
131 return Vector64IntHandle;
133 assert(!"Didn't find a class handle for simdType");
136 #endif // _TARGET_ARM64_
138 return NO_CLASS_HANDLE;
141 #endif // FEATURE_HW_INTRINSICS