Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.
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
1 change: 1 addition & 0 deletions src/dlls/mscorrc/mscorrc.rc
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ BEGIN
IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED "SIMD intrinsics may not be used by partial trust applications."
IDS_IBC_MISSING_EXTERNAL_TYPE "The generic type specified by the IBC data is not available to this assembly"
IDS_IBC_MISSING_EXTERNAL_METHOD "The generic method specified by the IBC data is not available to this assembly"
IDS_EE_HWINTRINSIC_NGEN_DISALLOWED "Hardware intrinsics may not be used with ngen."

IDS_INET_E_CANNOT_CONNECT "Cannot connect to URL for '%1'."
IDS_INET_E_RESOURCE_NOT_FOUND "The server or proxy was not found for '%1'."
Expand Down
1 change: 1 addition & 0 deletions src/dlls/mscorrc/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@
#define IDS_EE_SIMD_PARTIAL_TRUST_DISALLOWED 0x1ac4
#define IDS_IBC_MISSING_EXTERNAL_TYPE 0x1ac5
#define IDS_IBC_MISSING_EXTERNAL_METHOD 0x1ac6
#define IDS_EE_HWINTRINSIC_NGEN_DISALLOWED 0x1ac7

#define BFA_INVALID_FILE_TOKEN 0x2000
#define BFA_INVALID_TOKEN_TYPE 0x2001
Expand Down
11 changes: 6 additions & 5 deletions src/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,12 @@ TODO: Talk about initializing strutures before use
#define SELECTANY extern __declspec(selectany)
#endif

SELECTANY const GUID JITEEVersionIdentifier = { /* 76a743cd-8a07-471e-9ac4-cd5806a8ffac */
0x76a743cd,
0x8a07,
0x471e,
{0x9a, 0xc4, 0xcd, 0x58, 0x06, 0xa8, 0xff, 0xac}
// {CFEC7B89-D5FF-4A67-823A-EF99FE0286F4}
SELECTANY const GUID JITEEVersionIdentifier = {
0xcfec7b89,
0xd5ff,
0x4a67,
{ 0x82, 0x3a, 0xef, 0x99, 0xfe, 0x2, 0x86, 0xf4 }
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
33 changes: 32 additions & 1 deletion src/inc/corjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,38 @@ class CORJIT_FLAGS
CORJIT_FLAG_UNUSED11 = 41,
#endif // !defined(_TARGET_ARM_)

CORJIT_FLAG_NO_INLINING = 42 // JIT should not inline any called method into this method
CORJIT_FLAG_NO_INLINING = 42, // JIT should not inline any called method into this method

#if defined(_TARGET_X86_) || defined(_TARGET_AMD64_)

CORJIT_FLAG_USE_SSE3 = 43,
CORJIT_FLAG_USE_SSSE3 = 44,
CORJIT_FLAG_USE_SSE41 = 45,
CORJIT_FLAG_USE_SSE42 = 46,
CORJIT_FLAG_USE_AES = 47,
CORJIT_FLAG_USE_BMI1 = 48,
CORJIT_FLAG_USE_BMI2 = 49,
CORJIT_FLAG_USE_FMA = 50,
CORJIT_FLAG_USE_LZCNT = 51,
CORJIT_FLAG_USE_PCLMULQDQ = 52,
CORJIT_FLAG_USE_POPCNT = 53


#else // !defined(_TARGET_X86_) && !defined(_TARGET_AMD64_)

CORJIT_FLAG_UNUSED12 = 43,
CORJIT_FLAG_UNUSED13 = 44,
CORJIT_FLAG_UNUSED14 = 45,
CORJIT_FLAG_UNUSED15 = 46,
CORJIT_FLAG_UNUSED16 = 47,
CORJIT_FLAG_UNUSED17 = 48,
CORJIT_FLAG_UNUSED18 = 49,
CORJIT_FLAG_UNUSED19 = 50,
CORJIT_FLAG_UNUSED20 = 51,
CORJIT_FLAG_UNUSED21 = 52,
CORJIT_FLAG_UNUSED22 = 53

#endif // !defined(_TARGET_X86_) && !defined(_TARGET_AMD64_)
};

CORJIT_FLAGS()
Expand Down
2 changes: 2 additions & 0 deletions src/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ set( JIT_AMD64_SOURCES
simdcodegenxarch.cpp
targetamd64.cpp
unwindamd64.cpp
hwintrinsicxarch.cpp
)

set( JIT_ARM_SOURCES
Expand Down Expand Up @@ -127,6 +128,7 @@ set( JIT_I386_SOURCES
simdcodegenxarch.cpp
targetx86.cpp
unwindx86.cpp
hwintrinsicxarch.cpp
)

set( JIT_ARM64_SOURCES
Expand Down
66 changes: 66 additions & 0 deletions src/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2560,6 +2560,72 @@ void Compiler::compSetProcessor()
#endif // DEBUG

#endif // _TARGET_X86_

// Instruction set flags for Intel hardware intrinsics
#ifdef _TARGET_XARCH_
opts.compSupportsISA = 0;

if (!jitFlags.IsSet(JitFlags::JIT_FLAG_PREJIT))
{
if (opts.compCanUseSSE2)
{
opts.setSupportedISA(InstructionSet_SSE);
opts.setSupportedISA(InstructionSet_SSE2);
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_AES))
{
opts.setSupportedISA(InstructionSet_AES);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_AVX))
{
opts.setSupportedISA(InstructionSet_AVX);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_AVX2))
{
opts.setSupportedISA(InstructionSet_AVX2);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_BMI1))
{
opts.setSupportedISA(InstructionSet_BMI1);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_BMI2))
{
opts.setSupportedISA(InstructionSet_BMI2);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_FMA))
{
opts.setSupportedISA(InstructionSet_FMA);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_LZCNT))
{
opts.setSupportedISA(InstructionSet_LZCNT);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_PCLMULQDQ))
{
opts.setSupportedISA(InstructionSet_PCLMULQDQ);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_POPCNT))
{
opts.setSupportedISA(InstructionSet_POPCNT);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_SSE3))
{
opts.setSupportedISA(InstructionSet_SSE3);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_SSE41))
{
opts.setSupportedISA(InstructionSet_SSE41);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_SSE42))
{
opts.setSupportedISA(InstructionSet_SSE42);
}
if (jitFlags.IsSet(JitFlags::JIT_FLAG_USE_SSSE3))
{
opts.setSupportedISA(InstructionSet_SSSE3);
}
}
}
#endif
}

