Debian Codegraph @

src/panfrost/compiler/bifrost/valhall/va_compiler.h

raw
1 /*
2 * Copyright (C) 2021 Collabora Ltd.
3 * SPDX-License-Identifier: MIT
4 */
5
6 #ifndef __VALHALL_COMPILER_H
7 #define __VALHALL_COMPILER_H
8
9 #include "compiler.h"
10 #include "valhall.h"
11
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15
16 bool va_validate_fau(bi_instr *I);
17 void va_validate(FILE *fp, bi_context *ctx);
18 void va_repair_fau(bi_builder *b, bi_instr *I);
19 void va_fuse_add_imm(bi_instr *I);
20 void va_lower_constants(bi_context *ctx, bi_instr *I, struct hash_table_u64 *counts, uint32_t min_fau_count);
21 void va_count_constants(bi_context *ctx, bi_instr *I, struct hash_table_u64 *counts);
22 void va_lower_isel(bi_context *ctx);
23 void va_assign_slots(bi_context *ctx);
24 void va_insert_flow_control_nops(bi_context *ctx);
25 void va_merge_flow(bi_context *ctx);
26 void va_mark_last(bi_context *ctx);
27 void va_gather_hsr_info(bi_context *ctx, struct pan_shader_info *info);
28 uint64_t va_pack_instr(const bi_instr *I, unsigned arch);
29
30 static inline unsigned
31 va_fau_page(enum bir_fau value)
32 {
33 /* Uniform slots of FAU have a 7-bit index. The top 2-bits are the page; the
34 * bottom 5-bits are specified in the source.
35 */
36 if (value & BIR_FAU_UNIFORM) {
37 unsigned slot = value & ~BIR_FAU_UNIFORM;
38 unsigned page = slot >> 5;
39
40 assert(page <= 3);
41 return page;
42 }
43
44 /* Special indices are also paginated */
45 switch (value) {
46 case BIR_FAU_TLS_PTR:
47 case BIR_FAU_WLS_PTR:
48 return 1;
49 case BIR_FAU_LANE_ID:
50 case BIR_FAU_CORE_ID:
51 case BIR_FAU_SHADER_OUTPUT:
52 case BIR_FAU_PROGRAM_COUNTER:
53 return 3;
54 default:
55 return 0;
56 }
57 }
58
59 static inline unsigned
60 va_select_fau_page(const bi_instr *I)
61 {
62 bi_foreach_src(I, s) {
63 if (I->src[s].type == BI_INDEX_FAU)
64 return va_fau_page((enum bir_fau)I->src[s].value);
65 }
66
67 return 0;
68 }
69
70 /** Cycle model for Valhall. Results need to be normalized */
71 struct va_stats {
72 /** Counts per pipe */
73 unsigned fma, cvt, sfu, v, ls, t;
74 /** Mask of registers used */
75 uint64_t reg_mask;
76 /** number of uniform registers used */
77 unsigned nr_fau_uniforms;
78 };
79
80 void va_count_instr_stats(bi_instr *I, struct va_stats *stats);
81
82 #ifdef __cplusplus
83 } /* extern C */
84 #endif
85
86 #endif