Path: blob/21.2-virgl/src/panfrost/bifrost/bi_liveness.c
4564 views
/*1* Copyright (C) 2020 Collabora, Ltd.2* Copyright (C) 2018-2019 Alyssa Rosenzweig <[email protected]>3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21* SOFTWARE.22*/2324#include "compiler.h"2526void27bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max)28{29/* live_in[s] = GEN[s] + (live_out[s] - KILL[s]) */3031bi_foreach_dest(ins, d) {32pan_liveness_kill(live, bi_get_node(ins->dest[d]), max,33bi_writemask(ins, d));34}3536bi_foreach_src(ins, src) {37unsigned count = bi_count_read_registers(ins, src);38unsigned rmask = BITFIELD_MASK(count);39uint16_t mask = (rmask << ins->src[src].offset);4041unsigned node = bi_get_node(ins->src[src]);42pan_liveness_gen(live, node, max, mask);43}44}4546static void47bi_liveness_ins_update_wrap(uint16_t *live, void *ins, unsigned max)48{49bi_liveness_ins_update(live, (bi_instr *) ins, max);50}5152void53bi_compute_liveness(bi_context *ctx)54{55if (ctx->has_liveness)56return;5758pan_compute_liveness(&ctx->blocks, bi_max_temp(ctx), bi_liveness_ins_update_wrap);5960ctx->has_liveness = true;61}6263/* Once liveness data is no longer valid, call this */6465void66bi_invalidate_liveness(bi_context *ctx)67{68if (ctx->has_liveness)69pan_free_liveness(&ctx->blocks);7071ctx->has_liveness = false;72}737475