╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ target.zig ───────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭ find file ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ ╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │ │ │http│ ssh │ │ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
868 } 869 870 pub fn supportsThreads(target: *const std.Target, backend: std.lang.CompilerBackend) bool { 871 _ = target; 872 return switch (backend) { 873 .stage2_aarch64 => false, 874 .stage2_loongarch => false, 875 else => true, 876 }; 877 } 878 879 pub fn libcFloatPrefix(float_bits: u16) []const u8 { 880 return switch (float_bits) { 881 16, 80 => "__", 882 32, 64, 128 => "", 883 else => unreachable, 884 }; 885 } 886 887 pub fn libcFloatSuffix(float_bits: u16) []const u8 { 888 return switch (float_bits) { 889 16 => "h", // Non-standard 890 32 => "f", 891 64 => "", 892 80 => "x", // Non-standard 893 128 => "f128", 894 else => unreachable, 895 }; 896 } 897 898 pub fn compilerRtFloatAbbrev(target: *const std.Target, float_bits: u16) []const u8 { 899 return switch (float_bits) { 900 16 => "h", 901 32 => "s", 902 64 => "d", 903 80 => "x", 904 128 => if (target.cpu.arch.isPowerPC()) "k" else "t", 905 else => unreachable, 906 }; 907 } 908 909 pub fn compilerRtIntAbbrev(bits: u16) []const u8 { 910 return switch (bits) { 911 16 => "h", 912 32 => "s", 913 64 => "d", 914 128 => "t", 915 else => unreachable, 916 }; 917 } 918 919 pub fn fnCallConvAllowsZigTypes(cc: std.lang.CallingConvention) bool { 920 return switch (cc) { 921 .auto, .async, .@"inline" => true, 922 // For now we want to authorize PTX kernel to use zig objects, even if 923 // we end up exposing the ABI. The goal is to experiment with more 924 // integrated CPU/GPU code. 925 .nvptx_kernel => true, 926 else => false, 927 }; 928 } 929 930 pub fn zigBackend(target: *const std.Target, use_llvm: bool) std.lang.CompilerBackend { 931 if (use_llvm) return .stage2_llvm; 932 if (target.ofmt == .c) return .stage2_c; 933 return switch (target.cpu.arch) { 934 .aarch64, .aarch64_be => .stage2_aarch64, 935 .arm, .armeb, .thumb, .thumbeb => .stage2_arm, 936 .loongarch32, .loongarch64 => .stage2_loongarch, 937 .powerpc, .powerpcle, .powerpc64, .powerpc64le => .stage2_powerpc, 938 .riscv64 => .stage2_riscv64, 939 .sparc64 => .stage2_sparc64, 940 .spirv32, .spirv64 => .stage2_spirv, 941 .wasm32, .wasm64 => .stage2_wasm, 942 .x86 => .stage2_x86, 943 .x86_64 => .stage2_x86_64, 944 .spork8 => .zsf_spork8, 945 else => .other, 946 }; 947 } 948 949 pub inline fn backendSupportsFeature(backend: std.lang.CompilerBackend, comptime feature: Feature) bool { 950 return switch (feature) { 951 .panic_fn => switch (backend) { 952 .stage2_aarch64, 953 .stage2_c, 954 .stage2_llvm, 955 .stage2_x86_64, 956 .stage2_riscv64, 957 .stage2_wasm, 958 => true, 959 else => false, 960 }, 961 .error_return_trace => switch (backend) { 962 .stage2_llvm, .stage2_x86_64 => true, 963 else => false, 964 }, 965 .is_named_enum_value => switch (backend) { 966 .stage2_llvm, .stage2_x86_64, .stage2_wasm => true, 967 else => false, 968 }, 969 .error_set_has_value => switch (backend) { 970 .stage2_llvm, .stage2_wasm, .stage2_x86_64 => true, 971 else => false, 972 }, 973 .field_reordering => switch (backend) { 974 .stage2_aarch64, .stage2_c, .stage2_llvm, .stage2_loongarch, .stage2_x86_64, .stage2_wasm => true, 975 else => false, 976 }, 977 .separate_thread => switch (backend) { 978 // Supports a separate thread but does not support N separate 979 // threads because they would all just be locking the same mutex to 980 // protect Builder. 981 .stage2_llvm => false, 982 // Please do not make any more exceptions. Backends must support 983 // being run in a separate thread from now on. 984 else => true, 985 }, 986 }; 987 } 988