authorgravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2020-12-14 20:46:36+01:00
committergravatar for timonkruiper@gmail.comTimon Kruiper <timonkruiper@gmail.com> 2020-12-28 21:15:13+01:00
log4a0d64300bd9ab1a8c35c634856396e3413200f1
treef545e425f612b1bfbcbe69f388b595df434accf9
parentc81ae52ee0b2e952f8ed9c5c6517af8182bb09c1

stage2: rename llvm.zig to llvm_bindings.zig

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
549549 "${CMAKE_SOURCE_DIR}/src/link/cbe.h"
550550 "${CMAKE_SOURCE_DIR}/src/link/msdos-stub.bin"
551551 "${CMAKE_SOURCE_DIR}/src/liveness.zig"
552 "${CMAKE_SOURCE_DIR}/src/llvm.zig"
552 "${CMAKE_SOURCE_DIR}/src/llvm_bindings.zig"
553553 "${CMAKE_SOURCE_DIR}/src/main.zig"
554554 "${CMAKE_SOURCE_DIR}/src/mingw.zig"
555555 "${CMAKE_SOURCE_DIR}/src/musl.zig"
src/link.zig+1-1
......@@ -567,7 +567,7 @@ pub const File = struct {
567567 std.debug.print("\n", .{});
568568 }
569569
570 const llvm = @import("llvm.zig");
570 const llvm = @import("llvm_bindings.zig");
571571 const os_type = @import("target.zig").osToLLVM(base.options.target.os.tag);
572572 const bad = llvm.WriteArchive(full_out_path_z, object_files.items.ptr, object_files.items.len, os_type);
573573 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
4extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
5extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
6extern fn ZigLLDLinkMachO(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
7extern fn ZigLLDLinkWasm(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
8
9pub const LinkCOFF = ZigLLDLinkCOFF;
10pub const LinkELF = ZigLLDLinkELF;
11pub const LinkMachO = ZigLLDLinkMachO;
12pub const LinkWasm = ZigLLDLinkWasm;
13
14pub const ObjectFormatType = extern enum(c_int) {
15 Unknown,
16 COFF,
17 ELF,
18 MachO,
19 Wasm,
20 XCOFF,
21};
22
23pub const GetHostCPUName = LLVMGetHostCPUName;
24extern fn LLVMGetHostCPUName() ?[*:0]u8;
25
26pub const GetNativeFeatures = ZigLLVMGetNativeFeatures;
27extern fn ZigLLVMGetNativeFeatures() ?[*:0]u8;
28
29pub const WriteArchive = ZigLLVMWriteArchive;
30extern 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
37pub 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
76pub 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
131pub const ParseCommandLineOptions = ZigLLVMParseCommandLineOptions;
132extern fn ZigLLVMParseCommandLineOptions(argc: usize, argv: [*]const [*:0]const u8) void;
133
134pub const WriteImportLibrary = ZigLLVMWriteImportLibrary;
135extern 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
4extern fn ZigLLDLinkCOFF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
5extern fn ZigLLDLinkELF(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
6extern fn ZigLLDLinkMachO(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
7extern fn ZigLLDLinkWasm(argc: c_int, argv: [*:null]const ?[*:0]const u8, can_exit_early: bool) c_int;
8
9pub const LinkCOFF = ZigLLDLinkCOFF;
10pub const LinkELF = ZigLLDLinkELF;
11pub const LinkMachO = ZigLLDLinkMachO;
12pub const LinkWasm = ZigLLDLinkWasm;
13
14pub const ObjectFormatType = extern enum(c_int) {
15 Unknown,
16 COFF,
17 ELF,
18 MachO,
19 Wasm,
20 XCOFF,
21};
22
23pub const GetHostCPUName = LLVMGetHostCPUName;
24extern fn LLVMGetHostCPUName() ?[*:0]u8;
25
26pub const GetNativeFeatures = ZigLLVMGetNativeFeatures;
27extern fn ZigLLVMGetNativeFeatures() ?[*:0]u8;
28
29pub const WriteArchive = ZigLLVMWriteArchive;
30extern 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
37pub 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
76pub 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
131pub const ParseCommandLineOptions = ZigLLVMParseCommandLineOptions;
132extern fn ZigLLVMParseCommandLineOptions(argc: usize, argv: [*]const [*:0]const u8) void;
133
134pub const WriteImportLibrary = ZigLLVMWriteImportLibrary;
135extern 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(
16761676 if (build_options.have_llvm and emit_asm != .no) {
16771677 // LLVM has no way to set this non-globally.
16781678 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);
16801680 }
16811681
16821682 gimmeMoreOfThoseSweetSweetFileDescriptors();
......@@ -2839,7 +2839,7 @@ pub fn punt_to_lld(arena: *Allocator, args: []const []const u8) error{OutOfMemor
28392839 argv[i] = try arena.dupeZ(u8, arg); // TODO If there was an argsAllocZ we could avoid this allocation.
28402840 }
28412841 const exit_code = rc: {
2842 const llvm = @import("llvm.zig");
2842 const llvm = @import("llvm_bindings.zig");
28432843 const argc = @intCast(c_int, argv.len);
28442844 if (mem.eql(u8, args[1], "ld.lld")) {
28452845 break :rc llvm.LinkELF(argc, argv.ptr, true);
......@@ -3224,7 +3224,7 @@ fn detectNativeTargetInfo(gpa: *Allocator, cross_target: std.zig.CrossTarget) !s
32243224 if (!build_options.have_llvm)
32253225 fatal("CPU features detection is not yet available for {} without LLVM extensions", .{@tagName(arch)});
32263226
3227 const llvm = @import("llvm.zig");
3227 const llvm = @import("llvm_bindings.zig");
32283228 const llvm_cpu_name = llvm.GetHostCPUName();
32293229 const llvm_cpu_features = llvm.GetNativeFeatures();
32303230 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 {
405405 });
406406 errdefer comp.gpa.free(lib_final_path);
407407
408 const llvm = @import("llvm.zig");
408 const llvm = @import("llvm_bindings.zig");
409409 const arch_type = @import("target.zig").archToLLVM(target.cpu.arch);
410410 const def_final_path_z = try arena.dupeZ(u8, def_final_path);
411411 const lib_final_path_z = try arena.dupeZ(u8, lib_final_path);
src/target.zig+1-1
......@@ -1,5 +1,5 @@
11const std = @import("std");
2const llvm = @import("llvm.zig");
2const llvm = @import("llvm_bindings.zig");
33
44pub const ArchOsAbi = struct {
55 arch: std.Target.Cpu.Arch,