Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/panfrost/bifrost/bi_liveness.c
4564 views
1
/*
2
* Copyright (C) 2020 Collabora, Ltd.
3
* Copyright (C) 2018-2019 Alyssa Rosenzweig <[email protected]>
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
* and/or sell copies of the Software, and to permit persons to whom the
10
* Software is furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice (including the next
13
* paragraph) shall be included in all copies or substantial portions of the
14
* Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
25
#include "compiler.h"
26
27
void
28
bi_liveness_ins_update(uint16_t *live, bi_instr *ins, unsigned max)
29
{
30
/* live_in[s] = GEN[s] + (live_out[s] - KILL[s]) */
31
32
bi_foreach_dest(ins, d) {
33
pan_liveness_kill(live, bi_get_node(ins->dest[d]), max,
34
bi_writemask(ins, d));
35
}
36
37
bi_foreach_src(ins, src) {
38
unsigned count = bi_count_read_registers(ins, src);
39
unsigned rmask = BITFIELD_MASK(count);
40
uint16_t mask = (rmask << ins->src[src].offset);
41
42
unsigned node = bi_get_node(ins->src[src]);
43
pan_liveness_gen(live, node, max, mask);
44
}
45
}
46
47
static void
48
bi_liveness_ins_update_wrap(uint16_t *live, void *ins, unsigned max)
49
{
50
bi_liveness_ins_update(live, (bi_instr *) ins, max);
51
}
52
53
void
54
bi_compute_liveness(bi_context *ctx)
55
{
56
if (ctx->has_liveness)
57
return;
58
59
pan_compute_liveness(&ctx->blocks, bi_max_temp(ctx), bi_liveness_ins_update_wrap);
60
61
ctx->has_liveness = true;
62
}
63
64
/* Once liveness data is no longer valid, call this */
65
66
void
67
bi_invalidate_liveness(bi_context *ctx)
68
{
69
if (ctx->has_liveness)
70
pan_free_liveness(&ctx->blocks);
71
72
ctx->has_liveness = false;
73
}
74
75