@@ -59,6 +59,9 @@ public enum InstructionSet
5959 RiscV64_Zba = InstructionSet_RiscV64 . Zba ,
6060 RiscV64_Zbb = InstructionSet_RiscV64 . Zbb ,
6161 RiscV64_Zbs = InstructionSet_RiscV64 . Zbs ,
62+ Wasm32_WasmBase = InstructionSet_Wasm32 . WasmBase ,
63+ Wasm32_PackedSimd = InstructionSet_Wasm32 . PackedSimd ,
64+ Wasm32_Vector128 = InstructionSet_Wasm32 . Vector128 ,
6265 X64_X86Base = InstructionSet_X64 . X86Base ,
6366 X64_AVX = InstructionSet_X64 . AVX ,
6467 X64_AVX2 = InstructionSet_X64 . AVX2 ,
@@ -206,6 +209,15 @@ public enum InstructionSet_RiscV64
206209 Zbs = 4 ,
207210 }
208211
212+ public enum InstructionSet_Wasm32
213+ {
214+ ILLEGAL = InstructionSet . ILLEGAL ,
215+ NONE = InstructionSet . NONE ,
216+ WasmBase = 1 ,
217+ PackedSimd = 2 ,
218+ Vector128 = 3 ,
219+ }
220+
209221 public enum InstructionSet_X64
210222 {
211223 ILLEGAL = InstructionSet . ILLEGAL ,
@@ -319,6 +331,8 @@ public unsafe struct InstructionSetFlags : IEnumerable<InstructionSet>
319331
320332 public IEnumerable < InstructionSet_RiscV64 > RiscV64Flags => this . Select ( ( x ) => ( InstructionSet_RiscV64 ) x ) ;
321333
334+ public IEnumerable < InstructionSet_Wasm32 > Wasm32Flags => this . Select ( ( x ) => ( InstructionSet_Wasm32 ) x ) ;
335+
322336 public IEnumerable < InstructionSet_X64 > X64Flags => this . Select ( ( x ) => ( InstructionSet_X64 ) x ) ;
323337
324338 public IEnumerable < InstructionSet_X86 > X86Flags => this . Select ( ( x ) => ( InstructionSet_X86 ) x ) ;
@@ -438,6 +452,12 @@ public static InstructionSet ConvertToImpliedInstructionSetForVectorInstructionS
438452 case InstructionSet . ARM64_VectorT : return InstructionSet . ARM64_Sve ;
439453 }
440454 break ;
455+ case TargetArchitecture . Wasm32 :
456+ switch ( input )
457+ {
458+ case InstructionSet . Wasm32_Vector128 : return InstructionSet . Wasm32_PackedSimd ;
459+ }
460+ break ;
441461 case TargetArchitecture . X64 :
442462 switch ( input )
443463 {
@@ -581,6 +601,13 @@ public static InstructionSetFlags ExpandInstructionSetByImplicationHelper(Target
581601 resultflags . AddInstructionSet ( InstructionSet . RiscV64_RiscV64Base ) ;
582602 break ;
583603
604+ case TargetArchitecture . Wasm32 :
605+ if ( resultflags . HasInstructionSet ( InstructionSet . Wasm32_Vector128 ) )
606+ resultflags . AddInstructionSet ( InstructionSet . Wasm32_PackedSimd ) ;
607+ if ( resultflags . HasInstructionSet ( InstructionSet . Wasm32_PackedSimd ) )
608+ resultflags . AddInstructionSet ( InstructionSet . Wasm32_WasmBase ) ;
609+ break ;
610+
584611 case TargetArchitecture . X64 :
585612 if ( resultflags . HasInstructionSet ( InstructionSet . X64_X86Base ) )
586613 resultflags . AddInstructionSet ( InstructionSet . X64_X86Base_X64 ) ;
@@ -879,6 +906,13 @@ private static InstructionSetFlags ExpandInstructionSetByReverseImplicationHelpe
879906 resultflags . AddInstructionSet ( InstructionSet . RiscV64_Zbs ) ;
880907 break ;
881908
909+ case TargetArchitecture . Wasm32 :
910+ if ( resultflags . HasInstructionSet ( InstructionSet . Wasm32_PackedSimd ) )
911+ resultflags . AddInstructionSet ( InstructionSet . Wasm32_Vector128 ) ;
912+ if ( resultflags . HasInstructionSet ( InstructionSet . Wasm32_WasmBase ) )
913+ resultflags . AddInstructionSet ( InstructionSet . Wasm32_PackedSimd ) ;
914+ break ;
915+
882916 case TargetArchitecture . X64 :
883917 if ( resultflags . HasInstructionSet ( InstructionSet . X64_X86Base_X64 ) )
884918 resultflags . AddInstructionSet ( InstructionSet . X64_X86Base ) ;
@@ -1124,6 +1158,12 @@ public static IEnumerable<InstructionSetInfo> ArchitectureToValidInstructionSets
11241158 yield return new InstructionSetInfo ( "zbs" , "" , InstructionSet . RiscV64_Zbs , true ) ;
11251159 break ;
11261160
1161+ case TargetArchitecture . Wasm32 :
1162+ yield return new InstructionSetInfo ( "base" , "WasmBase" , InstructionSet . Wasm32_WasmBase , true ) ;
1163+ yield return new InstructionSetInfo ( "simd128" , "PackedSimd" , InstructionSet . Wasm32_PackedSimd , true ) ;
1164+ yield return new InstructionSetInfo ( "Vector128" , "" , InstructionSet . Wasm32_Vector128 , false ) ;
1165+ break ;
1166+
11271167 case TargetArchitecture . X64 :
11281168 yield return new InstructionSetInfo ( "base" , "X86Base" , InstructionSet . X64_X86Base , true ) ;
11291169 yield return new InstructionSetInfo ( "base" , "Sse" , InstructionSet . X64_X86Base , true ) ;
@@ -1315,6 +1355,9 @@ public void Set64BitInstructionSetVariants(TargetArchitecture architecture)
13151355 case TargetArchitecture . RiscV64 :
13161356 break ;
13171357
1358+ case TargetArchitecture . Wasm32 :
1359+ break ;
1360+
13181361 case TargetArchitecture . X64 :
13191362 if ( HasInstructionSet ( InstructionSet . X64_X86Base ) )
13201363 AddInstructionSet ( InstructionSet . X64_X86Base_X64 ) ;
@@ -1381,6 +1424,9 @@ public void Set64BitInstructionSetVariantsUnconditionally(TargetArchitecture arc
13811424 case TargetArchitecture . RiscV64 :
13821425 break ;
13831426
1427+ case TargetArchitecture . Wasm32 :
1428+ break ;
1429+
13841430 case TargetArchitecture . X64 :
13851431 AddInstructionSet ( InstructionSet . X64_X86Base_X64 ) ;
13861432 AddInstructionSet ( InstructionSet . X64_AVX_X64 ) ;
@@ -1449,6 +1495,10 @@ public static InstructionSet LookupPlatformIntrinsicInstructionSet(TargetArchite
14491495 platformIntrinsicNamespace = "System.Runtime.Intrinsics.Arm" ;
14501496 break ;
14511497
1498+ case TargetArchitecture . Wasm32 :
1499+ platformIntrinsicNamespace = "System.Runtime.Intrinsics.Wasm" ;
1500+ break ;
1501+
14521502 case TargetArchitecture . X64 :
14531503 platformIntrinsicNamespace = "System.Runtime.Intrinsics.X86" ;
14541504 break ;
@@ -1566,6 +1616,18 @@ public static InstructionSet LookupPlatformIntrinsicInstructionSet(TargetArchite
15661616 case TargetArchitecture . RiscV64 :
15671617 switch ( typeName )
15681618 {
1619+ default :
1620+ return InstructionSet . ILLEGAL ;
1621+ }
1622+ case TargetArchitecture . Wasm32 :
1623+ switch ( typeName )
1624+ {
1625+ case "WasmBase" :
1626+ return InstructionSet . Wasm32_WasmBase ;
1627+
1628+ case "PackedSimd" :
1629+ return InstructionSet . Wasm32_PackedSimd ;
1630+
15691631 default :
15701632 return InstructionSet . ILLEGAL ;
15711633 }
@@ -2243,6 +2305,26 @@ public static IEnumerable<MetadataType> LookupPlatformIntrinsicTypes(TypeSystemC
22432305 }
22442306 break ;
22452307
2308+ case ( InstructionSet . Wasm32_WasmBase , TargetArchitecture . Wasm32 ) :
2309+ {
2310+ var type = context . SystemModule . GetType ( "System.Runtime.Intrinsics.Wasm"u8 , "WasmBase"u8 , false ) ;
2311+ if ( type != null )
2312+ {
2313+ yield return type ;
2314+ }
2315+ }
2316+ break ;
2317+
2318+ case ( InstructionSet . Wasm32_PackedSimd , TargetArchitecture . Wasm32 ) :
2319+ {
2320+ var type = context . SystemModule . GetType ( "System.Runtime.Intrinsics.Wasm"u8 , "PackedSimd"u8 , false ) ;
2321+ if ( type != null )
2322+ {
2323+ yield return type ;
2324+ }
2325+ }
2326+ break ;
2327+
22462328 case ( InstructionSet . X64_X86Base , TargetArchitecture . X64 ) :
22472329 case ( InstructionSet . X64_X86Base_X64 , TargetArchitecture . X64 ) :
22482330 {
0 commit comments