#ifdef PROFILING_SUPPORTED
Expand Down
39 changes: 39 additions & 0 deletions src/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3016,6 +3016,28 @@ class Compiler
CorInfoIntrinsics intrinsicID,
bool tailCall);
NamedIntrinsic lookupNamedIntrinsic(CORINFO_METHOD_HANDLE method);

#ifdef _TARGET_XARCH_
InstructionSet lookupHWIntrinsicISA(const char* className);
NamedIntrinsic lookupHWIntrinsic(const char* methodName, InstructionSet isa);
InstructionSet isaOfHWIntrinsic(NamedIntrinsic intrinsic);
GenTree* impX86HWIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impSSEIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impSSE2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impSSSE3Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impSSE41Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impSSE42Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impAVXIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impAVX2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impAESIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impBMI1Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impBMI2Intrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impFMAIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impLZCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impPCLMULQDQIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
GenTree* impPOPCNTIntrinsic(NamedIntrinsic intrinsic, CORINFO_METHOD_HANDLE method, CORINFO_SIG_INFO* sig);
#endif
GenTreePtr impArrayAccessIntrinsic(CORINFO_CLASS_HANDLE clsHnd,
CORINFO_SIG_INFO* sig,
int memberRef,
Expand Down Expand Up @@ -7802,6 +7824,15 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#endif
}

bool compSupports(InstructionSet isa)
{
#ifdef _TARGET_XARCH_
return (opts.compSupportsISA & (1 << isa)) != 0;
#else
return false;
#endif
}

/*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Expand Down Expand Up @@ -7915,6 +7946,14 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#endif // FEATURE_AVX_SUPPORT
#endif // _TARGET_XARCH_

#ifdef _TARGET_XARCH_
uint64_t compSupportsISA;
void setSupportedISA(InstructionSet isa)
{
compSupportsISA |= 1 << isa;
}
#endif

// optimize maximally and/or favor speed over size?

#define DEFAULT_MIN_OPTS_CODE_SIZE 60000
Expand Down
63 changes: 63 additions & 0 deletions src/jit/hwintrinsiclistxarch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*****************************************************************************/
#ifndef HARDWARE_INTRINSIC
#error Define HARDWARE_INTRINSIC before including this file
#endif
/*****************************************************************************/

// clang-format off

#ifdef _TARGET_XARCH_
// Intrinsic ID Function name ISA
// SSE Intrinsics
HARDWARE_INTRINSIC(SSE_IsSupported, "get_IsSupported", SSE)

// SSE2 Intrinsics
HARDWARE_INTRINSIC(SSE2_IsSupported, "get_IsSupported", SSE2)

// SSE3 Intrinsics
HARDWARE_INTRINSIC(SSE3_IsSupported, "get_IsSupported", SSE3)

// SSSE3 Intrinsics
HARDWARE_INTRINSIC(SSSE3_IsSupported, "get_IsSupported", SSSE3)

// SSE41 Intrinsics
HARDWARE_INTRINSIC(SSE41_IsSupported, "get_IsSupported", SSE41)

// SSE42 Intrinsics
HARDWARE_INTRINSIC(SSE42_IsSupported, "get_IsSupported", SSE42)

// AVX Intrinsics
HARDWARE_INTRINSIC(AVX_IsSupported, "get_IsSupported", AVX)

// AVX2 Intrinsics
HARDWARE_INTRINSIC(AVX2_IsSupported, "get_IsSupported", AVX2)

// AES Intrinsics
HARDWARE_INTRINSIC(AES_IsSupported, "get_IsSupported", AES)

// BMI1 Intrinsics
HARDWARE_INTRINSIC(BMI1_IsSupported, "get_IsSupported", BMI1)

// BMI2 Intrinsics
HARDWARE_INTRINSIC(BMI2_IsSupported, "get_IsSupported", BMI2)

// FMA Intrinsics
HARDWARE_INTRINSIC(FMA_IsSupported, "get_IsSupported", FMA)

// LZCNT Intrinsics
HARDWARE_INTRINSIC(LZCNT_IsSupported, "get_IsSupported", LZCNT)

// PCLMULQDQ Intrinsics
HARDWARE_INTRINSIC(PCLMULQDQ_IsSupported, "get_IsSupported", PCLMULQDQ)

// POPCNT Intrinsics
HARDWARE_INTRINSIC(POPCNT_IsSupported, "get_IsSupported", POPCNT)
#endif

#undef HARDWARE_INTRINSIC

// clang-format on
Loading