Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d76ec49
Add Wasm32 WasmBase,PackedSimd instruction set definitions
adamperlin Jun 2, 2026
6c741ec
WIP Get Wasm JIT to compile with SIMD enabled
adamperlin Jun 3, 2026
f8573f3
More HARDWARE_INTRINSIC() stub definitions and ifdef fixes for Wasm SIMD
adamperlin Jun 3, 2026
ebc31df
WIP more changes to get TARGET_WASM to compile with FEATURE_HW_INTRIN…
adamperlin Jun 4, 2026
bf69792
More ifdef changes to morph, valuenum around arch-specific assumption…
adamperlin Jun 5, 2026
997d4cd
Last JIT changes to get clrjit to compile with TARGET_WASM && FEATURE…
adamperlin Jun 5, 2026
3d2d295
Update Wasm InstructionSetDesc to rename arch to WASM and declare Vec…
adamperlin Jun 5, 2026
4983314
jit-format
adamperlin Jun 5, 2026
3b9af51
Use separate NyiWasmSimd config option for NYI_WASM_SIMD()
adamperlin Jun 8, 2026
8a4d6e0
Merge branch 'main' of github.com:dotnet/runtime into adamperlin/wasm…
adamperlin Jun 8, 2026
b9cee29
Format fix in ReadyToRunInstructionSetHelper.cs
adamperlin Jun 8, 2026
602c7ba
Re-run instruction set generator, small compilation fixes from merge
adamperlin Jun 9, 2026
561a6e8
Fix asserts which came up during compilation of System.Private.CoreLi…
adamperlin Jun 9, 2026
f42576d
Add --codegenopt:JitNyiWasmSimdToR2RUnsupported=1 to crossgen invocat…
adamperlin Jun 9, 2026
c8ef653
jit-format
adamperlin Jun 9, 2026
92df7e7
Add assert to hwintrinsic.cpp, make flags uniform in hwintrinsiclistw…
adamperlin Jun 10, 2026
f7f01a7
Apply suggestions from code review
adamperlin Jun 10, 2026
eac9211
Fix clang build
adamperlin Jun 10, 2026
ff77001
Merge branch 'main' into adamperlin/wasm-simd-skeleton
adamperlin Jun 10, 2026
10d7de0
Review feedback and disable !HWIntrinsicInfo::IsInvalidNodeId assert …
adamperlin Jun 10, 2026
fd54819
Merge branch 'adamperlin/wasm-simd-skeleton' of github.com:adamperlin…
adamperlin Jun 10, 2026
94d8732
Fix GCC compiler warnings
adamperlin Jun 10, 2026
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
2 changes: 1 addition & 1 deletion src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
<CrossGenDllCmd>$(CrossGenDllCmd) -r:$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '*.dll'))</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) --targetarch:$(TargetArchitecture)</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(PublishReadyToRunContainerFormat)' != ''">$(CrossGenDllCmd) --obj-format:$(PublishReadyToRunContainerFormat)</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(PublishReadyToRunContainerFormat)' == 'wasm'">$(CrossGenDllCmd) --codegenopt:JitWasmNyiToR2RUnsupported=1</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(PublishReadyToRunContainerFormat)' == 'wasm'">$(CrossGenDllCmd) --codegenopt:JitWasmNyiToR2RUnsupported=1 --codegenopt:JitWasmSimdNyiToR2RUnsupported=1 </CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(UseComposite)' == 'true'">$(CrossGenDllCmd) --composite</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) --targetos:$(TargetOS)</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(UsingToolIbcOptimization)' != 'true' and '$(EnableNgenOptimization)' == 'true'">$(CrossGenDllCmd) -m:$(MergedMibcPath) --embed-pgo-data</CrossGenDllCmd>
Expand Down
25 changes: 25 additions & 0 deletions src/coreclr/inc/corinfoinstructionset.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ enum CORINFO_InstructionSet
InstructionSet_Zbb=3,
InstructionSet_Zbs=4,
#endif // TARGET_RISCV64
#ifdef TARGET_WASM
InstructionSet_WasmBase=1,
InstructionSet_PackedSimd=2,
InstructionSet_Vector128=3,
#endif // TARGET_WASM
#ifdef TARGET_AMD64
InstructionSet_X86Base=1,
InstructionSet_AVX=2,
Expand Down Expand Up @@ -284,6 +289,8 @@ struct CORINFO_InstructionSetFlags
#endif // TARGET_ARM64
#ifdef TARGET_RISCV64
#endif // TARGET_RISCV64
#ifdef TARGET_WASM
#endif // TARGET_WASM
#ifdef TARGET_AMD64
if (HasInstructionSet(InstructionSet_X86Base))
AddInstructionSet(InstructionSet_X86Base_X64);
Expand Down Expand Up @@ -448,6 +455,12 @@ inline CORINFO_InstructionSetFlags EnsureInstructionSetFlagsAreValid(CORINFO_Ins
if (resultflags.HasInstructionSet(InstructionSet_Zbs) && !resultflags.HasInstructionSet(InstructionSet_RiscV64Base))
resultflags.RemoveInstructionSet(InstructionSet_Zbs);
#endif // TARGET_RISCV64
#ifdef TARGET_WASM
if (resultflags.HasInstructionSet(InstructionSet_Vector128) && !resultflags.HasInstructionSet(InstructionSet_PackedSimd))
resultflags.RemoveInstructionSet(InstructionSet_Vector128);
if (resultflags.HasInstructionSet(InstructionSet_PackedSimd) && !resultflags.HasInstructionSet(InstructionSet_WasmBase))
resultflags.RemoveInstructionSet(InstructionSet_PackedSimd);
#endif // TARGET_WASM
#ifdef TARGET_AMD64
if (resultflags.HasInstructionSet(InstructionSet_X86Base) && !resultflags.HasInstructionSet(InstructionSet_X86Base_X64))
resultflags.RemoveInstructionSet(InstructionSet_X86Base);
Expand Down Expand Up @@ -742,6 +755,14 @@ inline const char *InstructionSetToString(CORINFO_InstructionSet instructionSet)
case InstructionSet_Zbs :
return "Zbs";
#endif // TARGET_RISCV64
#ifdef TARGET_WASM
case InstructionSet_WasmBase :
return "WasmBase";
case InstructionSet_PackedSimd :
return "PackedSimd";
case InstructionSet_Vector128 :
return "Vector128";
#endif // TARGET_WASM
#ifdef TARGET_AMD64
case InstructionSet_X86Base :
return "X86Base";
Expand Down Expand Up @@ -943,6 +964,10 @@ inline CORINFO_InstructionSet InstructionSetFromR2RInstructionSet(ReadyToRunInst
case READYTORUN_INSTRUCTION_Zbb: return InstructionSet_Zbb;
case READYTORUN_INSTRUCTION_Zbs: return InstructionSet_Zbs;
#endif // TARGET_RISCV64
#ifdef TARGET_WASM
case READYTORUN_INSTRUCTION_WasmBase: return InstructionSet_WasmBase;
case READYTORUN_INSTRUCTION_PackedSimd: return InstructionSet_PackedSimd;
#endif // TARGET_WASM
#ifdef TARGET_AMD64
case READYTORUN_INSTRUCTION_X86Base: return InstructionSet_X86Base;
case READYTORUN_INSTRUCTION_Sse: return InstructionSet_X86Base;
Expand Down
10 changes: 5 additions & 5 deletions src/coreclr/inc/jiteeversionguid.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@

#include <minipal/guid.h>

constexpr GUID JITEEVersionIdentifier = { /* 59df85b8-c0fd-4e40-aea1-68cb2cd916cc */
0x59df85b8,
0xc0fd,
0x4e40,
{0xae, 0xa1, 0x68, 0xcb, 0x2c, 0xd9, 0x16, 0xcc}
constexpr GUID JITEEVersionIdentifier = { /* bc67df92-da28-4e13-ba8d-4abcb0fcb75f */
0xbc67df92,
0xda28,
0x4e13,
{0xba, 0x8d, 0x4a, 0xbc, 0xb0, 0xfc, 0xb7, 0x5f}
};

#endif // JIT_EE_VERSIONING_GUID_H
2 changes: 2 additions & 0 deletions src/coreclr/inc/readytoruninstructionset.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ enum ReadyToRunInstructionSet
READYTORUN_INSTRUCTION_SveAes=88,
READYTORUN_INSTRUCTION_SveSha3=89,
READYTORUN_INSTRUCTION_SveSm4=90,
READYTORUN_INSTRUCTION_WasmBase=91,
READYTORUN_INSTRUCTION_PackedSimd=92,

};

Expand Down
9 changes: 9 additions & 0 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ function(create_standalone_jit)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_HW_INTRINSICS)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_MASKED_HW_INTRINSICS)
endif ()

