| author | |
| committer | |
| log | 4a0d64300bd9ab1a8c35c634856396e3413200f1 |
| tree | f545e425f612b1bfbcbe69f388b595df434accf9 |
| parent | c81ae52ee0b2e952f8ed9c5c6517af8182bb09c1 |
Putting functions in this file will create functions like
`llvm.function`, and the compiler thinks these are llvm intrinsics.7 files changed, 147 insertions(+), 147 deletions(-)
CMakeLists.txt+1-1| ... | ... | @@ -549,7 +549,7 @@ set(ZIG_STAGE2_SOURCES |
| 549 | 549 | "${CMAKE_SOURCE_DIR}/src/link/cbe.h" |
| 550 | 550 | "${CMAKE_SOURCE_DIR}/src/link/msdos-stub.bin" |
| 551 | 551 | "${CMAKE_SOURCE_DIR}/src/liveness.zig" |
| 552 | "${CMAKE_SOURCE_DIR}/src/llvm.zig" | |
| 552 | "${CMAKE_SOURCE_DIR}/src/llvm_bindings.zig" | |
| 553 | 553 | "${CMAKE_SOURCE_DIR}/src/main.zig" |
| 554 | 554 | "${CMAKE_SOURCE_DIR}/src/mingw.zig" |
| 555 | 555 | "${CMAKE_SOURCE_DIR}/src/musl.zig" |
src/link.zig+1-1| ... | ... | @@ -567,7 +567,7 @@ pub const File = struct { |
| 567 | 567 | std.debug.print("\n", .{}); |
| 568 | 568 | } |
| 569 | 569 | |
| 570 | const llvm = @import("llvm.zig"); | |
| 570 | const llvm = @import("llvm_bindings.zig"); | |
| 571 | 571 | const os_type = @import("target.zig").osToLLVM(base.options.target.os.tag); |
| 572 | 572 | const bad = llvm.WriteArchive(full_out_path_z, object_files.items.ptr, object_files.items.len, os_type); |
| 573 | 573 | if (bad) return error.UnableToWriteArchive; |
src/llvm.zig deleted-140| ... | ... | @@ -1,140 +0,0 @@ |
| 1 | //! We do this instead of @cImport because the self-hosted compiler is easier | |
| 2 | //! to bootstrap if it does not depend on translate-c. | |
| 3 | ||
| 4 | extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | |
| 5 | extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | |
| 6 | extern fn ZigLLDLinkMachO(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | |
| 7 | extern fn ZigLLDLinkWasm(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | |
| 8 | ||
| 9 | pub const LinkCOFF = ZigLLDLinkCOFF; | |
| 10 | pub const LinkELF = ZigLLDLinkELF; | |
| 11 | pub const LinkMachO = ZigLLDLinkMachO; | |
| 12 | pub const LinkWasm = ZigLLDLinkWasm; | |
| 13 | ||
| 14 | pub const ObjectFormatType = extern enum(c_int) { | |
| 15 | Unknown, | |
| 16 | COFF, | |
| 17 | ELF, | |
| 18 | MachO, | |
| 19 | Wasm, | |
| 20 | XCOFF, | |
| 21 | }; | |
| 22 | ||
| 23 | pub const GetHostCPUName = LLVMGetHostCPUName; | |
| 24 | extern fn LLVMGetHostCPUName() ?[*:0]u8; | |
| 25 | ||
| 26 | pub const GetNativeFeatures = ZigLLVMGetNativeFeatures; | |
| 27 | extern fn ZigLLVMGetNativeFeatures() ?[*:0]u8; | |
| 28 | ||
| 29 | pub const WriteArchive = ZigLLVMWriteArchive; | |
| 30 | extern fn ZigLLVMWriteArchive( | |
| 31 | archive_name: [*:0]const u8, | |
| 32 | file_names_ptr: [*]const [*:0]const u8, | |
| 33 | file_names_len: usize, | |
| 34 | os_type: OSType, | |
| 35 | ) bool; | |
| 36 | ||
| 37 | pub const OSType = extern enum(c_int) { | |
| 38 | UnknownOS = 0, | |
| 39 | Ananas = 1, | |
| 40 | CloudABI = 2, | |
| 41 | Darwin = 3, | |
| 42 | DragonFly = 4, | |
| 43 | FreeBSD = 5, | |
| 44 | Fuchsia = 6, | |
| 45 | IOS = 7, | |
| 46 | KFreeBSD = 8, | |
| 47 | Linux = 9, | |
| 48 | Lv2 = 10, | |
| 49 | MacOSX = 11, | |
| 50 | NetBSD = 12, | |
| 51 | OpenBSD = 13, | |
| 52 | Solaris = 14, | |
| 53 | Win32 = 15, | |
| 54 | Haiku = 16, | |
| 55 | Minix = 17, | |
| 56 | RTEMS = 18, | |
| 57 | NaCl = 19, | |
| 58 | CNK = 20, | |
| 59 | AIX = 21, | |
| 60 | CUDA = 22, | |
| 61 | NVCL = 23, | |
| 62 | AMDHSA = 24, | |
| 63 | PS4 = 25, | |
| 64 | ELFIAMCU = 26, | |
| 65 | TvOS = 27, | |
| 66 | WatchOS = 28, | |
| 67 | Mesa3D = 29, | |
| 68 | Contiki = 30, | |
| 69 | AMDPAL = 31, | |
| 70 | HermitCore = 32, | |
| 71 | Hurd = 33, | |
| 72 | WASI = 34, | |
| 73 | Emscripten = 35, | |
| 74 | }; | |
| 75 | ||
| 76 | pub const ArchType = extern enum(c_int) { | |
| 77 | UnknownArch = 0, | |
| 78 | arm = 1, | |
| 79 | armeb = 2, | |
| 80 | aarch64 = 3, | |
| 81 | aarch64_be = 4, | |
| 82 | aarch64_32 = 5, | |
| 83 | arc = 6, | |
| 84 | avr = 7, | |
| 85 | bpfel = 8, | |
| 86 | bpfeb = 9, | |
| 87 | hexagon = 10, | |
| 88 | mips = 11, | |
| 89 | mipsel = 12, | |
| 90 | mips64 = 13, | |
| 91 | mips64el = 14, | |
| 92 | msp430 = 15, | |
| 93 | ppc = 16, | |
| 94 | ppc64 = 17, | |
| 95 | ppc64le = 18, | |
| 96 | r600 = 19, | |
| 97 | amdgcn = 20, | |
| 98 | riscv32 = 21, | |
| 99 | riscv64 = 22, | |
| 100 | sparc = 23, | |
| 101 | sparcv9 = 24, | |
| 102 | sparcel = 25, | |
| 103 | systemz = 26, | |
| 104 | tce = 27, | |
| 105 | tcele = 28, | |
| 106 | thumb = 29, | |
| 107 | thumbeb = 30, | |
| 108 | x86 = 31, | |
| 109 | x86_64 = 32, | |
| 110 | xcore = 33, | |
| 111 | nvptx = 34, | |
| 112 | nvptx64 = 35, | |
| 113 | le32 = 36, | |
| 114 | le64 = 37, | |
| 115 | amdil = 38, | |
| 116 | amdil64 = 39, | |
| 117 | hsail = 40, | |
| 118 | hsail64 = 41, | |
| 119 | spir = 42, | |
| 120 | spir64 = 43, | |
| 121 | kalimba = 44, | |
| 122 | shave = 45, | |
| 123 | lanai = 46, | |
| 124 | wasm32 = 47, | |
| 125 | wasm64 = 48, | |
| 126 | renderscript32 = 49, | |
| 127 | renderscript64 = 50, | |
| 128 | ve = 51, | |
| 129 | }; | |
| 130 | ||
| 131 | pub const ParseCommandLineOptions = ZigLLVMParseCommandLineOptions; | |
| 132 | extern fn ZigLLVMParseCommandLineOptions(argc: usize, argv: [*]const [*:0]const u8) void; | |
| 133 | ||
| 134 | pub const WriteImportLibrary = ZigLLVMWriteImportLibrary; | |
| 135 | extern fn ZigLLVMWriteImportLibrary( | |
| 136 | def_path: [*:0]const u8, | |
| 137 | arch: ArchType, | |
| 138 | output_lib_path: [*c]const u8, | |
| 139 | kill_at: bool, | |
| 140 | ) bool; |
src/llvm_bindings.zig created+140| ... | ... | @@ -0,0 +1,140 @@ |
| 1 | //! We do this instead of @cImport because the self-hosted compiler is easier | |
| 2 | //! to bootstrap if it does not depend on translate-c. | |
| 3 | ||
| 4 | extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | |
| 5 | extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | |
| 6 | extern fn ZigLLDLinkMachO(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | |
| 7 | extern fn ZigLLDLinkWasm(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int; | |
| 8 | ||
| 9 | pub const LinkCOFF = ZigLLDLinkCOFF; | |
| 10 | pub const LinkELF = ZigLLDLinkELF; | |
| 11 | pub const LinkMachO = ZigLLDLinkMachO; | |
| 12 | pub const LinkWasm = ZigLLDLinkWasm; | |
| 13 | ||
| 14 | pub const ObjectFormatType = extern enum(c_int) { | |
| 15 | Unknown, | |
| 16 | COFF, | |
| 17 | ELF, | |
| 18 | MachO, | |
| 19 | Wasm, | |
| 20 | XCOFF, | |
| 21 | }; | |
| 22 | ||
| 23 | pub const GetHostCPUName = LLVMGetHostCPUName; | |
| 24 | extern fn LLVMGetHostCPUName() ?[*:0]u8; | |
| 25 | ||
| 26 | pub const GetNativeFeatures = ZigLLVMGetNativeFeatures; | |
| 27 | extern fn ZigLLVMGetNativeFeatures() ?[*:0]u8; | |
| 28 | ||
| 29 | pub const WriteArchive = ZigLLVMWriteArchive; | |
| 30 | extern fn ZigLLVMWriteArchive( | |
| 31 | archive_name: [*:0]const u8, | |
| 32 | file_names_ptr: [*]const [*:0]const u8, | |
| 33 | file_names_len: usize, | |
| 34 | os_type: OSType, | |
| 35 | ) bool; | |
| 36 | ||
| 37 | pub const OSType = extern enum(c_int) { | |
| 38 | UnknownOS = 0, | |
| 39 | Ananas = 1, | |
| 40 | CloudABI = 2, | |
| 41 | Darwin = 3, | |
| 42 | DragonFly = 4, | |
| 43 | FreeBSD = 5, | |
| 44 | Fuchsia = 6, | |
| 45 | IOS = 7, | |
| 46 | KFreeBSD = 8, | |
| 47 | Linux = 9, | |
| 48 | Lv2 = 10, | |
| 49 | MacOSX = 11, | |
| 50 | NetBSD = 12, | |
| 51 | OpenBSD = 13, | |
| 52 | Solaris = 14, | |
| 53 | Win32 = 15, | |
| 54 | Haiku = 16, | |
| 55 | Minix = 17, | |
| 56 | RTEMS = 18, | |
| 57 | NaCl = 19, | |
| 58 | CNK = 20, | |
| 59 | AIX = 21, | |
| 60 | CUDA = 22, | |
| 61 | NVCL = 23, | |
| 62 | AMDHSA = 24, | |
| 63 | PS4 = 25, | |
| 64 | ELFIAMCU = 26, | |
| 65 | TvOS = 27, | |
| 66 | WatchOS = 28, | |
| 67 | Mesa3D = 29, | |
| 68 | Contiki = 30, | |
| 69 | AMDPAL = 31, | |
| 70 | HermitCore = 32, | |
| 71 | Hurd = 33, | |
| 72 | WASI = 34, | |
| 73 | Emscripten = 35, | |
| 74 | }; | |
| 75 | ||
| 76 | pub const ArchType = extern enum(c_int) { | |
| 77 | UnknownArch = 0, | |
| 78 | arm = 1, | |
| 79 | armeb = 2, | |
| 80 | aarch64 = 3, | |
| 81 | aarch64_be = 4, | |
| 82 | aarch64_32 = 5, | |
| 83 | arc = 6, | |
| 84 | avr = 7, | |
| 85 | bpfel = 8, | |
| 86 | bpfeb = 9, | |
| 87 | hexagon = 10, | |
| 88 | mips = 11, | |
| 89 | mipsel = 12, | |
| 90 | mips64 = 13, | |
| 91 | mips64el = 14, | |
| 92 | msp430 = 15, | |
| 93 | ppc = 16, | |
| 94 | ppc64 = 17, | |
| 95 | ppc64le = 18, | |
| 96 | r600 = 19, | |
| 97 | amdgcn = 20, | |
| 98 | riscv32 = 21, | |
| 99 | riscv64 = 22, | |
| 100 | sparc = 23, | |
| 101 | sparcv9 = 24, | |
| 102 | sparcel = 25, | |
| 103 | systemz = 26, | |
| 104 | tce = 27, | |
| 105 | tcele = 28, | |
| 106 | thumb = 29, | |
| 107 | thumbeb = 30, | |
| 108 | x86 = 31, | |
| 109 | x86_64 = 32, | |
| 110 | xcore = 33, | |
| 111 | nvptx = 34, | |
| 112 | nvptx64 = 35, | |
| 113 | le32 = 36, | |
| 114 | le64 = 37, | |
| 115 | amdil = 38, | |
| 116 | amdil64 = 39, | |
| 117 | hsail = 40, | |
| 118 | hsail64 = 41, | |
| 119 | spir = 42, | |
| 120 | spir64 = 43, | |
| 121 | kalimba = 44, | |
| 122 | shave = 45, | |
| 123 | lanai = 46, | |
| 124 | wasm32 = 47, | |
| 125 | wasm64 = 48, | |
| 126 | renderscript32 = 49, | |
| 127 | renderscript64 = 50, | |
| 128 | ve = 51, | |
| 129 | }; | |
| 130 | ||
| 131 | pub const ParseCommandLineOptions = ZigLLVMParseCommandLineOptions; | |
| 132 | extern fn ZigLLVMParseCommandLineOptions(argc: usize, argv: [*]const [*:0]const u8) void; | |
| 133 | ||
| 134 | pub const WriteImportLibrary = ZigLLVMWriteImportLibrary; | |
| 135 | extern fn ZigLLVMWriteImportLibrary( | |
| 136 | def_path: [*:0]const u8, | |
| 137 | arch: ArchType, | |
| 138 | output_lib_path: [*c]const u8, | |
| 139 | kill_at: bool, | |
| 140 | ) bool; |
src/main.zig+3-3| ... | ... | @@ -1676,7 +1676,7 @@ fn buildOutputType( |
| 1676 | 1676 | if (build_options.have_llvm and emit_asm != .no) { |
| 1677 | 1677 | // LLVM has no way to set this non-globally. |
| 1678 | 1678 | const argv = [_][*:0]const u8{ "zig (LLVM option parsing)", "--x86-asm-syntax=intel" }; |
| 1679 | @import("llvm.zig").ParseCommandLineOptions(argv.len, &argv); | |
| 1679 | @import("llvm_bindings.zig").ParseCommandLineOptions(argv.len, &argv); | |
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | gimmeMoreOfThoseSweetSweetFileDescriptors(); |
| ... | ... | @@ -2839,7 +2839,7 @@ pub fn punt_to_lld(arena: *Allocator, args: []const []const u8) error{OutOfMemor |
| 2839 | 2839 | argv[i] = try arena.dupeZ(u8, arg); // TODO If there was an argsAllocZ we could avoid this allocation. |
| 2840 | 2840 | } |
| 2841 | 2841 | const exit_code = rc: { |
| 2842 | const llvm = @import("llvm.zig"); | |
| 2842 | const llvm = @import("llvm_bindings.zig"); | |
| 2843 | 2843 | const argc = @intCast(c_int, argv.len); |
| 2844 | 2844 | if (mem.eql(u8, args[1], "ld.lld")) { |
| 2845 | 2845 | break :rc llvm.LinkELF(argc, argv.ptr, true); |
| ... | ... | @@ -3224,7 +3224,7 @@ fn detectNativeTargetInfo(gpa: *Allocator, cross_target: std.zig.CrossTarget) !s |
| 3224 | 3224 | if (!build_options.have_llvm) |
| 3225 | 3225 | fatal("CPU features detection is not yet available for {} without LLVM extensions", .{@tagName(arch)}); |
| 3226 | 3226 | |
| 3227 | const llvm = @import("llvm.zig"); | |
| 3227 | const llvm = @import("llvm_bindings.zig"); | |
| 3228 | 3228 | const llvm_cpu_name = llvm.GetHostCPUName(); |
| 3229 | 3229 | const llvm_cpu_features = llvm.GetNativeFeatures(); |
| 3230 | 3230 | info.target.cpu = try detectNativeCpuWithLLVM(arch, llvm_cpu_name, llvm_cpu_features); |
src/mingw.zig+1-1| ... | ... | @@ -405,7 +405,7 @@ pub fn buildImportLib(comp: *Compilation, lib_name: []const u8) !void { |
| 405 | 405 | }); |
| 406 | 406 | errdefer comp.gpa.free(lib_final_path); |
| 407 | 407 | |
| 408 | const llvm = @import("llvm.zig"); | |
| 408 | const llvm = @import("llvm_bindings.zig"); | |
| 409 | 409 | const arch_type = @import("target.zig").archToLLVM(target.cpu.arch); |
| 410 | 410 | const def_final_path_z = try arena.dupeZ(u8, def_final_path); |
| 411 | 411 | const lib_final_path_z = try arena.dupeZ(u8, lib_final_path); |
src/target.zig+1-1| ... | ... | @@ -1,5 +1,5 @@ |
| 1 | 1 | const std = @import("std"); |
| 2 | const llvm = @import("llvm.zig"); | |
| 2 | const llvm = @import("llvm_bindings.zig"); | |
| 3 | 3 | |
| 4 | 4 | pub const ArchOsAbi = struct { |
| 5 | 5 | arch: std.Target.Cpu.Arch, |