mesa/src/compiler/nir
Rhys Perry 368be87255 nir/algebraic: shrink 64-bit bitwise operations with 0/-1 constant half
fossil-db (navi21):
Totals from 457 (0.34% of 135636) affected shaders:
Instrs: 259349 -> 250383 (-3.46%)
CodeSize: 1411976 -> 1369136 (-3.03%)
Latency: 2175961 -> 2148158 (-1.28%)
InvThroughput: 502206 -> 490244 (-2.38%)
Copies: 15238 -> 15232 (-0.04%); split: -0.07%, +0.03%

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19748>
2022-11-21 17:34:46 +00:00
..
tests nir: Fixes [-Wdeprecated-declarations] in serialize_tests.cpp 2022-08-23 15:19:16 +00:00
README
meson.build nir: Add helper to create passthrough TCS shader 2022-10-24 21:39:38 +00:00
nir.c nir: Fix nir_chase_binding() vecN handling 2022-11-18 11:57:05 +00:00
nir.h nir/range_analysis: Set higher default maximum for max_workgroup_count 2022-11-19 05:40:42 +00:00
nir_algebraic.py nir/algebraic: support CL vector accessors 2022-10-29 10:31:39 +00:00
nir_builder.c nir: Add a common gen_rect_vertices implementation 2022-07-19 12:47:30 +00:00
nir_builder.h nir: Add a common gen_rect_vertices implementation 2022-07-19 12:47:30 +00:00
nir_builder_opcodes_h.py nir/builder: assume scalar alignment if not provided 2022-01-21 13:45:33 +00:00
nir_builtin_builder.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_builtin_builder.h nir: Fix nir_fmax_abs_vec_comp 2022-10-17 20:46:24 +00:00
nir_clone.c nir: use a GC context for instructions 2022-08-30 18:21:44 +00:00
nir_constant_expressions.h
nir_constant_expressions.py nir: introduce nir_pack_{sint,uint}_2x16 instructions 2022-03-04 08:06:56 +00:00
nir_control_flow.c nir: use a GC context for instructions 2022-08-30 18:21:44 +00:00
nir_control_flow.h nir/cf: Return a cursor from nir_cf_extract as well 2022-05-09 08:43:40 +00:00
nir_control_flow_private.h
nir_conversion_builder.h
nir_convert_ycbcr.c
nir_deref.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_deref.h
nir_divergence_analysis.c nir,ac/llvm,radeonsi: add nir_load_clamp_vertex_color_amd 2022-11-11 04:22:20 +00:00
nir_dominance.c
nir_format_convert.h
nir_from_ssa.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_gather_info.c nir/gather_info: take texture vars into account when counting textures 2022-11-10 10:21:34 +00:00
nir_gather_ssa_types.c
nir_gather_xfb_info.c glsl/nir: Stash the xfb_info in the nir_shader when linking XFB 2022-05-31 23:09:30 +00:00
nir_group_loads.c nir: add nir_intrinsic_image_samples_identical 2022-08-03 17:44:15 +00:00
nir_gs_count_vertices.c
nir_inline_functions.c
nir_inline_helpers.h
nir_inline_uniforms.c nir: update nir_is_supported_terminator_condition() 2022-09-08 01:01:14 +00:00
nir_instr_set.c nir: Fix qsort comparator function 2022-11-05 00:09:00 +00:00
nir_instr_set.h
nir_intrinsics.py nir: Define AGX intrinsics for local pixel access 2022-11-19 20:25:41 +00:00
nir_intrinsics_c.py
nir_intrinsics_h.py
nir_intrinsics_indices_h.py nir: add transform feedback info into nir_intrinsic_store_output 2022-03-01 21:59:55 +00:00
nir_linking_helpers.c nir: call nir_metadata_preserve at nir_remove_unused_io_vars 2022-07-20 11:35:24 +00:00
nir_liveness.c nir: Delete the per-instr SSA liveness impl. 2022-02-10 00:36:57 +00:00
nir_loop_analyze.c nir: track whether a loop contains soft fp64 ops 2022-09-30 17:07:37 +00:00
nir_loop_analyze.h nir: update nir_is_supported_terminator_condition() 2022-09-08 01:01:14 +00:00
nir_lower_alpha_test.c
nir_lower_alu.c nir: use nir_shader_instructions_pass in nir_lower_alu 2022-09-26 11:13:03 +00:00
nir_lower_alu_width.c Revert "nir: Drop the unused instr arg for src/dest copy functions." 2022-08-30 18:21:44 +00:00
nir_lower_amul.c
nir_lower_array_deref_of_vec.c
nir_lower_atomics_to_ssbo.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_lower_bit_size.c nir/lower_bit_size: lower uadd_sat/iadd_sat/isub_sat to unsaturated alu 2022-11-18 18:31:32 +00:00
nir_lower_bitmap.c
nir_lower_blend.c nir/lower_blend: Avoid emitting unnecessary fsats 2022-09-12 23:44:54 +00:00
nir_lower_blend.h util: Move src/gallium/include/pipe/p_format.h to src/util/format/u_formats.h 2022-11-19 03:38:19 +00:00
nir_lower_bool_to_bitsize.c nir: use nir_shader_instructions_pass in nir_lower_bool_to_bitsize 2022-09-26 11:13:03 +00:00
nir_lower_bool_to_float.c nir: use nir_shader_instructions_pass in nir_lower_bool_to_float 2022-09-26 11:13:03 +00:00
nir_lower_bool_to_int32.c nir/lower_bool_to_int32: add support for lowering functions. 2022-10-26 21:47:29 +00:00
nir_lower_cl_images.c nir/lower_cl_images: support keeping derefs 2022-11-10 10:21:34 +00:00
nir_lower_clamp_color_outputs.c nir: use nir_shader_instructions_pass in nir_lower_clamp_color_outputs 2022-09-26 11:13:03 +00:00
nir_lower_clip.c nir/lower_clip: support clipdist array + no vars 2021-11-28 04:44:56 +00:00
nir_lower_clip_cull_distance_arrays.c nir: handle per-view clip/cull distances 2022-01-11 22:45:23 +00:00
nir_lower_clip_disable.c nir: use nir_shader_instructions_pass in nir_lower_clip_disable 2022-09-26 11:13:03 +00:00
nir_lower_clip_halfz.c nir: use nir_shader_instructions_pass in nir_lower_clip_halfz 2022-09-26 11:13:03 +00:00
nir_lower_const_arrays_to_uniforms.c nir: Add an options parameter to deref_instr_has_complex_use 2022-06-24 19:21:26 +00:00
nir_lower_convert_alu_types.c
nir_lower_discard_if.c nir: Make nir_lower_discard_if() handle demotes and terminates, too. 2022-08-31 18:26:19 +00:00
nir_lower_discard_or_demote.c
nir_lower_double_ops.c nir: Add assert in nir_lower_doubles 2022-10-28 10:08:50 +00:00
nir_lower_drawpixels.c nir: use nir_shader_instructions_pass in nir_lower_drawpixels 2022-09-26 11:13:03 +00:00
nir_lower_fb_read.c nir: use nir_shader_instructions_pass in nir_lower_fb_read 2022-09-26 11:13:03 +00:00
nir_lower_flatshade.c
nir_lower_flrp.c
nir_lower_fp16_conv.c
nir_lower_fragcolor.c
nir_lower_fragcoord_wtrans.c
nir_lower_frexp.c nir: use nir_shader_instructions_pass in nir_lower_frexp 2022-09-26 11:13:03 +00:00
nir_lower_global_vars_to_local.c
nir_lower_goto_ifs.c
nir_lower_gs_intrinsics.c nir: use nir_metadata_none instead of its value 2022-09-26 11:13:03 +00:00
nir_lower_idiv.c nir/lower_idiv: Inline convert_instr_precise 2022-10-27 19:37:14 +00:00
nir_lower_image.c nir: Switch to using nir_vec_scalars() for things that used nir_channel(). 2022-03-02 22:28:58 +00:00
nir_lower_indirect_derefs.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_lower_input_attachments.c nir: Use nir_shader_instructions_pass in nir_lower_input_attachments 2022-05-13 22:51:38 +00:00
nir_lower_int64.c nir/lower_int64: Fix float16 to int64 conversions. 2022-11-07 06:18:08 +00:00
nir_lower_int_to_float.c nir: Fix idiv lowering on !NativeIntegers when lower_fdiv is also set. 2022-06-07 02:38:42 +00:00
nir_lower_interpolation.c nir: use nir_shader_instructions_pass in nir_lower_interpolation 2022-09-26 11:13:03 +00:00
nir_lower_io.c nir/lower_explicit_io: fix metadata preserve 2022-11-18 20:46:20 +00:00
nir_lower_io_arrays_to_elements.c Revert "nir: Drop the unused instr arg for src/dest copy functions." 2022-08-30 18:21:44 +00:00
nir_lower_io_to_scalar.c Revert "nir: Drop the unused instr arg for src/dest copy functions." 2022-08-30 18:21:44 +00:00
nir_lower_io_to_temporaries.c
nir_lower_io_to_vector.c nir/lower_io_to_vector: Demote the old scalar vars to globals. 2022-11-09 20:21:17 +00:00
nir_lower_is_helper_invocation.c nir/lower_is_helper_invocation: create load_helper_invocation instr with bitsize=1 2022-03-21 03:20:33 +00:00
nir_lower_load_const_to_scalar.c
nir_lower_locals_to_regs.c nir: use a GC context for instructions 2022-08-30 18:21:44 +00:00
nir_lower_mediump.c nir/lower_mediump_vars: Don't lower mediump shared vars with atomic access. 2022-09-14 14:56:22 -07:00
nir_lower_memcpy.c nir: fix lower_memcpy 2022-02-17 15:12:45 +00:00
nir_lower_memory_model.c nir: call nir_metadata_preserve in nir_lower_memory_model 2022-05-19 13:37:20 +00:00
nir_lower_multiview.c nir: Track per-view outputs in shader_info 2022-08-31 02:00:18 +00:00
nir_lower_non_uniform_access.c nir: add nir_intrinsic_image_samples_identical 2022-08-03 17:44:15 +00:00
nir_lower_packing.c
nir_lower_passthrough_edgeflags.c
nir_lower_patch_vertices.c
nir_lower_phis_to_scalar.c Revert "nir: Drop the unused instr arg for src/dest copy functions." 2022-08-30 18:21:44 +00:00
nir_lower_pntc_ytransform.c
nir_lower_point_size.c v3dv/v3d: Fix copyright holder to Raspberry Pi Ltd 2022-02-18 11:50:07 +01:00
nir_lower_point_size_mov.c nir/lower_point_size: apply point size clamping 2022-06-22 13:27:29 +00:00
nir_lower_point_smooth.c nir: Add a lowering pass for point smoothing 2022-07-16 07:08:09 -04:00
nir_lower_poly_line_smooth.c nir: Add a lowering pass for polygon and line smoothing 2022-07-16 10:15:22 +00:00
nir_lower_printf.c
nir_lower_readonly_images_to_tex.c nir: properly handle CL textures 2022-11-10 10:21:34 +00:00
nir_lower_regs_to_ssa.c
nir_lower_returns.c
nir_lower_samplers.c nir: use nir_shader_instructions_pass in nir_lower_samplers 2022-09-26 11:13:03 +00:00
nir_lower_scratch.c
nir_lower_shader_calls.c Revert "nir/lower_shader_calls: put inserted instructions into a dummy block" 2022-11-19 10:53:18 +00:00
nir_lower_single_sampled.c nir: Add a pass for lowering shaders to single-sampled 2022-07-13 20:28:42 +00:00
nir_lower_ssbo.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_lower_subgroups.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_lower_system_values.c nir/lower_system_values: Fix cs_local_index_to_id with variable workgroups 2022-10-13 21:25:23 +00:00
nir_lower_sysvals_to_varyings.c
nir_lower_task_shader.c nir/lower_task_shader: Don't fail adding a launch when last instruction is a jump 2022-09-23 01:25:48 +00:00
nir_lower_tex.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_lower_tex_shadow.c nir/nir_lower_tex_shadow: support tex_instr without deref src 2022-01-28 18:40:53 +00:00
nir_lower_texcoord_replace.c nir: Use nir_test_mask instead of i2b(iand) 2022-06-30 18:00:32 +00:00
nir_lower_to_source_mods.c nir_lower_to_source_mods: Don't sneek in an abs modifier from parent 2022-10-04 08:36:57 +02:00
nir_lower_two_sided_color.c
nir_lower_ubo_vec4.c nir: Use nir_test_mask instead of i2b(iand) 2022-06-30 18:00:32 +00:00
nir_lower_undef_to_zero.c
nir_lower_uniforms_to_ubo.c nir: Add a .base field to nir_load_ubo_vec4. 2022-01-19 22:28:34 +00:00
nir_lower_var_copies.c
nir_lower_variable_initializers.c nir/lower_variable_initializers: implement non-scoped barrier path 2022-08-31 07:25:00 +02:00
nir_lower_vars_to_ssa.c nir/vars_to_ssa: Always do OOB load/store removal. 2022-10-03 17:18:31 +00:00
nir_lower_vec3_to_vec4.c
nir_lower_vec_to_movs.c Revert "nir: Drop the unused instr arg for src/dest copy functions." 2022-08-30 18:21:44 +00:00
nir_lower_viewport_transform.c
nir_lower_wpos_center.c anv,nir: Use sample_pos_or_center in lower_wpos_center 2021-12-17 16:02:16 +00:00
nir_lower_wpos_ytransform.c
nir_lower_wrmasks.c
nir_metadata.c nir: add support for forced sampler indirect loop unrolling 2022-05-17 02:12:21 +00:00
nir_move_vec_src_uses_to_dest.c
nir_normalize_cubemap_coords.c nir: Usher nir_normalize_cubemap_coords into 2022 2022-10-17 20:46:24 +00:00
nir_opcodes.py nir: Fix ifind_msb_rev constant folding. 2022-10-22 11:57:55 +02:00
nir_opcodes_c.py
nir_opcodes_h.py
nir_opt_access.c nir: Drop infer_non_readable option for nir_opt_access() 2022-11-02 03:42:04 +00:00
nir_opt_algebraic.py nir/algebraic: shrink 64-bit bitwise operations with 0/-1 constant half 2022-11-21 17:34:46 +00:00
nir_opt_barriers.c
nir_opt_combine_stores.c nir: Switch to using nir_vec_scalars() for things that used nir_channel(). 2022-03-02 22:28:58 +00:00
nir_opt_comparison_pre.c nir/comparison_pre: See through an inot to apply the optimization 2022-09-08 01:01:14 +00:00
nir_opt_conditional_discard.c
nir_opt_constant_folding.c nir: Constant fold sampler/texture offsets 2022-04-26 22:34:39 +00:00
nir_opt_copy_prop_vars.c nir/nir_opt_copy_prop_vars: Don't leak dynarray memory during the pass. 2022-10-03 15:33:21 +00:00
nir_opt_copy_propagate.c spirv: run nir_copy_prop before nir_rematerialize_derefs_in_use_blocks_impl 2021-11-24 15:43:51 +00:00
nir_opt_cse.c
nir_opt_dce.c nir: Free instructions more often 2022-08-30 18:21:44 +00:00
nir_opt_dead_cf.c nir: add load_shared2_amd and store_shared2_amd 2022-04-13 23:08:07 +00:00
nir_opt_dead_write_vars.c
nir_opt_find_array_copies.c
nir_opt_fragdepth.c
nir_opt_gcm.c nir/gce: pin call instructions 2022-05-31 12:36:48 +00:00
nir_opt_idiv_const.c
nir_opt_if.c fix: nir: unused variable ‘else_block’ [-Wunused-variable] 2022-09-19 22:02:16 +00:00
nir_opt_intrinsics.c
nir_opt_large_constants.c nir: Add an options parameter to deref_instr_has_complex_use 2022-06-24 19:21:26 +00:00
nir_opt_load_store_vectorize.c util,nir: Move mask_sign_extend from opt_load_store_vectorize to util 2022-07-06 11:23:18 +00:00
nir_opt_loop_unroll.c nir: allow to fine tune unrolling for loops with soft fp64 ops 2022-09-30 17:07:37 +00:00
nir_opt_memcpy.c nir/opt_memcpy: Add another case for function_temp 2022-06-24 19:21:26 +00:00
nir_opt_move.c nir/nir_opt_move: handle non-SSA defs 2022-02-24 11:36:00 +00:00
nir_opt_move_discards_to_top.c
nir_opt_non_uniform_access.c nir: add a pass to remove non-uniform access qualifier when the operands are uniform 2022-08-03 23:57:50 +00:00
nir_opt_offsets.c nir: add load_shared2_amd and store_shared2_amd 2022-04-13 23:08:07 +00:00
nir_opt_peephole_select.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_opt_phi_precision.c nir/opt_phi_precision: Fix missing swizzles when narrowing phi srcs. 2022-10-22 03:06:31 +00:00
nir_opt_preamble.c nir,ac/llvm,radeonsi: add nir_load_clamp_vertex_color_amd 2022-11-11 04:22:20 +00:00
nir_opt_ray_queries.c nir: Add a pass for combining ray queries 2022-11-11 15:17:08 +00:00
nir_opt_rematerialize_compares.c
nir_opt_remove_phis.c
nir_opt_shrink_stores.c nir/builder: Add a nir_trim_vector helper 2022-05-11 14:47:33 +00:00
nir_opt_shrink_vectors.c nir/opt_shrink_vectors: Round to supported vec size 2022-07-10 18:03:46 +00:00
nir_opt_sink.c nir/nir_opt_move: allow to move uniform loads 2022-02-24 11:36:00 +00:00
nir_opt_trivial_continues.c
nir_opt_undef.c nir/opt_undef: add a pass to clean up 64bit undefs 2022-09-27 18:38:25 +00:00
nir_opt_uniform_atomics.c nir: use nir_metadata_none instead of its value 2022-09-26 11:13:03 +00:00
nir_opt_vectorize.c nir/opt_vectorize: refactor src rewriting to avoid unnecessary mov instructions 2022-06-03 08:53:18 +00:00
nir_passthrough_tcs.c nir: Add way to create passthrough TCS without VS nir 2022-10-29 17:46:23 +00:00
nir_phi_builder.c
nir_phi_builder.h
nir_print.c nir: make ray query load values visible in NIR prints 2022-11-10 14:40:08 +02:00
nir_propagate_invariant.c
nir_range_analysis.c nir/range_analysis: Set higher default maximum for max_workgroup_count 2022-11-19 05:40:42 +00:00
nir_range_analysis.h nir: Constify def parameter to nir_ssa_def_bits_used 2022-02-10 18:15:39 +00:00
nir_remove_dead_variables.c
nir_repair_ssa.c
nir_scale_fdiv.c nir_scale_fdiv: Respect vector swizzles 2022-11-15 03:05:13 +00:00
nir_schedule.c nir: add load_shared2_amd and store_shared2_amd 2022-04-13 23:08:07 +00:00
nir_schedule.h nir/schedule: allow drivers to decide about instruction latency 2022-03-09 15:53:04 +00:00
nir_search.c nir: adjust nir_src_copy signature to take a nir_instr * 2022-08-30 18:21:44 +00:00
nir_search.h nir: Free instructions more often 2022-08-30 18:21:44 +00:00
nir_search_helpers.h nir/algebraic: shrink 64-bit bitwise operations with 0/-1 constant half 2022-11-21 17:34:46 +00:00
nir_serialize.c nir: use a GC context for instructions 2022-08-30 18:21:44 +00:00
nir_serialize.h
nir_split_64bit_vec3_and_vec4.c nir: Add pass to split 64 bit vec3 and vec4 variable access and phis 2022-04-21 16:57:11 +00:00
nir_split_per_member_structs.c nir: use nir_shader_instructions_pass in nir_split_per_member_structs 2022-09-26 11:13:03 +00:00
nir_split_var_copies.c nir: use nir_shader_instructions_pass in nir_split_var_copies 2022-09-26 11:13:03 +00:00
nir_split_vars.c nir: Add an options parameter to deref_instr_has_complex_use 2022-06-24 19:21:26 +00:00
nir_sweep.c nir: use a GC context for instructions 2022-08-30 18:21:44 +00:00
nir_to_lcssa.c
nir_validate.c nir: Remove the need of _MTX_INITIALIZER_NP by using simple_mtx_t/SIMPLE_MTX_INITIALIZER in nir/nir_validate.c 2022-11-09 04:38:28 +00:00
nir_vla.h
nir_vulkan.h
nir_worklist.c nir: Use u_worklist to back nir_block_worklist 2022-04-25 23:50:57 +00:00
nir_worklist.h nir: Use u_worklist to back nir_block_worklist 2022-04-25 23:50:57 +00:00
nir_xfb_info.h nir: fix nir_xfb_info buffer_to_stream length 2022-09-16 08:51:28 +00:00

