• 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_builder_opcodes_h = custom_target(
24  'nir_builder_opcodes.h',
25  input : 'nir_builder_opcodes_h.py',
26  output : 'nir_builder_opcodes.h',
27  command : [prog_python, '@INPUT@'],
28  capture : true,
29  depend_files : nir_depends,
30)
31
32nir_constant_expressions_c = custom_target(
33  'nir_constant_expressions.c',
34  input : 'nir_constant_expressions.py',
35  output : 'nir_constant_expressions.c',
36  command : [prog_python, '@INPUT@'],
37  capture : true,
38  depend_files : nir_depends,
39)
40
41nir_opcodes_h = custom_target(
42  'nir_opcodes.h',
43  input : 'nir_opcodes_h.py',
44  output : 'nir_opcodes.h',
45  command : [prog_python, '@INPUT@'],
46  capture : true,
47  depend_files : nir_depends,
48)
49
50nir_opcodes_c = custom_target(
51  'nir_opcodes.c',
52  input : 'nir_opcodes_c.py',
53  output : 'nir_opcodes.c',
54  command : [prog_python, '@INPUT@'],
55  capture : true,
56  depend_files : nir_depends,
57)
58
59nir_opt_algebraic_c = custom_target(
60  'nir_opt_algebraic.c',
61  input : 'nir_opt_algebraic.py',
62  output : 'nir_opt_algebraic.c',
63  command : [prog_python, '@INPUT@'],
64  capture : true,
65  depend_files : files('nir_algebraic.py'),
66)
67
68nir_intrinsics_h = custom_target(
69  'nir_intrinsics.h',
70  input : 'nir_intrinsics_h.py',
71  output : 'nir_intrinsics.h',
72  command : [prog_python, '@INPUT@', '--outdir', meson.current_build_dir()],
73  capture : false,
74  depend_files : files('nir_intrinsics.py'),
75)
76
77nir_intrinsics_indices_h = custom_target(
78  'nir_intrinsics_indices.h',
79  input : 'nir_intrinsics_indices_h.py',
80  output : 'nir_intrinsics_indices.h',
81  command : [prog_python, '@INPUT@', '--outdir', meson.current_build_dir()],
82  capture : false,
83  depend_files : files('nir_intrinsics.py'),
84)
85
86nir_intrinsics_c = custom_target(
87  'nir_intrinsic.c',
88  input : 'nir_intrinsics_c.py',
89  output : 'nir_intrinsics.c',
90  command : [prog_python, '@INPUT@', '--outdir', meson.current_build_dir()],
91  capture: false,
92  depend_files : files('nir_intrinsics.py'),
93)
94
95files_libnir = files(
96  'nir.c',
97  'nir.h',
98  'nir_builder.h',
99  'nir_builtin_builder.c',
100  'nir_builtin_builder.h',
101  'nir_conversion_builder.h',
102  'nir_clone.c',
103  'nir_constant_expressions.h',
104  'nir_control_flow.c',
105  'nir_control_flow.h',
106  'nir_control_flow_private.h',
107  'nir_convert_ycbcr.c',
108  'nir_deref.c',
109  'nir_deref.h',
110  'nir_divergence_analysis.c',
111  'nir_dominance.c',
112  'nir_format_convert.h',
113  'nir_from_ssa.c',
114  'nir_gather_info.c',
115  'nir_gather_ssa_types.c',
116  'nir_gather_xfb_info.c',
117  'nir_gs_count_vertices.c',
118  'nir_inline_functions.c',
119  'nir_inline_uniforms.c',
120  'nir_instr_set.c',
121  'nir_instr_set.h',
122  'nir_linking_helpers.c',
123  'nir_liveness.c',
124  'nir_loop_analyze.c',
125  'nir_loop_analyze.h',
126  'nir_lower_alu.c',
127  'nir_lower_alu_to_scalar.c',
128  'nir_lower_alpha_test.c',
129  'nir_lower_amul.c',
130  'nir_lower_array_deref_of_vec.c',
131  'nir_lower_atomics_to_ssbo.c',
132  'nir_lower_bitmap.c',
133  'nir_lower_blend.c',
134  'nir_lower_bool_to_bitsize.c',
135  'nir_lower_bool_to_float.c',
136  'nir_lower_bool_to_int32.c',
137  'nir_lower_clamp_color_outputs.c',
138  'nir_lower_clip.c',
139  'nir_lower_clip_cull_distance_arrays.c',
140  'nir_lower_clip_disable.c',
141  'nir_lower_clip_halfz.c',
142  'nir_lower_convert_alu_types.c',
143  'nir_lower_variable_initializers.c',
144  'nir_lower_discard_or_demote.c',
145  'nir_lower_double_ops.c',
146  'nir_lower_drawpixels.c',
147  'nir_lower_fb_read.c',
148  'nir_lower_flatshade.c',
149  'nir_lower_flrp.c',
150  'nir_lower_fp16_conv.c',
151  'nir_lower_fragcoord_wtrans.c',
152  'nir_lower_fragcolor.c',
153  'nir_lower_frexp.c',
154  'nir_lower_global_vars_to_local.c',
155  'nir_lower_goto_ifs.c',
156  'nir_lower_gs_intrinsics.c',
157  'nir_lower_load_const_to_scalar.c',
158  'nir_lower_locals_to_regs.c',
159  'nir_lower_idiv.c',
160  'nir_lower_image.c',
161  'nir_lower_indirect_derefs.c',
162  'nir_lower_input_attachments.c',
163  'nir_lower_int64.c',
164  'nir_lower_interpolation.c',
165  'nir_lower_int_to_float.c',
166  'nir_lower_io.c',
167  'nir_lower_io_arrays_to_elements.c',
168  'nir_lower_io_to_temporaries.c',
169  'nir_lower_io_to_scalar.c',
170  'nir_lower_io_to_vector.c',
171  'nir_lower_is_helper_invocation.c',
172  'nir_lower_multiview.c',
173  'nir_lower_mediump.c',
174  'nir_lower_memcpy.c',
175  'nir_lower_memory_model.c',
176  'nir_lower_non_uniform_access.c',
177  'nir_lower_packing.c',
178  'nir_lower_passthrough_edgeflags.c',
179  'nir_lower_patch_vertices.c',
180  'nir_lower_phis_to_scalar.c',
181  'nir_lower_pntc_ytransform.c',
182  'nir_lower_point_size.c',
183  'nir_lower_point_size_mov.c',
184  'nir_lower_printf.c',
185  'nir_lower_regs_to_ssa.c',
186  'nir_lower_readonly_images_to_tex.c',
187  'nir_lower_returns.c',
188  'nir_lower_samplers.c',
189  'nir_lower_scratch.c',
190  'nir_lower_shader_calls.c',
191  'nir_lower_ssbo.c',
192  'nir_lower_subgroups.c',
193  'nir_lower_system_values.c',
194  'nir_lower_tex.c',
195  'nir_lower_texcoord_replace.c',
196  'nir_lower_to_source_mods.c',
197  'nir_lower_two_sided_color.c',
198  'nir_lower_undef_to_zero.c',
199  'nir_lower_vars_to_ssa.c',
200  'nir_lower_var_copies.c',
201  'nir_lower_vec_to_movs.c',
202  'nir_lower_vec3_to_vec4.c',
203  'nir_lower_viewport_transform.c',
204  'nir_lower_wpos_center.c',
205  'nir_lower_wpos_ytransform.c',
206  'nir_lower_wrmasks.c',
207  'nir_lower_bit_size.c',
208  'nir_lower_ubo_vec4.c',
209  'nir_lower_uniforms_to_ubo.c',
210  'nir_lower_sysvals_to_varyings.c',
211  'nir_metadata.c',
212  'nir_move_vec_src_uses_to_dest.c',
213  'nir_normalize_cubemap_coords.c',
214  'nir_opt_access.c',
215  'nir_opt_barriers.c',
216  'nir_opt_combine_stores.c',
217  'nir_opt_comparison_pre.c',
218  'nir_opt_conditional_discard.c',
219  'nir_opt_constant_folding.c',
220  'nir_opt_copy_prop_vars.c',
221  'nir_opt_copy_propagate.c',
222  'nir_opt_cse.c',
223  'nir_opt_dce.c',
224  'nir_opt_dead_cf.c',
225  'nir_opt_dead_write_vars.c',
226  'nir_opt_find_array_copies.c',
227  'nir_opt_fragdepth.c',
228  'nir_opt_gcm.c',
229  'nir_opt_idiv_const.c',
230  'nir_opt_if.c',
231  'nir_opt_intrinsics.c',
232  'nir_opt_large_constants.c',
233  'nir_opt_load_store_vectorize.c',
234  'nir_opt_loop_unroll.c',
235  'nir_opt_memcpy.c',
236  'nir_opt_move.c',
237  'nir_opt_move_discards_to_top.c',
238  'nir_opt_offsets.c',
239  'nir_opt_peephole_select.c',
240  'nir_opt_phi_precision.c',
241  'nir_opt_rematerialize_compares.c',
242  'nir_opt_remove_phis.c',
243  'nir_opt_shrink_vectors.c',
244  'nir_opt_sink.c',
245  'nir_opt_trivial_continues.c',
246  'nir_opt_undef.c',
247  'nir_opt_uniform_atomics.c',
248  'nir_opt_vectorize.c',
249  'nir_phi_builder.c',
250  'nir_phi_builder.h',
251  'nir_print.c',
252  'nir_propagate_invariant.c',
253  'nir_range_analysis.c',
254  'nir_range_analysis.h',
255  'nir_remove_dead_variables.c',
256  'nir_repair_ssa.c',
257  'nir_schedule.c',
258  'nir_schedule.h',
259  'nir_search.c',
260  'nir_search.h',
261  'nir_search_helpers.h',
262  'nir_serialize.c',
263  'nir_serialize.h',
264  'nir_split_per_member_structs.c',
265  'nir_split_var_copies.c',
266  'nir_split_vars.c',
267  'nir_sweep.c',
268  'nir_to_lcssa.c',
269  'nir_validate.c',
270  'nir_vla.h',
271  'nir_vulkan.h',
272  'nir_worklist.c',
273  'nir_worklist.h',
274  'nir_xfb_info.h',
275  '../spirv/GLSL.ext.AMD.h',
276  '../spirv/GLSL.std.450.h',
277  '../spirv/gl_spirv.c',
278  '../spirv/nir_load_libclc.c',
279  '../spirv/nir_lower_libclc.c',
280  '../spirv/nir_spirv.h',
281  '../spirv/OpenCL.std.h',
282  '../spirv/spirv.h',
283  '../spirv/spirv_info.h',
284  '../spirv/spirv_to_nir.c',
285  '../spirv/vtn_alu.c',
286  '../spirv/vtn_amd.c',
287  '../spirv/vtn_cfg.c',
288  '../spirv/vtn_glsl450.c',
289  '../spirv/vtn_opencl.c',
290  '../spirv/vtn_private.h',
291  '../spirv/vtn_subgroup.c',
292  '../spirv/vtn_variables.c',
293)
294
295_libnir_args = []
296if dep_clc.found()
297  _basedir = dep_clc.get_variable(pkgconfig : 'libexecdir')
298
299  _static_libclc = get_option('static-libclc')
300  if _static_libclc.length() > 0
301    if _static_libclc.contains('all')
302      _static_libclc = ['spirv', 'spirv64']
303    endif
304
305    prog_zstd = find_program('zstd', required : false)
306    _zstd_static_libclc = dep_zstd.found() and prog_zstd.found()
307    if _zstd_static_libclc
308      _libnir_args += '-DHAVE_STATIC_LIBCLC_ZSTD'
309    endif
310
311    foreach s : _static_libclc
312      _libnir_args += '-DHAVE_STATIC_LIBCLC_@0@'.format(s.to_upper())
313      f = '@0@-mesa3d-.spv'.format(s)
314      _libclc_file = _basedir / f
315
316      if _zstd_static_libclc
317        _libclc_file = custom_target(
318          '@0@.zstd'.format(f),
319          command : [prog_zstd, '-f', '@INPUT@', '-o', '@OUTPUT@'],
320          input : [_libclc_file],
321          output : '@0@.zstd'.format(f),
322        )
323      endif
324
325      files_libnir += custom_target(
326        '@0@.h'.format(f),
327        command : [
328          prog_python, files_xxd, '-b', '@INPUT@', '@OUTPUT@',
329          '-n', 'libclc_@0@_mesa3d_spv'.format(s),
330        ],
331        input : [_libclc_file],
332        output : '@0@.h'.format(f),
333        depend_files : files_xxd,
334      )
335    endforeach
336  else
337    _libnir_args += ['-DDYNAMIC_LIBCLC_PATH="@0@/"'.format(_basedir)]
338    if not cc.has_function('mmap')
339      error('mmap required for dynamic libCLC loading')
340    endif
341  endif
342endif
343
344_libnir = static_library(
345  'nir',
346  [files_libnir, spirv_info_c, nir_opt_algebraic_c, nir_opcodes_c,
347   nir_opcodes_h, nir_constant_expressions_c, nir_builder_opcodes_h,
348   vtn_gather_types_c, nir_intrinsics_c, nir_intrinsics_h, nir_intrinsics_indices_h, vtn_generator_ids_h],
349  include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_compiler, include_directories('../spirv')],
350  c_args : [c_msvc_compat_args, no_override_init_args, _libnir_args],
351  gnu_symbol_visibility : 'hidden',
352  dependencies : dep_valgrind,
353  link_with : libcompiler,
354  build_by_default : false,
355)
356
357# Headers-only dependency
358idep_nir_headers = declare_dependency(
359  sources : [nir_opcodes_h, nir_builder_opcodes_h, nir_intrinsics_h, nir_intrinsics_indices_h],
360  include_directories : include_directories('.'),
361)
362
363# Also link with nir
364idep_nir = declare_dependency(
365  dependencies : [idep_nir_headers, idep_mesautil],
366  link_with : _libnir,
367)
368
369nir_algebraic_py = files('nir_algebraic.py')
370
371if with_tests
372  test(
373    'nir_builder',
374    executable(
375      'nir_builder_test',
376      files('tests/builder_tests.cpp'),
377      cpp_args : [cpp_msvc_compat_args],
378      gnu_symbol_visibility : 'hidden',
379      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
380      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
381    ),
382    suite : ['compiler', 'nir'],
383  )
384
385  test(
386    'nir_control_flow',
387    executable(
388      'nir_control_flow_test',
389      files('tests/control_flow_tests.cpp'),
390      cpp_args : [cpp_msvc_compat_args],
391      gnu_symbol_visibility : 'hidden',
392      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
393      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
394    ),
395    suite : ['compiler', 'nir'],
396  )
397
398  test(
399    'nir_core',
400    executable(
401      'nir_core_test',
402      files('tests/core_tests.cpp'),
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  )
410
411  test(
412    'nir_vars',
413    executable(
414      'nir_vars_test',
415      files('tests/vars_tests.cpp'),
416      cpp_args : [cpp_msvc_compat_args],
417      gnu_symbol_visibility : 'hidden',
418      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
419      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
420    ),
421    suite : ['compiler', 'nir'],
422  )
423
424  test(
425    'nir_algebraic_parser',
426    prog_python,
427    args : [
428      join_paths(meson.current_source_dir(), 'tests/algebraic_parser_test.py')
429    ],
430    suite : ['compiler', 'nir'],
431  )
432
433  test(
434    'negative_equal',
435    executable(
436      'negative_equal',
437      files('tests/negative_equal_tests.cpp'),
438      c_args : [c_msvc_compat_args, no_override_init_args],
439      gnu_symbol_visibility : 'hidden',
440      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
441      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
442    ),
443    suite : ['compiler', 'nir'],
444  )
445
446  test(
447    'comparison_pre',
448    executable(
449      'comparison_pre',
450      files('tests/comparison_pre_tests.cpp'),
451      c_args : [c_msvc_compat_args, no_override_init_args],
452      gnu_symbol_visibility : 'hidden',
453      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
454      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
455    ),
456    suite : ['compiler', 'nir'],
457  )
458
459  test(
460    'load_store_vectorizer',
461    executable(
462      'load_store_vectorizer',
463      files('tests/load_store_vectorizer_tests.cpp'),
464      cpp_args : [cpp_msvc_compat_args],
465      gnu_symbol_visibility : 'hidden',
466      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
467      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
468    ),
469    suite : ['compiler', 'nir'],
470    should_fail : meson.get_cross_property('xfail', '').contains('load_store_vectorizer'),
471  )
472
473  test(
474    'nir_serialize_test',
475    executable(
476      'nir_serialize_test',
477      files('tests/serialize_tests.cpp'),
478      cpp_args : [cpp_msvc_compat_args],
479      gnu_symbol_visibility : 'hidden',
480      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
481      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
482    ),
483    suite : ['compiler', 'nir'],
484  )
485
486  test(
487    'nir_opt_if',
488    executable(
489      'nir_opt_if_tests',
490      files('tests/opt_if_tests.cpp'),
491      cpp_args : [cpp_msvc_compat_args],
492      gnu_symbol_visibility : 'hidden',
493      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
494      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
495    ),
496    suite : ['compiler', 'nir'],
497  )
498
499  test(
500    'nir_lower_returns',
501    executable(
502      'nir_lower_returns_tests',
503      files('tests/lower_returns_tests.cpp'),
504      cpp_args : [cpp_msvc_compat_args],
505      gnu_symbol_visibility : 'hidden',
506      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
507      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
508    ),
509    suite : ['compiler', 'nir'],
510  )
511
512  test(
513    'ssa_def_bits_used',
514    executable(
515      'ssa_def_bits_used',
516      files('tests/ssa_def_bits_used_tests.cpp'),
517      c_args : [c_msvc_compat_args, no_override_init_args],
518      gnu_symbol_visibility : 'hidden',
519      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
520      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
521    ),
522    suite : ['compiler', 'nir'],
523  )
524
525  test(
526    'algebraic',
527    executable(
528      'algebraic',
529      files('tests/algebraic_tests.cpp'),
530      c_args : [c_msvc_compat_args, no_override_init_args],
531      gnu_symbol_visibility : 'hidden',
532      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
533      dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil],
534    ),
535    suite : ['compiler', 'nir'],
536  )
537endif
538