@@ -25,6 +25,8 @@ base: link.File,
25
25
llvm_object : * LlvmObject ,
26
26
27
27
pub fn createEmpty (gpa : Allocator , options : link.Options ) ! * NvPtx {
28
+ if (! build_options .have_llvm ) return error .TODOArchNotSupported ;
29
+
28
30
const nvptx = try gpa .create (NvPtx );
29
31
nvptx .* = .{
30
32
.base = .{
@@ -36,8 +38,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx {
36
38
.llvm_object = undefined ,
37
39
};
38
40
39
- if (! build_options .have_llvm ) return error .TODOArchNotSupported ;
40
-
41
41
switch (options .target .cpu .arch ) {
42
42
.nvptx , .nvptx64 = > {},
43
43
else = > return error .TODOArchNotSupported ,
@@ -53,8 +53,9 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*NvPtx {
53
53
}
54
54
55
55
pub fn openPath (allocator : Allocator , sub_path : []const u8 , options : link.Options ) ! * NvPtx {
56
+ if (! build_options .have_llvm ) @panic ("nvptx target requires a zig compiler with llvm enabled." );
57
+ if (! options .use_llvm ) return error .TODOArchNotSupported ;
56
58
assert (options .object_format == .nvptx );
57
- if (! build_options .have_llvm or ! options .use_llvm ) return error .NvptxRequiresLlvm ;
58
59
59
60
const nvptx = try createEmpty (allocator , options );
60
61
errdefer nvptx .base .destroy ();
@@ -64,14 +65,17 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option
64
65
}
65
66
66
67
pub fn deinit (self : * NvPtx ) void {
68
+ if (! build_options .have_llvm ) return ;
67
69
self .llvm_object .destroy (self .base .allocator );
68
70
}
69
71
70
72
pub fn updateFunc (self : * NvPtx , module : * Module , func : * Module.Fn , air : Air , liveness : Liveness ) ! void {
73
+ if (! build_options .have_llvm ) return ;
71
74
try self .llvm_object .updateFunc (module , func , air , liveness );
72
75
}
73
76
74
77
pub fn updateDecl (self : * NvPtx , module : * Module , decl : * Module.Decl ) ! void {
78
+ if (! build_options .have_llvm ) return ;
75
79
return self .llvm_object .updateDecl (module , decl );
76
80
}
77
81
@@ -81,13 +85,15 @@ pub fn updateDeclExports(
81
85
decl : * const Module.Decl ,
82
86
exports : []const * Module.Export ,
83
87
) ! void {
88
+ if (! build_options .have_llvm ) return ;
84
89
if (build_options .skip_non_native and builtin .object_format != .nvptx ) {
85
90
@panic ("Attempted to compile for object format that was disabled by build configuration" );
86
91
}
87
92
return self .llvm_object .updateDeclExports (module , decl , exports );
88
93
}
89
94
90
95
pub fn freeDecl (self : * NvPtx , decl : * Module.Decl ) void {
96
+ if (! build_options .have_llvm ) return ;
91
97
return self .llvm_object .freeDecl (decl );
92
98
}
93
99
@@ -96,7 +102,8 @@ pub fn flush(self: *NvPtx, comp: *Compilation) !void {
96
102
}
97
103
98
104
pub fn flushModule (self : * NvPtx , comp : * Compilation ) ! void {
99
- if (build_options .skip_non_native or ! build_options .have_llvm ) {
105
+ if (! build_options .have_llvm ) return ;
106
+ if (build_options .skip_non_native ) {
100
107
@panic ("Attempted to compile for architecture that was disabled by build configuration" );
101
108
}
102
109
const tracy = trace (@src ());
0 commit comments