| ... | @@ -2836,14 +2836,44 @@ pub const Feature = packed struct(u8) { | ... | @@ -2836,14 +2836,44 @@ pub const Feature = packed struct(u8) { |
| 2836 | @"shared-mem", | 2836 | @"shared-mem", |
| 2837 | | 2837 | |
| 2838 | pub fn fromCpuFeature(feature: std.Target.wasm.Feature) Tag { | 2838 | pub fn fromCpuFeature(feature: std.Target.wasm.Feature) Tag { |
| 2839 | return @enumFromInt(@intFromEnum(feature)); | 2839 | return switch (feature) { |
| | 2840 | .atomics => .atomics, |
| | 2841 | .bulk_memory => .@"bulk-memory", |
| | 2842 | .exception_handling => .@"exception-handling", |
| | 2843 | .extended_const => .@"extended-const", |
| | 2844 | .half_precision => .@"half-precision", |
| | 2845 | .multimemory => .multimemory, |
| | 2846 | .multivalue => .multivalue, |
| | 2847 | .mutable_globals => .@"mutable-globals", |
| | 2848 | .nontrapping_bulk_memory_len0 => .@"nontrapping-bulk-memory-len0", // Zig extension. |
| | 2849 | .nontrapping_fptoint => .@"nontrapping-fptoint", |
| | 2850 | .reference_types => .@"reference-types", |
| | 2851 | .relaxed_simd => .@"relaxed-simd", |
| | 2852 | .sign_ext => .@"sign-ext", |
| | 2853 | .simd128 => .simd128, |
| | 2854 | .tail_call => .@"tail-call", |
| | 2855 | }; |
| 2840 | } | 2856 | } |
| 2841 | | 2857 | |
| 2842 | pub fn toCpuFeature(tag: Tag) ?std.Target.wasm.Feature { | 2858 | pub fn toCpuFeature(tag: Tag) ?std.Target.wasm.Feature { |
| 2843 | return if (@intFromEnum(tag) < @typeInfo(std.Target.wasm.Feature).@"enum".fields.len) | 2859 | return switch (tag) { |
| 2844 | @enumFromInt(@intFromEnum(tag)) | 2860 | .atomics => .atomics, |
| 2845 | else | 2861 | .@"bulk-memory" => .bulk_memory, |
| 2846 | null; | 2862 | .@"exception-handling" => .exception_handling, |
| | 2863 | .@"extended-const" => .extended_const, |
| | 2864 | .@"half-precision" => .half_precision, |
| | 2865 | .multimemory => .multimemory, |
| | 2866 | .multivalue => .multivalue, |
| | 2867 | .@"mutable-globals" => .mutable_globals, |
| | 2868 | .@"nontrapping-bulk-memory-len0" => .nontrapping_bulk_memory_len0, // Zig extension. |
| | 2869 | .@"nontrapping-fptoint" => .nontrapping_fptoint, |
| | 2870 | .@"reference-types" => .reference_types, |
| | 2871 | .@"relaxed-simd" => .relaxed_simd, |
| | 2872 | .@"sign-ext" => .sign_ext, |
| | 2873 | .simd128 => .simd128, |
| | 2874 | .@"tail-call" => .tail_call, |
| | 2875 | .@"shared-mem" => null, // Linker-only feature. |
| | 2876 | }; |
| 2847 | } | 2877 | } |
| 2848 | | 2878 | |
| 2849 | pub const format = @compileError("use @tagName instead"); | 2879 | pub const format = @compileError("use @tagName instead"); |