2017-09-14 17:57:17 -07:00
|
|
|
# Copyright © 2017 Intel Corporation
|
|
|
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
|
2018-05-02 12:43:50 -04:00
|
|
|
nir_depends = files('nir_opcodes.py', 'nir_intrinsics.py')
|
2017-09-14 17:57:17 -07:00
|
|
|
|
|
|
|
nir_builder_opcodes_h = custom_target(
|
|
|
|
'nir_builder_opcodes.h',
|
|
|
|
input : 'nir_builder_opcodes_h.py',
|
|
|
|
output : 'nir_builder_opcodes.h',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@'],
|
2017-09-14 17:57:17 -07:00
|
|
|
capture : true,
|
|
|
|
depend_files : nir_depends,
|
|
|
|
)
|
|
|
|
|
|
|
|
nir_constant_expressions_c = custom_target(
|
|
|
|
'nir_constant_expressions.c',
|
|
|
|
input : 'nir_constant_expressions.py',
|
|
|
|
output : 'nir_constant_expressions.c',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@'],
|
2017-09-14 17:57:17 -07:00
|
|
|
capture : true,
|
|
|
|
depend_files : nir_depends,
|
|
|
|
)
|
|
|
|
|
|
|
|
nir_opcodes_h = custom_target(
|
|
|
|
'nir_opcodes.h',
|
|
|
|
input : 'nir_opcodes_h.py',
|
|
|
|
output : 'nir_opcodes.h',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@'],
|
2017-09-14 17:57:17 -07:00
|
|
|
capture : true,
|
|
|
|
depend_files : nir_depends,
|
|
|
|
)
|
|
|
|
|
|
|
|
nir_opcodes_c = custom_target(
|
|
|
|
'nir_opcodes.c',
|
|
|
|
input : 'nir_opcodes_c.py',
|
|
|
|
output : 'nir_opcodes.c',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@'],
|
2017-09-14 17:57:17 -07:00
|
|
|
capture : true,
|
|
|
|
depend_files : nir_depends,
|
|
|
|
)
|
|
|
|
|
|
|
|
nir_opt_algebraic_c = custom_target(
|
|
|
|
'nir_opt_algebraic.c',
|
|
|
|
input : 'nir_opt_algebraic.py',
|
|
|
|
output : 'nir_opt_algebraic.c',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@'],
|
2017-09-14 17:57:17 -07:00
|
|
|
capture : true,
|
|
|
|
depend_files : files('nir_algebraic.py'),
|
|
|
|
)
|
|
|
|
|
2018-03-15 18:42:44 -04:00
|
|
|
nir_intrinsics_h = custom_target(
|
|
|
|
'nir_intrinsics.h',
|
|
|
|
input : 'nir_intrinsics_h.py',
|
|
|
|
output : 'nir_intrinsics.h',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@', '--outdir', meson.current_build_dir()],
|
2018-03-15 18:42:44 -04:00
|
|
|
capture : false,
|
|
|
|
depend_files : files('nir_intrinsics.py'),
|
|
|
|
)
|
|
|
|
|
|
|
|
nir_intrinsics_c = custom_target(
|
|
|
|
'nir_intrinsic.c',
|
|
|
|
input : 'nir_intrinsics_c.py',
|
|
|
|
output : 'nir_intrinsics.c',
|
2018-08-09 10:27:26 +02:00
|
|
|
command : [prog_python, '@INPUT@', '--outdir', meson.current_build_dir()],
|
2018-03-15 18:42:44 -04:00
|
|
|
capture: false,
|
|
|
|
depend_files : files('nir_intrinsics.py'),
|
|
|
|
)
|
|
|
|
|
2017-09-14 17:57:17 -07:00
|
|
|
files_libnir = files(
|
|
|
|
'nir.c',
|
|
|
|
'nir.h',
|
|
|
|
'nir_builder.h',
|
2018-04-25 18:19:23 +02:00
|
|
|
'nir_builtin_builder.c',
|
|
|
|
'nir_builtin_builder.h',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_clone.c',
|
|
|
|
'nir_constant_expressions.h',
|
|
|
|
'nir_control_flow.c',
|
|
|
|
'nir_control_flow.h',
|
|
|
|
'nir_control_flow_private.h',
|
2018-03-16 01:15:47 -07:00
|
|
|
'nir_deref.c',
|
2018-03-20 11:11:25 -07:00
|
|
|
'nir_deref.h',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_dominance.c',
|
2017-10-20 09:35:48 -07:00
|
|
|
'nir_format_convert.h',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_from_ssa.c',
|
|
|
|
'nir_gather_info.c',
|
2019-01-05 09:13:44 -06:00
|
|
|
'nir_gather_ssa_types.c',
|
2018-10-05 09:13:25 -05:00
|
|
|
'nir_gather_xfb_info.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_gs_count_vertices.c',
|
|
|
|
'nir_inline_functions.c',
|
|
|
|
'nir_instr_set.c',
|
|
|
|
'nir_instr_set.h',
|
2017-10-04 16:50:50 -07:00
|
|
|
'nir_linking_helpers.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_liveness.c',
|
|
|
|
'nir_loop_analyze.c',
|
|
|
|
'nir_loop_analyze.h',
|
2018-05-08 11:24:40 -07:00
|
|
|
'nir_lower_alu.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_alu_to_scalar.c',
|
2017-02-22 16:53:18 -08:00
|
|
|
'nir_lower_alpha_test.c',
|
2019-03-11 18:47:39 -05:00
|
|
|
'nir_lower_array_deref_of_vec.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_atomics_to_ssbo.c',
|
|
|
|
'nir_lower_bitmap.c',
|
2018-10-22 16:44:59 -05:00
|
|
|
'nir_lower_bool_to_float.c',
|
2018-10-18 12:04:09 -05:00
|
|
|
'nir_lower_bool_to_int32.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_clamp_color_outputs.c',
|
|
|
|
'nir_lower_clip.c',
|
|
|
|
'nir_lower_clip_cull_distance_arrays.c',
|
|
|
|
'nir_lower_constant_initializers.c',
|
|
|
|
'nir_lower_double_ops.c',
|
|
|
|
'nir_lower_drawpixels.c',
|
2019-04-26 10:05:08 -07:00
|
|
|
'nir_lower_fb_read.c',
|
2018-08-18 11:46:46 -07:00
|
|
|
'nir_lower_flrp.c',
|
2019-04-26 15:01:43 +02:00
|
|
|
'nir_lower_fragcoord_wtrans.c',
|
2019-03-22 09:24:57 +01:00
|
|
|
'nir_lower_frexp.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_global_vars_to_local.c',
|
|
|
|
'nir_lower_gs_intrinsics.c',
|
|
|
|
'nir_lower_load_const_to_scalar.c',
|
|
|
|
'nir_lower_locals_to_regs.c',
|
|
|
|
'nir_lower_idiv.c',
|
|
|
|
'nir_lower_indirect_derefs.c',
|
2019-04-03 17:29:20 +02:00
|
|
|
'nir_lower_input_attachments.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_int64.c',
|
2019-04-03 19:29:36 -04:00
|
|
|
'nir_lower_interpolation.c',
|
2019-04-30 22:25:05 -07:00
|
|
|
'nir_lower_int_to_float.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_io.c',
|
2017-10-23 15:51:29 +11:00
|
|
|
'nir_lower_io_arrays_to_elements.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_io_to_temporaries.c',
|
|
|
|
'nir_lower_io_to_scalar.c',
|
2019-03-06 15:21:51 -06:00
|
|
|
'nir_lower_io_to_vector.c',
|
2019-02-27 14:36:44 -06:00
|
|
|
'nir_lower_non_uniform_access.c',
|
2018-04-27 09:28:48 +02:00
|
|
|
'nir_lower_packing.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_passthrough_edgeflags.c',
|
|
|
|
'nir_lower_patch_vertices.c',
|
|
|
|
'nir_lower_phis_to_scalar.c',
|
|
|
|
'nir_lower_regs_to_ssa.c',
|
|
|
|
'nir_lower_returns.c',
|
2016-12-02 11:36:42 -08:00
|
|
|
'nir_lower_scratch.c',
|
2017-08-22 13:23:59 -07:00
|
|
|
'nir_lower_subgroups.c',
|
2019-04-07 13:24:45 -07:00
|
|
|
'nir_lower_sincos.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_system_values.c',
|
|
|
|
'nir_lower_tex.c',
|
|
|
|
'nir_lower_to_source_mods.c',
|
|
|
|
'nir_lower_two_sided_color.c',
|
|
|
|
'nir_lower_vars_to_ssa.c',
|
|
|
|
'nir_lower_var_copies.c',
|
|
|
|
'nir_lower_vec_to_movs.c',
|
2019-04-14 15:43:13 +00:00
|
|
|
'nir_lower_viewport_transform.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_lower_wpos_center.c',
|
|
|
|
'nir_lower_wpos_ytransform.c',
|
2018-04-26 10:02:04 +02:00
|
|
|
'nir_lower_bit_size.c',
|
2019-02-08 22:36:37 +01:00
|
|
|
'nir_lower_uniforms_to_ubo.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_metadata.c',
|
2018-06-06 10:11:45 -04:00
|
|
|
'nir_move_load_const.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_move_vec_src_uses_to_dest.c',
|
|
|
|
'nir_normalize_cubemap_coords.c',
|
2019-03-08 10:08:20 -08:00
|
|
|
'nir_opt_combine_stores.c',
|
2018-05-22 18:19:16 -07:00
|
|
|
'nir_opt_comparison_pre.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_opt_conditional_discard.c',
|
|
|
|
'nir_opt_constant_folding.c',
|
|
|
|
'nir_opt_copy_prop_vars.c',
|
|
|
|
'nir_opt_copy_propagate.c',
|
|
|
|
'nir_opt_cse.c',
|
|
|
|
'nir_opt_dce.c',
|
|
|
|
'nir_opt_dead_cf.c',
|
2018-07-27 13:56:35 -07:00
|
|
|
'nir_opt_dead_write_vars.c',
|
2018-07-23 19:16:56 -07:00
|
|
|
'nir_opt_find_array_copies.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_opt_gcm.c',
|
2017-12-28 13:06:28 -08:00
|
|
|
'nir_opt_idiv_const.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_opt_if.c',
|
|
|
|
'nir_opt_intrinsics.c',
|
2018-06-28 19:16:58 -07:00
|
|
|
'nir_opt_large_constants.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_opt_loop_unroll.c',
|
|
|
|
'nir_opt_move_comparisons.c',
|
2018-01-26 12:38:57 +01:00
|
|
|
'nir_opt_move_load_ubo.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_opt_peephole_select.c',
|
nir: Rematerialize compare instructions
On some architectures, Boolean values used to control conditional
branches or condtional selection must be propagated into a flag. This
generally means that a stored Boolean value must be compared with zero.
Rather than force the generation of extra compares with zero, re-emit
the original comparison instruction. This can save register pressure by
not needing to store the Boolean value.
There are several possible ares for future improvement to this pass:
1. Be more conservative. If both sources to the comparison instruction
are non-constants, it may be better for register pressure to emit the
extra compare. The current shader-db results on Intel GPUs (next
commit) lead me to believe that this is not currently a problem.
2. Be less conservative. Currently the pass requires that all users of
the comparison match the pattern. The idea is that after the pass is
complete, no instruction will use the resulting Boolean value. The only
uses will be of the flag value. It may be beneficial to relax this
requirement in some cases.
3. Be less conservative. Also try to rematerialize comparisons used for
discard_if intrinsics. After changing the way the Intel compiler
generates cod e for discard_if (see MR!935), I tried implementing this
already. The changes were pretty small. Instructions were helped in 19
shaders, but, overall, cycles were hurt. A commit "nir: Rematerialize
comparisons for nir_intrinsic_discard_if too" is on my fd.o cgit.
4. Copy the preceeding ALU instruction. If the comparison is a
comparison with zero, and it is the only user of a particular ALU
instruction (e.g., (a+b) != 0.0), it may be a further improvment to also
copy the preceeding ALU instruction. On Intel GPUs, this may enable
cmod propagation to make additional progress.
v2: Use much simpler method to get the prev_block for an if-statement.
Suggested by Tim.
Reviewed-by: Matt Turner <mattst88@gmail.com>
2019-05-20 11:22:12 -07:00
|
|
|
'nir_opt_rematerialize_compares.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_opt_remove_phis.c',
|
2018-01-29 17:19:00 +01:00
|
|
|
'nir_opt_shrink_load.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_opt_trivial_continues.c',
|
|
|
|
'nir_opt_undef.c',
|
2015-11-14 20:26:47 -05:00
|
|
|
'nir_opt_vectorize.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_phi_builder.c',
|
|
|
|
'nir_phi_builder.h',
|
|
|
|
'nir_print.c',
|
|
|
|
'nir_propagate_invariant.c',
|
|
|
|
'nir_remove_dead_variables.c',
|
|
|
|
'nir_repair_ssa.c',
|
|
|
|
'nir_search.c',
|
|
|
|
'nir_search.h',
|
|
|
|
'nir_search_helpers.h',
|
2017-09-12 23:17:51 -04:00
|
|
|
'nir_serialize.c',
|
|
|
|
'nir_serialize.h',
|
2019-03-04 17:51:12 +01:00
|
|
|
'nir_strip.c',
|
2018-03-21 16:48:35 -07:00
|
|
|
'nir_split_per_member_structs.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_split_var_copies.c',
|
2018-07-24 10:08:06 -07:00
|
|
|
'nir_split_vars.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'nir_sweep.c',
|
|
|
|
'nir_to_lcssa.c',
|
|
|
|
'nir_validate.c',
|
|
|
|
'nir_vla.h',
|
|
|
|
'nir_worklist.c',
|
|
|
|
'nir_worklist.h',
|
2018-10-05 09:13:25 -05:00
|
|
|
'nir_xfb_info.h',
|
2018-03-19 13:08:32 +01:00
|
|
|
'../spirv/GLSL.ext.AMD.h',
|
2017-09-14 17:57:17 -07:00
|
|
|
'../spirv/GLSL.std.450.h',
|
2018-01-18 12:31:52 +01:00
|
|
|
'../spirv/gl_spirv.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'../spirv/nir_spirv.h',
|
2018-07-12 15:02:27 +02:00
|
|
|
'../spirv/OpenCL.std.h',
|
2017-09-14 17:57:17 -07:00
|
|
|
'../spirv/spirv.h',
|
|
|
|
'../spirv/spirv_info.h',
|
|
|
|
'../spirv/spirv_to_nir.c',
|
|
|
|
'../spirv/vtn_alu.c',
|
2018-02-23 13:54:59 +01:00
|
|
|
'../spirv/vtn_amd.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'../spirv/vtn_cfg.c',
|
|
|
|
'../spirv/vtn_glsl450.c',
|
2018-07-12 15:02:27 +02:00
|
|
|
'../spirv/vtn_opencl.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'../spirv/vtn_private.h',
|
2017-04-28 04:45:50 -07:00
|
|
|
'../spirv/vtn_subgroup.c',
|
2017-09-14 17:57:17 -07:00
|
|
|
'../spirv/vtn_variables.c',
|
|
|
|
)
|
|
|
|
|
|
|
|
libnir = static_library(
|
|
|
|
'nir',
|
|
|
|
[files_libnir, spirv_info_c, nir_opt_algebraic_c, nir_opcodes_c,
|
2017-12-05 22:31:02 -08:00
|
|
|
nir_opcodes_h, nir_constant_expressions_c, nir_builder_opcodes_h,
|
2018-03-15 18:42:44 -04:00
|
|
|
vtn_gather_types_c, nir_intrinsics_c, nir_intrinsics_h],
|
2017-09-14 17:57:17 -07:00
|
|
|
include_directories : [inc_common, inc_compiler, include_directories('../spirv')],
|
|
|
|
c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
|
|
|
|
link_with : libcompiler,
|
|
|
|
build_by_default : false,
|
|
|
|
)
|
|
|
|
|
2017-12-12 12:22:56 -08:00
|
|
|
# Headers-only dependency
|
|
|
|
idep_nir_headers = declare_dependency(
|
2018-03-15 18:42:44 -04:00
|
|
|
sources : [nir_opcodes_h, nir_builder_opcodes_h, nir_intrinsics_h],
|
2017-12-12 12:22:56 -08:00
|
|
|
include_directories : include_directories('.'),
|
|
|
|
)
|
|
|
|
|
|
|
|
# Also link with nir
|
|
|
|
idep_nir = declare_dependency(
|
|
|
|
dependencies : idep_nir_headers,
|
|
|
|
link_with : libnir,
|
|
|
|
)
|
|
|
|
|
2017-10-24 11:07:52 -04:00
|
|
|
nir_algebraic_py = files('nir_algebraic.py')
|
|
|
|
|
2017-09-14 17:57:17 -07:00
|
|
|
if with_tests
|
2017-12-11 16:13:31 -08:00
|
|
|
test(
|
|
|
|
'nir_control_flow',
|
|
|
|
executable(
|
|
|
|
'nir_control_flow_test',
|
2017-12-12 12:22:56 -08:00
|
|
|
files('tests/control_flow_tests.cpp'),
|
2018-05-22 15:34:38 -07:00
|
|
|
cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
|
2017-12-11 16:13:31 -08:00
|
|
|
include_directories : [inc_common],
|
2017-12-12 12:22:56 -08:00
|
|
|
dependencies : [dep_thread, idep_gtest, idep_nir],
|
|
|
|
link_with : libmesa_util,
|
2018-11-19 13:44:15 -08:00
|
|
|
),
|
|
|
|
suite : ['compiler', 'nir'],
|
2017-09-14 17:57:17 -07:00
|
|
|
)
|
2018-11-19 13:44:15 -08:00
|
|
|
|
2018-08-29 16:30:09 -07:00
|
|
|
test(
|
|
|
|
'nir_vars',
|
|
|
|
executable(
|
|
|
|
'nir_vars_test',
|
|
|
|
files('tests/vars_tests.cpp'),
|
|
|
|
cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
|
|
|
|
include_directories : [inc_common],
|
|
|
|
dependencies : [dep_thread, idep_gtest, idep_nir],
|
|
|
|
link_with : libmesa_util,
|
2018-11-19 13:44:15 -08:00
|
|
|
),
|
|
|
|
suite : ['compiler', 'nir'],
|
2018-08-29 16:30:09 -07:00
|
|
|
)
|
2018-11-29 17:46:59 +01:00
|
|
|
test(
|
|
|
|
'nir_algebraic_parser',
|
|
|
|
prog_python,
|
|
|
|
args : [
|
|
|
|
join_paths(meson.current_source_dir(), 'tests/algebraic_parser_test.py')
|
|
|
|
],
|
2018-12-07 09:15:27 -08:00
|
|
|
suite : ['compiler', 'nir'],
|
2018-11-29 17:46:59 +01:00
|
|
|
)
|
2018-05-24 11:37:51 -07:00
|
|
|
|
|
|
|
test(
|
|
|
|
'negative_equal',
|
|
|
|
executable(
|
|
|
|
'negative_equal',
|
|
|
|
files('tests/negative_equal_tests.cpp'),
|
|
|
|
c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
|
|
|
|
include_directories : [inc_common],
|
|
|
|
dependencies : [dep_thread, idep_gtest, idep_nir],
|
|
|
|
link_with : libmesa_util,
|
|
|
|
)
|
|
|
|
)
|
2019-06-17 16:27:37 -07:00
|
|
|
|
|
|
|
test(
|
|
|
|
'comparison_pre',
|
|
|
|
executable(
|
|
|
|
'comparison_pre',
|
|
|
|
files('tests/comparison_pre_tests.cpp'),
|
|
|
|
c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
|
|
|
|
include_directories : [inc_common],
|
|
|
|
dependencies : [dep_thread, idep_gtest, idep_nir],
|
|
|
|
link_with : libmesa_util,
|
|
|
|
)
|
|
|
|
)
|
2017-09-14 17:57:17 -07:00
|
|
|
endif
|