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