if (TARGETDETAILS_ARCH STREQUAL "wasm")
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_SIMD)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_HW_INTRINSICS)
endif ()
endfunction()

if (CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_I386)
Expand Down Expand Up @@ -305,9 +310,12 @@ set( JIT_WASM_SOURCES
codegenwasm.cpp
emitwasm.cpp
fgwasm.cpp
hwintrinsicwasm.cpp
hwintrinsiccodegenwasm.cpp
lowerwasm.cpp
regallocwasm.cpp
registeropswasm.cpp
simd.cpp
targetwasm.cpp
unwindwasm.cpp
)
Expand Down Expand Up @@ -501,6 +509,7 @@ set( JIT_WASM_HEADERS
instrswasm.h
registerwasm.h
fgwasm.h
hwintrinsiclistwasm.h
)

set ( JITSHARED_SOURCES
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/jit/abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ var_types ABIPassingSegment::GetRegisterType() const
return TYP_FLOAT;
case 8:
return TYP_DOUBLE;
#if defined(FEATURE_SIMD) && defined(TARGET_WASM)
case 12:
#endif
#ifdef FEATURE_SIMD
case 16:
return TYP_SIMD16;
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ bool IntegralRange::Contains(int64_t value) const
case NI_ArmBase_LeadingZeroCount:
case NI_ArmBase_Arm64_LeadingZeroCount:
case NI_ArmBase_Arm64_LeadingSignCount:
#elif defined(TARGET_WASM)
// TODO-WASM: See if we can support CTZ/CLZ ranges here
#else
#error Unsupported platform
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ class CodeGen final : public CodeGenInterface
void genSetRegToConst(regNumber targetReg, var_types targetType, GenTree* tree);
#if defined(FEATURE_SIMD)
void genSetRegToConst(regNumber targetReg, var_types targetType, simd_t* val);
#endif
#if defined(FEATURE_SIMD) && defined(FEATURE_MASKED_HW_INTRINSICS)
void genSetRegToConst(regNumber targetReg, var_types targetType, simdmask_t* val);
#endif
void genLoadLocalIntoReg(regNumber targetReg, unsigned lclNum);
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,6 @@ void CodeGen::genConsumeOperands(GenTreeOp* tree)
}
}

