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_deref.c', 111 'nir_deref.h', 112 'nir_divergence_analysis.c', 113 'nir_dominance.c', 114 'nir_format_convert.h', 115 'nir_from_ssa.c', 116 'nir_functions.c', 117 'nir_gather_info.c', 118 'nir_gather_types.c', 119 'nir_gather_xfb_info.c', 120 'nir_group_loads.c', 121 'nir_gs_count_vertices.c', 122 'nir_inline_uniforms.c', 123 'nir_instr_set.c', 124 'nir_instr_set.h', 125 'nir_legacy.c', 126 'nir_legacy.h', 127 'nir_linking_helpers.c', 128 'nir_liveness.c', 129 'nir_loop_analyze.c', 130 'nir_loop_analyze.h', 131 'nir_lower_alu.c', 132 'nir_lower_alu_width.c', 133 'nir_lower_alpha_test.c', 134 'nir_lower_amul.c', 135 'nir_lower_array_deref_of_vec.c', 136 'nir_lower_atomics_to_ssbo.c', 137 'nir_lower_bitmap.c', 138 'nir_lower_blend.c', 139 'nir_lower_bool_to_bitsize.c', 140 'nir_lower_bool_to_float.c', 141 'nir_lower_bool_to_int32.c', 142 'nir_lower_cl_images.c', 143 'nir_lower_clamp_color_outputs.c', 144 'nir_lower_clip.c', 145 'nir_lower_clip_cull_distance_arrays.c', 146 'nir_lower_clip_disable.c', 147 'nir_lower_clip_halfz.c', 148 'nir_lower_const_arrays_to_uniforms.c', 149 'nir_lower_continue_constructs.c', 150 'nir_lower_convert_alu_types.c', 151 'nir_lower_variable_initializers.c', 152 'nir_lower_discard_if.c', 153 'nir_lower_discard_or_demote.c', 154 'nir_lower_double_ops.c', 155 'nir_lower_drawpixels.c', 156 'nir_lower_fb_read.c', 157 'nir_lower_flatshade.c', 158 'nir_lower_flrp.c', 159 'nir_lower_fp16_conv.c', 160 'nir_lower_fragcoord_wtrans.c', 161 'nir_lower_frag_coord_to_pixel_coord.c', 162 'nir_lower_fragcolor.c', 163 'nir_lower_frexp.c', 164 'nir_lower_global_vars_to_local.c', 165 'nir_lower_goto_ifs.c', 166 'nir_lower_gs_intrinsics.c', 167 'nir_lower_helper_writes.c', 168 'nir_lower_load_const_to_scalar.c', 169 'nir_lower_locals_to_regs.c', 170 'nir_lower_idiv.c', 171 'nir_lower_image.c', 172 'nir_lower_image_atomics_to_global.c', 173 'nir_lower_indirect_derefs.c', 174 'nir_lower_input_attachments.c', 175 'nir_lower_int64.c', 176 'nir_lower_interpolation.c', 177 'nir_lower_int_to_float.c', 178 'nir_lower_io.c', 179 'nir_lower_io_arrays_to_elements.c', 180 'nir_lower_io_to_temporaries.c', 181 'nir_lower_io_to_scalar.c', 182 'nir_lower_io_to_vector.c', 183 'nir_lower_is_helper_invocation.c', 184 'nir_lower_multiview.c', 185 'nir_lower_mediump.c', 186 'nir_lower_mem_access_bit_sizes.c', 187 'nir_lower_memcpy.c', 188 'nir_lower_memory_model.c', 189 'nir_lower_non_uniform_access.c', 190 'nir_lower_packing.c', 191 'nir_lower_passthrough_edgeflags.c', 192 'nir_lower_patch_vertices.c', 193 'nir_lower_phis_to_scalar.c', 194 'nir_lower_pntc_ytransform.c', 195 'nir_lower_point_size.c', 196 'nir_lower_point_size_mov.c', 197 'nir_lower_point_smooth.c', 198 'nir_lower_poly_line_smooth.c', 199 'nir_lower_printf.c', 200 'nir_lower_reg_intrinsics_to_ssa.c', 201 'nir_lower_readonly_images_to_tex.c', 202 'nir_lower_returns.c', 203 'nir_lower_robust_access.c', 204 'nir_lower_samplers.c', 205 'nir_lower_scratch.c', 206 'nir_lower_shader_calls.c', 207 'nir_lower_single_sampled.c', 208 'nir_lower_ssbo.c', 209 'nir_lower_subgroups.c', 210 'nir_lower_system_values.c', 211 'nir_lower_task_shader.c', 212 'nir_lower_tess_coord_z.c', 213 'nir_lower_tex_shadow.c', 214 'nir_lower_tex.c', 215 'nir_lower_texcoord_replace.c', 216 'nir_lower_texcoord_replace_late.c', 217 'nir_lower_two_sided_color.c', 218 'nir_lower_undef_to_zero.c', 219 'nir_lower_vars_to_ssa.c', 220 'nir_lower_var_copies.c', 221 'nir_lower_vec_to_regs.c', 222 'nir_lower_vec3_to_vec4.c', 223 'nir_lower_viewport_transform.c', 224 'nir_lower_wpos_center.c', 225 'nir_lower_wpos_ytransform.c', 226 'nir_lower_wrmasks.c', 227 'nir_lower_bit_size.c', 228 'nir_lower_ubo_vec4.c', 229 'nir_lower_uniforms_to_ubo.c', 230 'nir_lower_sysvals_to_varyings.c', 231 'nir_metadata.c', 232 'nir_mod_analysis.c', 233 'nir_move_vec_src_uses_to_dest.c', 234 'nir_normalize_cubemap_coords.c', 235 'nir_opt_access.c', 236 'nir_opt_barriers.c', 237 'nir_opt_combine_stores.c', 238 'nir_opt_comparison_pre.c', 239 'nir_opt_conditional_discard.c', 240 'nir_opt_constant_folding.c', 241 'nir_opt_copy_prop_vars.c', 242 'nir_opt_copy_propagate.c', 243 'nir_opt_cse.c', 244 'nir_opt_dce.c', 245 'nir_opt_dead_cf.c', 246 'nir_opt_dead_write_vars.c', 247 'nir_opt_find_array_copies.c', 248 'nir_opt_fragdepth.c', 249 'nir_opt_gcm.c', 250 'nir_opt_idiv_const.c', 251 'nir_opt_if.c', 252 'nir_opt_intrinsics.c', 253 'nir_opt_large_constants.c', 254 'nir_opt_load_store_vectorize.c', 255 'nir_opt_loop.c', 256 'nir_opt_loop_unroll.c', 257 'nir_opt_memcpy.c', 258 'nir_opt_move.c', 259 'nir_opt_move_discards_to_top.c', 260 'nir_opt_non_uniform_access.c', 261 'nir_opt_offsets.c', 262 'nir_opt_peephole_select.c', 263 'nir_opt_phi_precision.c', 264 'nir_opt_preamble.c', 265 'nir_opt_ray_queries.c', 266 'nir_opt_reassociate_bfi.c', 267 'nir_opt_rematerialize_compares.c', 268 'nir_opt_remove_phis.c', 269 'nir_opt_reuse_constants.c', 270 'nir_opt_shrink_stores.c', 271 'nir_opt_shrink_vectors.c', 272 'nir_opt_sink.c', 273 'nir_opt_undef.c', 274 'nir_opt_uniform_atomics.c', 275 'nir_opt_uniform_subgroup.c', 276 'nir_opt_vectorize.c', 277 'nir_passthrough_gs.c', 278 'nir_passthrough_tcs.c', 279 'nir_phi_builder.c', 280 'nir_phi_builder.h', 281 'nir_print.c', 282 'nir_propagate_invariant.c', 283 'nir_range_analysis.c', 284 'nir_range_analysis.h', 285 'nir_remove_dead_variables.c', 286 'nir_remove_tex_shadow.c', 287 'nir_repair_ssa.c', 288 'nir_scale_fdiv.c', 289 'nir_schedule.c', 290 'nir_schedule.h', 291 'nir_search.c', 292 'nir_search.h', 293 'nir_search_helpers.h', 294 'nir_serialize.c', 295 'nir_serialize.h', 296 'nir_split_64bit_vec3_and_vec4.c', 297 'nir_split_per_member_structs.c', 298 'nir_split_var_copies.c', 299 'nir_split_vars.c', 300 'nir_sweep.c', 301 'nir_to_lcssa.c', 302 'nir_trivialize_registers.c', 303 'nir_validate.c', 304 'nir_vla.h', 305 'nir_worklist.c', 306 'nir_worklist.h', 307 'nir_xfb_info.h', 308) 309 310# When a file is too large, -Wmisleading-indentation will give a note about 311# not being able to process it, however that is not suppressable by a #pragma 312# in GCC. This happens with the generated code in nir_opt_algebraic.c. 313# 314# As a workaround, drop the warning for GCC. Clang builds should cover this. 315no_misleading_indentation = [] 316if cc.get_id() == 'gcc' 317 no_misleading_indentation += cc.get_supported_arguments('-Wno-misleading-indentation') 318endif 319 320_libnir = static_library( 321 'nir', 322 [files_libnir, nir_opt_algebraic_c, nir_opcodes_c, 323 nir_opcodes_h, nir_constant_expressions_c, nir_builder_opcodes_h, 324 nir_intrinsics_c, nir_intrinsics_h, nir_intrinsics_indices_h], 325 include_directories : [inc_include, inc_src], 326 c_args : [c_msvc_compat_args, no_override_init_args, no_misleading_indentation], 327 gnu_symbol_visibility : 'hidden', 328 dependencies : [idep_compiler, dep_valgrind], 329 build_by_default : false, 330) 331 332inc_nir = include_directories('.') 333 334# Headers-only dependency 335idep_nir_headers = declare_dependency( 336 sources : [nir_opcodes_h, nir_builder_opcodes_h, nir_intrinsics_h, nir_intrinsics_indices_h, 337 ir_expression_operation_h, builtin_types_h], 338 include_directories : [inc_nir, inc_compiler], 339) 340 341# Also link with nir 342idep_nir = declare_dependency( 343 dependencies : [idep_nir_headers, idep_mesautil, idep_compiler], 344 link_with : _libnir, 345) 346 347if with_tests 348 if cc.get_id() == 'msvc' and cc.version().version_compare('< 19.29') 349 msvc_designated_initializer = 'cpp_std=c++latest' 350 else 351 msvc_designated_initializer = 'cpp_std=c++20' 352 endif 353 354 test( 355 'nir_tests', 356 executable( 357 'nir_tests', 358 files( 359 'tests/algebraic_tests.cpp', 360 'tests/builder_tests.cpp', 361 'tests/comparison_pre_tests.cpp', 362 'tests/control_flow_tests.cpp', 363 'tests/core_tests.cpp', 364 'tests/dce_tests.cpp', 365 'tests/load_store_vectorizer_tests.cpp', 366 'tests/loop_analyze_tests.cpp', 367 'tests/loop_unroll_tests.cpp', 368 'tests/lower_alu_width_tests.cpp', 369 'tests/mod_analysis_tests.cpp', 370 'tests/negative_equal_tests.cpp', 371 'tests/opt_if_tests.cpp', 372 'tests/opt_peephole_select.cpp', 373 'tests/opt_shrink_vectors_tests.cpp', 374 'tests/serialize_tests.cpp', 375 'tests/range_analysis_tests.cpp', 376 'tests/vars_tests.cpp', 377 ), 378 cpp_args : [cpp_msvc_compat_args], 379 override_options: [msvc_designated_initializer], 380 gnu_symbol_visibility : 'hidden', 381 include_directories : [inc_include, inc_src], 382 dependencies : [dep_thread, idep_gtest, idep_nir, idep_mesautil], 383 ), 384 suite : ['compiler', 'nir'], 385 protocol : 'gtest', 386 ) 387 388 test( 389 'nir_algebraic_parser', 390 prog_python, 391 args : [ 392 files('tests/algebraic_parser_test.py') 393 ], 394 suite : ['compiler', 'nir'], 395 ) 396endif 397