README

New IR, or NIR, is an IR for Mesa intended to sit below GLSL IR and Mesa IR.
Its design inherits from the various IRs that Mesa has used in the past, as
well as Direct3D assembly, and it includes a few new ideas as well. It is a
flat (in terms of using instructions instead of expressions), typeless IR,
similar to TGSI and Mesa IR.  It also supports SSA (although it doesn't require
it).

Variables
=========

NIR includes support for source-level GLSL variables through a structure mostly
copied from GLSL IR. These will be used for linking and conversion from GLSL IR
(and later, from an AST), but for the most part, they will be lowered to
registers (see below) and loads/stores.

Registers
=========

Registers are light-weight; they consist of a structure that only contains its
size, its index for liveness analysis, and an optional name for debugging. In
addition, registers can be local to a function or global to the entire shader;
the latter will be used in ARB_shader_subroutine for passing parameters and
getting return values from subroutines. Registers can also be an array, in which
case they can be accessed indirectly. Each ALU instruction (add, subtract, etc.)
works directly with registers or SSA values (see below).

SSA
========

Everywhere a register can be loaded/stored, an SSA value can be used instead.
The only exception is that arrays/indirect addressing are not supported with
SSA; although research has been done on extensions of SSA to arrays before, it's
usually for the purpose of parallelization (which we're not interested in), and
adds some overhead in the form of adding copies or extra arrays (which is much
more expensive than introducing copies between non-array registers). SSA uses
point directly to their corresponding definition, which in turn points to the
instruction it is part of. This creates an implicit use-def chain and avoids the
need for an external structure for each SSA register.

Functions
=========

Support for function calls is mostly similar to GLSL IR. Each shader contains a
list of functions, and each function has a list of overloads. Each overload
contains a list of parameters, and may contain an implementation which specifies
the variables that correspond to the parameters and return value. Inlining a
function, assuming it has a single return point, is as simple as copying its
instructions, registers, and local variables into the target function and then
inserting copies to and from the new parameters as appropriate. After functions
are inlined and any non-subroutine functions are deleted, parameters and return
variables will be converted to global variables and then global registers. We
don't do this lowering earlier (i.e. the fortranizer idea) for a few reasons:

- If we want to do optimizations before link time, we need to have the function
signature available during link-time.

- If we do any inlining before link time, then we might wind up with the
inlined function and the non-inlined function using the same global
variables/registers which would preclude optimization.

Intrinsics
=========

Any operation (other than function calls and textures) which touches a variable
or is not referentially transparent is represented by an intrinsic. Intrinsics
are similar to the idea of a "builtin function," i.e. a function declaration
whose implementation is provided by the backend, except they are more powerful
in the following ways:

- They can also load and store registers when appropriate, which limits the
number of variables needed in later stages of the IR while obviating the need
for a separate load/store variable instruction.

- Intrinsics can be marked as side-effect free, which permits them to be
treated like any other instruction when it comes to optimizations. This allows
load intrinsics to be represented as intrinsics while still being optimized
away by dead code elimination, common subexpression elimination, etc.

Intrinsics are used for:

- Atomic operations
- Memory barriers
- Subroutine calls
- Geometry shader emitVertex and endPrimitive
- Loading and storing variables (before lowering)
- Loading and storing uniforms, shader inputs and outputs, etc (after lowering)
- Copying variables (cases where in GLSL the destination is a structure or
array)
- The kitchen sink
- ...

Textures
=========

Unfortunately, there are far too many texture operations to represent each one
of them with an intrinsic, so there's a special texture instruction similar to
the GLSL IR one. The biggest difference is that, while the texture instruction
has a sampler dereference field used just like in GLSL IR, this gets lowered to
a texture unit index (with a possible indirect offset) while the type
information of the original sampler is kept around for backends. Also, all the
non-constant sources are stored in a single array to make it easier for
optimization passes to iterate over all the sources.

Control Flow
=========

Like in GLSL IR, control flow consists of a tree of "control flow nodes", which
include if statements and loops, and jump instructions (break, continue, and
return). Unlike GLSL IR, though, the leaves of the tree aren't statements but
basic blocks. Each basic block also keeps track of its successors and
predecessors, and function implementations keep track of the beginning basic
block (the first basic block of the function) and the ending basic block (a fake
basic block that every return statement points to). Together, these elements
make up the control flow graph, in this case a redundant piece of information on
top of the control flow tree that will be used by almost all the optimizations.
There are helper functions to add and remove control flow nodes that also update
the control flow graph, and so usually it doesn't need to be touched by passes
that modify control flow nodes.