#ifndef TARGET_WASM
#if defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS)
//------------------------------------------------------------------------
// genConsumeOperands: Do liveness update for the operands of a multi-operand node,
Expand All @@ -1840,6 +1839,7 @@ void CodeGen::genConsumeMultiOpOperands(GenTreeMultiOp* tree)
}
#endif // defined(FEATURE_SIMD) || defined(FEATURE_HW_INTRINSICS)

#ifndef TARGET_WASM
//------------------------------------------------------------------------
// genConsumePutStructArgStk: Do liveness update for the operands of a PutArgStk node.
// Also loads in the right register the addresses of the
Expand Down
12 changes: 9 additions & 3 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3992,9 +3992,12 @@ class Compiler

#if defined(FEATURE_HW_INTRINSICS)
GenTree* gtFoldExprHWIntrinsic(GenTreeHWIntrinsic* tree);
GenTreeMskCon* gtFoldExprConvertVecCnsToMask(GenTreeHWIntrinsic* tree, GenTreeVecCon* vecCon);
#endif // FEATURE_HW_INTRINSICS

#if defined(FEATURE_HW_INTRINSICS) && defined(FEATURE_MASKED_HW_INTRINSICS)
GenTreeMskCon* gtFoldExprConvertVecCnsToMask(GenTreeHWIntrinsic* tree, GenTreeVecCon* vecCon);
#endif // FEATURE_MASKED_HW_INTRINSICS

