-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.zig
277 lines (270 loc) · 11.3 KB
/
build.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
const std = @import("std");
const log = std.log.scoped(.spirv_tools);
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const spirv_headers = b.dependency("spirv_headers", .{});
const lib = b.addStaticLibrary(.{
.name = "spirv-opt",
.target = target,
.optimize = optimize,
});
const tag = target.result.os.tag;
if (tag == .windows) {
lib.root_module.addCMacro("SPIRV_WINDOWS", "");
} else if (tag == .linux) {
lib.root_module.addCMacro("SPIRV_LINUX", "");
} else if (tag == .macos) {
lib.root_module.addCMacro("SPIRV_MAC", "");
} else if (tag == .ios) {
lib.root_module.addCMacro("SPIRV_IOS", "");
} else if (tag == .tvos) {
lib.root_module.addCMacro("SPIRV_TVOS", "");
} else if (tag == .freebsd) {
lib.root_module.addCMacro("SPIRV_FREEBSD", "");
} else if (tag == .openbsd) {
lib.root_module.addCMacro("SPIRV_OPENBSD", "");
} else if (tag == .fuchsia) {
lib.root_module.addCMacro("SPIRV_FUCHSIA", "");
} else {
log.err("Incompatible target platform.", .{});
std.process.exit(1);
}
lib.linkLibCpp();
lib.addCSourceFiles(.{ .files = sources });
lib.addIncludePath(b.path("."));
lib.addIncludePath(b.path("include"));
lib.addIncludePath(b.path("include-generated"));
lib.addIncludePath(spirv_headers.path("include"));
lib.addIncludePath(spirv_headers.path("include/spirv/unified1"));
lib.installHeadersDirectory(b.path("include/spirv-tools"), "spirv-tools", .{});
b.installArtifact(lib);
}
const sources = &[_][]const u8{
"source/spirv_target_env.cpp",
"source/lint/lint_divergent_derivatives.cpp",
"source/lint/linter.cpp",
"source/lint/divergence_analysis.cpp",
"source/text.cpp",
"source/assembly_grammar.cpp",
"source/extensions.cpp",
"source/pch_source.cpp",
"source/util/timer.cpp",
"source/util/string_utils.cpp",
"source/util/parse_number.cpp",
"source/util/bit_vector.cpp",
"source/table.cpp",
"source/reduce/remove_selection_reduction_opportunity.cpp",
"source/reduce/reduction_pass.cpp",
"source/reduce/operand_to_const_reduction_opportunity_finder.cpp",
"source/reduce/reduction_util.cpp",
"source/reduce/structured_loop_to_selection_reduction_opportunity_finder.cpp",
"source/reduce/remove_function_reduction_opportunity_finder.cpp",
"source/reduce/simple_conditional_branch_to_branch_reduction_opportunity.cpp",
"source/reduce/remove_function_reduction_opportunity.cpp",
"source/reduce/simple_conditional_branch_to_branch_opportunity_finder.cpp",
"source/reduce/remove_selection_reduction_opportunity_finder.cpp",
"source/reduce/conditional_branch_to_simple_conditional_branch_reduction_opportunity.cpp",
"source/reduce/merge_blocks_reduction_opportunity.cpp",
"source/reduce/change_operand_reduction_opportunity.cpp",
"source/reduce/remove_instruction_reduction_opportunity.cpp",
"source/reduce/pch_source_reduce.cpp",
"source/reduce/remove_struct_member_reduction_opportunity.cpp",
"source/reduce/remove_unused_instruction_reduction_opportunity_finder.cpp",
"source/reduce/reducer.cpp",
"source/reduce/operand_to_undef_reduction_opportunity_finder.cpp",
"source/reduce/merge_blocks_reduction_opportunity_finder.cpp",
"source/reduce/reduction_opportunity.cpp",
"source/reduce/change_operand_to_undef_reduction_opportunity.cpp",
"source/reduce/operand_to_dominating_id_reduction_opportunity_finder.cpp",
"source/reduce/remove_block_reduction_opportunity_finder.cpp",
"source/reduce/conditional_branch_to_simple_conditional_branch_opportunity_finder.cpp",
"source/reduce/structured_loop_to_selection_reduction_opportunity.cpp",
"source/reduce/structured_construct_to_block_reduction_opportunity.cpp",
"source/reduce/remove_block_reduction_opportunity.cpp",
"source/reduce/remove_unused_struct_member_reduction_opportunity_finder.cpp",
"source/reduce/reduction_opportunity_finder.cpp",
"source/reduce/structured_construct_to_block_reduction_opportunity_finder.cpp",
"source/spirv_optimizer_options.cpp",
"source/spirv_fuzzer_options.cpp",
"source/spirv_validator_options.cpp",
"source/print.cpp",
"source/spirv_endian.cpp",
"source/binary.cpp",
"source/diff/diff.cpp",
"source/enum_string_mapping.cpp",
"source/spirv_reducer_options.cpp",
"source/parsed_operand.cpp",
"source/name_mapper.cpp",
"source/link/linker.cpp",
"source/software_version.cpp",
"source/opcode.cpp",
"source/ext_inst.cpp",
"source/opt/invocation_interlock_placement_pass.cpp",
"source/opt/optimizer.cpp",
"source/opt/register_pressure.cpp",
"source/opt/loop_utils.cpp",
"source/opt/spread_volatile_semantics.cpp",
"source/opt/combine_access_chains.cpp",
"source/opt/build_module.cpp",
"source/opt/eliminate_dead_output_stores_pass.cpp",
"source/opt/liveness.cpp",
"source/opt/modify_maximal_reconvergence.cpp",
"source/opt/code_sink.cpp",
"source/opt/types.cpp",
"source/opt/cfg.cpp",
"source/opt/decoration_manager.cpp",
"source/opt/local_single_block_elim_pass.cpp",
"source/opt/freeze_spec_constant_value_pass.cpp",
"source/opt/local_redundancy_elimination.cpp",
"source/opt/struct_packing_pass.cpp",
"source/opt/feature_manager.cpp",
"source/opt/pass.cpp",
"source/opt/loop_fission.cpp",
"source/opt/dominator_tree.cpp",
"source/opt/merge_return_pass.cpp",
"source/opt/eliminate_dead_constant_pass.cpp",
"source/opt/cfg_cleanup_pass.cpp",
"source/opt/wrap_opkill.cpp",
"source/opt/eliminate_dead_io_components_pass.cpp",
"source/opt/const_folding_rules.cpp",
"source/opt/strip_debug_info_pass.cpp",
"source/opt/ssa_rewrite_pass.cpp",
"source/opt/loop_dependence.cpp",
"source/opt/mem_pass.cpp",
"source/opt/remove_duplicates_pass.cpp",
"source/opt/dead_variable_elimination.cpp",
"source/opt/module.cpp",
"source/opt/fold_spec_constant_op_and_composite_pass.cpp",
"source/opt/loop_unswitch_pass.cpp",
"source/opt/unify_const_pass.cpp",
"source/opt/type_manager.cpp",
"source/opt/switch_descriptorset_pass.cpp",
"source/opt/inline_pass.cpp",
"source/opt/ir_loader.cpp",
"source/opt/licm_pass.cpp",
"source/opt/eliminate_dead_functions_pass.cpp",
"source/opt/vector_dce.cpp",
"source/opt/loop_unroller.cpp",
"source/opt/constants.cpp",
"source/opt/desc_sroa_util.cpp",
"source/opt/def_use_manager.cpp",
"source/opt/ccp_pass.cpp",
"source/opt/pch_source_opt.cpp",
"source/opt/aggressive_dead_code_elim_pass.cpp",
"source/opt/eliminate_dead_functions_util.cpp",
"source/opt/simplification_pass.cpp",
"source/opt/dead_branch_elim_pass.cpp",
"source/opt/flatten_decoration_pass.cpp",
"source/opt/folding_rules.cpp",
"source/opt/ir_context.cpp",
"source/opt/loop_descriptor.cpp",
"source/opt/function.cpp",
"source/opt/instruction_list.cpp",
"source/opt/control_dependence.cpp",
"source/opt/composite.cpp",
"source/opt/convert_to_half_pass.cpp",
"source/opt/strip_nonsemantic_info_pass.cpp",
"source/opt/if_conversion.cpp",
"source/opt/fix_func_call_arguments.cpp",
"source/opt/debug_info_manager.cpp",
"source/opt/eliminate_dead_members_pass.cpp",
"source/opt/strength_reduction_pass.cpp",
"source/opt/desc_sroa.cpp",
"source/opt/block_merge_util.cpp",
"source/opt/copy_prop_arrays.cpp",
"source/opt/pass_manager.cpp",
"source/opt/inline_exhaustive_pass.cpp",
"source/opt/loop_fusion_pass.cpp",
"source/opt/dead_insert_elim_pass.cpp",
"source/opt/scalar_analysis.cpp",
"source/opt/block_merge_pass.cpp",
"source/opt/convert_to_sampled_image_pass.cpp",
"source/opt/local_single_store_elim_pass.cpp",
"source/opt/private_to_local_pass.cpp",
"source/opt/propagator.cpp",
"source/opt/loop_dependence_helpers.cpp",
"source/opt/set_spec_constant_default_value_pass.cpp",
"source/opt/fold.cpp",
"source/opt/amd_ext_to_khr.cpp",
"source/opt/scalar_replacement_pass.cpp",
"source/opt/opextinst_forward_ref_fixup_pass.cpp",
"source/opt/interface_var_sroa.cpp",
"source/opt/redundancy_elimination.cpp",
"source/opt/workaround1209.cpp",
"source/opt/relax_float_ops_pass.cpp",
"source/opt/instruction.cpp",
"source/opt/reduce_load_size.cpp",
"source/opt/fix_storage_class.cpp",
"source/opt/value_number_table.cpp",
"source/opt/remove_unused_interface_variables_pass.cpp",
"source/opt/inline_opaque_pass.cpp",
"source/opt/replace_invalid_opc.cpp",
"source/opt/trim_capabilities_pass.cpp",
"source/opt/dominator_analysis.cpp",
"source/opt/replace_desc_array_access_using_var_index.cpp",
"source/opt/dataflow.cpp",
"source/opt/struct_cfg_analysis.cpp",
"source/opt/remove_dontinline_pass.cpp",
"source/opt/local_access_chain_convert_pass.cpp",
"source/opt/interp_fixup_pass.cpp",
"source/opt/basic_block.cpp",
"source/opt/graphics_robust_access_pass.cpp",
"source/opt/loop_fusion.cpp",
"source/opt/analyze_live_input_pass.cpp",
"source/opt/upgrade_memory_model.cpp",
"source/opt/scalar_analysis_simplification.cpp",
"source/opt/compact_ids_pass.cpp",
"source/opt/loop_peeling.cpp",
"source/to_string.cpp",
"source/diagnostic.cpp",
"source/libspirv.cpp",
"source/operand.cpp",
"source/disassemble.cpp",
"source/text_handler.cpp",
"source/val/validate_annotation.cpp",
"source/val/validate_misc.cpp",
"source/val/validate_cfg.cpp",
"source/val/validate_capability.cpp",
"source/val/validate_tensor_layout.cpp",
"source/val/validate_barriers.cpp",
"source/val/validate_non_uniform.cpp",
"source/val/validate_ray_query.cpp",
"source/val/validate_ray_tracing.cpp",
"source/val/validate_scopes.cpp",
"source/val/validate_atomics.cpp",
"source/val/validate_instruction.cpp",
"source/val/validate_ray_tracing_reorder.cpp",
"source/val/validate_decorations.cpp",
"source/val/validate_debug.cpp",
"source/val/validate_builtins.cpp",
"source/val/validate_interfaces.cpp",
"source/val/validate.cpp",
"source/val/validate_constants.cpp",
"source/val/validate_bitwise.cpp",
"source/val/validate_extensions.cpp",
"source/val/construct.cpp",
"source/val/function.cpp",
"source/val/validate_adjacency.cpp",
"source/val/validate_conversion.cpp",
"source/val/validate_small_type_uses.cpp",
"source/val/validate_id.cpp",
"source/val/validate_arithmetics.cpp",
"source/val/validate_mode_setting.cpp",
"source/val/validate_memory_semantics.cpp",
"source/val/validate_logicals.cpp",
"source/val/validate_derivatives.cpp",
"source/val/validate_memory.cpp",
"source/val/validate_image.cpp",
"source/val/validate_literals.cpp",
"source/val/instruction.cpp",
"source/val/validate_type.cpp",
"source/val/validate_mesh_shading.cpp",
"source/val/validate_execution_limitations.cpp",
"source/val/validate_layout.cpp",
"source/val/basic_block.cpp",
"source/val/validate_function.cpp",
"source/val/validate_composites.cpp",
"source/val/validation_state.cpp",
"source/val/validate_primitives.cpp",
};