• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright © 2017 Intel Corporation
2
3# Permission is hereby granted, free of charge, to any person obtaining a copy
4# of this software and associated documentation files (the "Software"), to deal
5# in the Software without restriction, including without limitation the rights
6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7# copies of the Software, and to permit persons to whom the Software is
8# furnished to do so, subject to the following conditions:
9
10# The above copyright notice and this permission notice shall be included in
11# all copies or substantial portions of the Software.
12
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19# SOFTWARE.
20
21nir_depends = files('nir_opcodes.py', 'nir_intrinsics.py')
22
23nir_algebraic_depends = files('nir_opcodes.py', 'nir_algebraic.py')
24
25nir_builder_opcodes_h = custom_target(
26  'nir_builder_opcodes.h',
27  input : 'nir_builder_opcodes_h.py',
28  output : 'nir_builder_opcodes.h',
29  command : [prog_python, '@INPUT@'],
30  capture : true,
31  depend_files : nir_depends,
32)
33
34nir_constant_expressions_c = custom_target(
35  'nir_constant_expressions.c',
36  input : 'nir_constant_expressions.py',
37  output : 'nir_constant_expressions.c',
38  command : [prog_python, '@INPUT@'],
39  capture : true,
40  depend_files : nir_depends,
41)
42
43nir_opcodes_h = custom_target(
44  'nir_opcodes.h',
45  input : 'nir_opcodes_h.py',
46  output : 'nir_opcodes.h',
47  command : [prog_python, '@INPUT@'],
48  capture : true,
49  depend_files : nir_depends,
50)
51
52nir_opcodes_c = custom_target(
53  'nir_opcodes.c',
54  input : 'nir_opcodes_c.py',
55  output : 'nir_opcodes.c',
56  command : [prog_python, '@INPUT@'],
57  capture : true,
58  depend_files : nir_depends,
59)
60
61nir_opt_algebraic_c = custom_target(
62  'nir_opt_algebraic.c',
63  input : 'nir_opt_algebraic.py',
64  output : 'nir_opt_algebraic.c',
65  command : [prog_python, '@INPUT@'],
66  capture : true,
67  depend_files : nir_algebraic_depends,
68)
69
70nir_intrinsics_h = custom_target(
71  'nir_intrinsics.h',
72  input : 'nir_intrinsics_h.py',
73  output : 'nir_intrinsics.h',
74  command : [prog_python, '@INPUT@', '--outdir', meson.current_build_dir()],
75  capture : false,
76  depend_files : files('nir_intrinsics.py'),
77)
78
79nir_intrinsics_indices_h = custom_target(
80  'nir_intrinsics_indices.h',
81  input : 'nir_intrinsics_indices_h.py',
82  output : 'nir_intrinsics_indices.h',
83  command : [prog_python, '@INPUT@', '--outdir', meson.current_build_dir()],
84  capture : false,
85  depend_files : files('nir_intrinsics.py'),
86)
87
88nir_intrinsics_c = custom_target(
89  'nir_intrinsic.c',
90  input : 'nir_intrinsics_c.py',
91  output : 'nir_intrinsics.c',
92  command : [prog_python, '@INPUT@', '--outdir', meson.current_build_dir()],
93  capture: false,
94  depend_files : files('nir_intrinsics.py'),
95)
96
97files_libnir = files(
98  'nir.c',
99  'nir.h',
100  'nir_builder.c',
101  'nir_builder.h',
102  'nir_builtin_builder.c',
103  'nir_builtin_builder.h',
104  'nir_conversion_builder.h',
105  'nir_clone.c',
106  'nir_constant_expressions.h',
107  'nir_control_flow.c',
108  'nir_control_flow.h',
109  'nir_control_flow_private.h',
110  'nir_convert_ycbcr.c',
111  'nir_deref.c',
112  'nir_deref.h',
113  'nir_divergence_analysis.c',
114  'nir_dominance.c',
115  'nir_format_convert.h',
116  'nir_from_ssa.c',
117  'nir_gather_info.c',
118  'nir_gather_ssa_types.c',
119  'nir_gather_xfb_info.c',
120  'nir_group_loads.c',
121  'nir_gs_count_vertices.c',
122  'nir_inline_functions.c',
123  'nir_inline_uniforms.c',
124  'nir_instr_set.c',
125  'nir_instr_set.h',
126  'nir_linking_helpers.c',
127  'nir_liveness.c',
128  'nir_loop_analyze.c',
129  'nir_loop_analyze.h',
130  'nir_lower_alu.c',
131  'nir_lower_alu_width.c',
132  'nir_lower_alpha_test.c',
133  'nir_lower_amul.c',
134  'nir_lower_array_deref_of_vec.c',
135  'nir_lower_atomics_to_ssbo.c',
136  'nir_lower_bitmap.c',
137  'nir_lower_blend.c',
138  'nir_lower_bool_to_bitsize.c',
139  'nir_lower_bool_to_float.c',
140  'nir_lower_bool_to_int32.c',
141  'nir_lower_clamp_color_outputs.c',
142  'nir_lower_clip.c',
143  'nir_lower_clip_cull_distance_arrays.c',
144  'nir_lower_clip_disable.c',
145  'nir_lower_clip_halfz.c',
146  'nir_lower_const_arrays_to_uniforms.c',
147  'nir_lower_convert_alu_types.c',
148  'nir_lower_variable_initializers.c',
149  'nir_lower_discard_if.c',
150  'nir_lower_discard_or_demote.c',
151  'nir_lower_double_ops.c',
152  'nir_lower_drawpixels.c',
153  'nir_lower_fb_read.c',
154  'nir_lower_flatshade.c',
155  'nir_lower_flrp.c',
156  'nir_lower_fp16_conv.c',
157  'nir_lower_fragcoord_wtrans.c',
158  'nir_lower_fragcolor.c',
159  'nir_lower_frexp.c',
160  'nir_lower_global_vars_to_local.c',
161  'nir_lower_goto_ifs.c',
162  'nir_lower_gs_intrinsics.c',
163  'nir_lower_load_const_to_scalar.c',
164  'nir_lower_locals_to_regs.c',
165  'nir_lower_idiv.c',
166  'nir_lower_image.c',
167  'nir_lower_indirect_derefs.c',
168  'nir_lower_input_attachments.c',
169  'nir_lower_int64.c',
170  'nir_lower_interpolation.c',
171  'nir_lower_int_to_float.c',
172  'nir_lower_io.c',
173  'nir_lower_io_arrays_to_elements.c',
174  'nir_lower_io_to_temporaries.c',
175  'nir_lower_io_to_scalar.c',
176  'nir_lower_io_to_vector.c',
177  'nir_lower_is_helper_invocation.c',
178  'nir_lower_multiview.c',
179  'nir_lower_mediump.c',
180  'nir_lower_memcpy.c',
181  'nir_lower_memory_model.c',
182  'nir_lower_non_uniform_access.c',
183  'nir_lower_packing.c',
184  'nir_lower_passthrough_edgeflags.c',
185  'nir_lower_patch_vertices.c',
186  'nir_lower_phis_to_scalar.c',
187  'nir_lower_pntc_ytransform.c',
188  'nir_lower_point_size.c',
189  'nir_lower_point_size_mov.c',
190  'nir_lower_point_smooth.c',
191  'nir_lower_poly_line_smooth.c',
192  'nir_lower_printf.c',
193  'nir_lower_regs_to_ssa.c',
194  'nir_lower_readonly_images_to_tex.c',
195  'nir_lower_returns.c',
196  'nir_lower_samplers.c',
197  'nir_lower_scratch.c',
198  'nir_lower_shader_calls.c',
199  'nir_lower_single_sampled.c',
200  'nir_lower_ssbo.c',
201  'nir_lower_subgroups.c',
202  'nir_lower_system_values.c',
203  'nir_lower_task_shader.c',
204  'nir_lower_tex_shadow.c',
205  'nir_lower_tex.c',
206  'nir_lower_texcoord_replace.c',
207  'nir_lower_to_source_mods.c',
208  'nir_lower_two_sided_color.c',
209  'nir_lower_undef_to_zero.c',
210  'nir_lower_vars_to_ssa.c',
211  'nir_lower_var_copies.c',
212  'nir_lower_vec_to_movs.c',
213  'nir_lower_vec3_to_vec4.c',
214  'nir_lower_viewport_transform.c',
215  'nir_lower_wpos_center.c',
216  'nir_lower_wpos_ytransform.c',
217  'nir_lower_wrmasks.c',
218  'nir_lower_bit_size.c',
219  'nir_lower_ubo_vec4.c',
220  'nir_lower_uniforms_to_ubo.c',
221  'nir_lower_sysvals_to_varyings.c',
222  'nir_metadata.c',
223  'nir_move_vec_src_uses_to_dest.c',
224  'nir_normalize_cubemap_coords.c',
225  'nir_opt_access.c',
226  'nir_opt_barriers.c',
227  'nir_opt_combine_stores.c',
228  'nir_opt_comparison_pre.c',
229  'nir_opt_conditional_discard.c',
230  'nir_opt_constant_folding.c',
231  'nir_opt_copy_prop_vars.c',
232  'nir_opt_copy_propagate.c',
233  'nir_opt_cse.c',
234  'nir_opt_dce.c',
235  'nir_opt_dead_cf.c',
236  'nir_opt_dead_write_vars.c',
237  'nir_opt_find_array_copies.c',
238  'nir_opt_fragdepth.c',
239  'nir_opt_gcm.c',
240  'nir_opt_idiv_const.c',
241  'nir_opt_if.c',
242  'nir_opt_intrinsics.c',
243  'nir_opt_large_constants.c',
244  'nir_opt_load_store_vectorize.c',
245  'nir_opt_loop_unroll.c',
246  'nir_opt_memcpy.c',
247  'nir_opt_move.c',
248  'nir_opt_move_discards_to_top.c',
249  'nir_opt_offsets.c',
250  'nir_opt_peephole_select.c',
251  'nir_opt_phi_precision.c',
252  'nir_opt_preamble.c',
253  'nir_opt_ray_queries.c',
254  'nir_opt_rematerialize_compares.c',
255  'nir_opt_remove_phis.c',
256  'nir_opt_shrink_stores.c',
257  'nir_opt_shrink_vectors.c',
258  'nir_opt_sink.c',
259  'nir_opt_trivial_continues.c',
260  'nir_opt_undef.c',
261  'nir_opt_uniform_atomics.c',
262  'nir_opt_vectorize.c',
263  'nir_phi_builder.c',
264  'nir_phi_builder.h',
265  'nir_print.c',
266  'nir_propagate_invariant.c',
267  'nir_range_analysis.c',
268  'nir_range_analysis.h',
269  'nir_remove_dead_variables.c',
270  'nir_repair_ssa.c',
271  'nir_scale_fdiv.c',
272  'nir_schedule.c',
273  'nir_schedule.h',
274  'nir_search.c',
275  'nir_search.h',
276  'nir_search_helpers.h',
277  'nir_serialize.c',
278  'nir_serialize.h',
279  'nir_split_64bit_vec3_and_vec4.c',
280  'nir_split_per_member_structs.c',
281  'nir_split_var_copies.c',
282  'nir_split_vars.c',
283  'nir_sweep.c',
284  'nir_to_lcssa.c',
285  'nir_validate.c',
286  'nir_vla.h',
287  'nir_vulkan.h',
288  'nir_worklist.c',
289  'nir_worklist.h',
290  'nir_xfb_info.h',
291  '../spirv/GLSL.ext.AMD.h',
292  '../spirv/GLSL.std.450.h',
293  '../spirv/gl_spirv.c',
294  '../spirv/nir_load_libclc.c',
295  '../spirv/nir_lower_libclc.c',
296  '../spirv/nir_spirv.h',
297  '../spirv/OpenCL.std.h',
298  '../spirv/spirv.h',
299  '../spirv/spirv_info.h',
300  '../spirv/spirv_to_nir.c',
301  '../spirv/vtn_alu.c',
302  '../spirv/vtn_amd.c',
303  '../spirv/vtn_cfg.c',
304  '../spirv/vtn_glsl450.c',
305  '../spirv/vtn_opencl.c',
306  '../spirv/vtn_private.h',
307  '../spirv/vtn_subgroup.c',
308  '../spirv/vtn_variables.c',
309)
310
311_libnir_args = []
312if dep_clc.found()
313  _basedir = dep_clc.get_variable(pkgconfig : 'libexecdir')
314
315  _static_libclc = get_option('static-libclc')
316  if _static_libclc.length() > 0
317    if _static_libclc.contains('all')
318      _static_libclc = ['spirv', 'spirv64']
319    endif
320
321    prog_zstd = find_program('zstd', required : false)
322    _zstd_static_libclc = dep_zstd.found() and prog_zstd.found()
323    if _zstd_static_libclc
324      _libnir_args += '-DHAVE_STATIC_LIBCLC_ZSTD'
325    endif
326
327    foreach s : _static_libclc
328      _libnir_args += '-DHAVE_STATIC_LIBCLC_@0@'.format(s.to_upper())
329      f = '@0@-mesa3d-.spv'.format(s)
330      _libclc_file = _basedir / f
331
332      if _zstd_static_libclc
333        _libclc_file = custom_target(
334          '@0@.zstd'.format(f),
335          command : [prog_zstd, '-f', '@INPUT@', '-o', '@OUTPUT@'],
336          input : [_libclc_file],
337          output : '@0@.zstd'.format(f),
338        )
339      endif
340
341      files_libnir += custom_target(
342        '@0@.h'.format(f),
343        command : [
344          prog_python, files_xxd, '-b', '@INPUT@', '@OUTPUT@',
345          '-n', 'libclc_@0@_mesa3d_spv'.format(s),
346        ],
347        input : [_libclc_file],
348        output : '@0@.h'.format(f),
349        depend_files : files_xxd,
350      )
351    endforeach
352  else
353    _libnir_args += ['-DDYNAMIC_LIBCLC_PATH="@0@/"'.format(_basedir)]
354    if not cc.has_function('mmap')
355      error('mmap required for dynamic libCLC loading')
356    endif
357  endif
358endif
359
360_libnir = static_library(
361  'nir',
362  [files_libnir, spirv_info_c, nir_opt_algebraic_c, nir_opcodes_c,
363   nir_opcodes_h, nir_constant_expressions_c, nir_builder_opcodes_h,
364   vtn_gather_types_c, nir_intrinsics_c, nir_intrinsics_h, nir_intrinsics_indices_h, vtn_generator_ids_h],
365  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_compiler, include_directories('../spirv')],
366  c_args : [c_msvc_compat_args, no_override_init_args, _libnir_args],
367  gnu_symbol_visibility : 'hidden',
368  dependencies : dep_valgrind,
369  link_with : libcompiler,
370  build_by_default : false,
371)
372
373# Headers-only dependency
374idep_nir_headers = declare_dependency(
375  sources : [nir_opcodes_h, nir_builder_opcodes_h, nir_intrinsics_h, nir_intrinsics_indices_h],
376  include_directories : include_directories('.'),
377)
378
379# Also link with nir
380idep_nir = declare_dependency(
381  dependencies : [idep_nir_headers, idep_mesautil],
382  link_with : _libnir,
383)
384
385if with_tests
386  test(
387    'nir_tests',
388    executable(
389      'nir_tests',
390      files(
391        'tests/algebraic_tests.cpp',
392        'tests/builder_tests.cpp',
393        'tests/comparison_pre_tests.cpp',
394        'tests/control_flow_tests.cpp',
395        'tests/core_tests.cpp',
396        'tests/lower_returns_tests.cpp',
397        'tests/negative_equal_tests.cpp',
398        'tests/opt_if_tests.cpp',
399        'tests/serialize_tests.cpp',
400        'tests/ssa_def_bits_used_tests.cpp',
401        'tests/vars_tests.cpp',
402      ),
403      cpp_args : [cpp_msvc_compat_args],
404      gnu_symbol_visibility : 'hidden',
405      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
406      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
407    ),
408    suite : ['compiler', 'nir'],
409    protocol : gtest_test_protocol,
410  )
411
412  test(
413    'nir_algebraic_parser',
414    prog_python,
415    args : [
416      join_paths(meson.current_source_dir(), 'tests/algebraic_parser_test.py')
417    ],
418    suite : ['compiler', 'nir'],
419  )
420
421  test(
422    'load_store_vectorizer',
423    executable(
424      'load_store_vectorizer',
425      files('tests/load_store_vectorizer_tests.cpp'),
426      cpp_args : [cpp_msvc_compat_args],
427      gnu_symbol_visibility : 'hidden',
428      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
429      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
430    ),
431    suite : ['compiler', 'nir'],
432    # TODO: Use a negative filter for gtest instead of the expect failure here.
433    should_fail : meson.get_cross_property('xfail', '').contains('load_store_vectorizer'),
434    protocol : gtest_test_protocol,
435  )
436
437  test(
438    'nir_opt_dce',
439    executable(
440      'nir_opt_dce_tests',
441      files('tests/dce_tests.cpp'),
442      cpp_args : [cpp_msvc_compat_args],
443      gnu_symbol_visibility : 'hidden',
444      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
445      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
446    ),
447    suite : ['compiler', 'nir'],
448  )
449endif
450