// Options to control behavior of gtTryRemoveBoxUpstreamEffects
enum BoxRemovalOptions
{
Expand Down Expand Up @@ -10215,6 +10218,9 @@ class Compiler

return FP_REGSIZE_BYTES;
}
#elif defined(TARGET_WASM)
// TODO-WASM: Verify if we need a more complicated condition here
return FP_REGSIZE_BYTES;
#else
assert(!"getVectorTByteLength() unimplemented on target arch");
unreached();
Expand Down Expand Up @@ -10245,7 +10251,7 @@ class Compiler
{
return XMM_REGSIZE_BYTES;
}
#elif defined(TARGET_ARM64)
#elif defined(TARGET_ARM64) || defined(TARGET_WASM)
return FP_REGSIZE_BYTES;
#else
assert(!"getMaxVectorByteLength() unimplemented on target arch");
Expand Down Expand Up @@ -10343,7 +10349,7 @@ class Compiler

// Return 0 if size is even less than XMM, otherwise - XMM
return (size >= XMM_REGSIZE_BYTES) ? XMM_REGSIZE_BYTES : 0;
#elif defined(TARGET_ARM64)
#elif defined(TARGET_ARM64) || defined(TARGET_WASM)
assert(getMaxVectorByteLength() == FP_REGSIZE_BYTES);
return (size >= FP_REGSIZE_BYTES) ? FP_REGSIZE_BYTES : 0;
#else
Expand Down
10 changes: 10 additions & 0 deletions src/coreclr/jit/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line);
#define NYI_LOONGARCH64(msg) do { } while (0)
#define NYI_RISCV64(msg) do { } while (0)
#define NYI_WASM(msg) do { } while (0)
#define NYI_WASM_SIMD(msg) do { } while (0)

#elif defined(TARGET_X86)

Expand All @@ -179,6 +180,7 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line);
#define NYI_LOONGARCH64(msg) do { } while (0)
#define NYI_RISCV64(msg) do { } while (0)
#define NYI_WASM(msg) do { } while (0)
#define NYI_WASM_SIMD(msg) do { } while (0)

#elif defined(TARGET_ARM)

Expand All @@ -189,6 +191,7 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line);
#define NYI_LOONGARCH64(msg) do { } while (0)
#define NYI_RISCV64(msg) do { } while (0)
#define NYI_WASM(msg) do { } while (0)
#define NYI_WASM_SIMD(msg) do { } while (0)

#elif defined(TARGET_ARM64)

Expand All @@ -199,6 +202,7 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line);
#define NYI_LOONGARCH64(msg) do { } while (0)
#define NYI_RISCV64(msg) do { } while (0)
#define NYI_WASM(msg) do { } while (0)
#define NYI_WASM_SIMD(msg) do { } while (0)

#elif defined(TARGET_LOONGARCH64)
#define NYI_AMD64(msg) do { } while (0)
Expand All @@ -208,6 +212,7 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line);
#define NYI_LOONGARCH64(msg) NYIRAW("NYI_LOONGARCH64: " msg)
#define NYI_RISCV64(msg) do { } while (0)
#define NYI_WASM(msg) do { } while (0)
#define NYI_WASM_SIMD(msg) do { } while (0)

#elif defined(TARGET_RISCV64)
#define NYI_AMD64(msg) do { } while (0)
Expand All @@ -217,6 +222,7 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line);
#define NYI_LOONGARCH64(msg) do { } while (0)
#define NYI_RISCV64(msg) NYIRAW("NYI_RISCV64: " msg)
#define NYI_WASM(msg) do { } while (0)
#define NYI_WASM_SIMD(msg) do { } while (0)

#elif defined(TARGET_WASM)
#define NYI_AMD64(msg) do { } while (0)
Expand All @@ -230,6 +236,10 @@ extern void notYetImplemented(const char* msg, const char* file, unsigned line);
{ JITDUMP("NYI_WASM: " msg); implReadyToRunUnsupported(); } \
else { NYIRAW("NYI_WASM: " msg); } } while (0)

#define NYI_WASM_SIMD(msg) do { if (JitConfig.JitWasmSimdNyiToR2RUnsupported() > 0) \
{ JITDUMP("NYI_WASM_SIMD: " msg); implReadyToRunUnsupported(); } \
else { NYIRAW("NYI_WASM_SIMD: " msg); } } while (0)

#else

#error "Unknown platform, not x86, ARM, LOONGARCH64, AMD64, or RISCV64?"
Expand Down
Loading
Loading