• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright (C) 2021 Collabora Ltd.
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 "va_compiler.h"
26 #include "valhall.h"
27 #include "bi_builder.h"
28 
29 void
va_count_instr_stats(bi_instr * I,struct va_stats * stats)30 va_count_instr_stats(bi_instr *I, struct va_stats *stats)
31 {
32    /* Adjusted for 64-bit arithmetic */
33    unsigned words = bi_count_write_registers(I, 0);
34 
35    switch (valhall_opcodes[I->op].unit) {
36    /* Arithmetic is 2x slower for 64-bit than 32-bit */
37    case VA_UNIT_FMA:
38       stats->fma += words;
39       return;
40 
41    case VA_UNIT_CVT:
42       stats->cvt += words;
43       return;
44 
45    case VA_UNIT_SFU:
46       stats->sfu += words;
47       return;
48 
49    /* Varying is scaled by 16-bit components interpolated */
50    case VA_UNIT_V:
51       stats->v += (I->vecsize + 1) *
52          (bi_is_regfmt_16(I->register_format) ? 1 : 2);
53       return;
54 
55    /* We just count load/store and texturing for now */
56    case VA_UNIT_LS:
57       stats->ls++;
58       return;
59 
60    case VA_UNIT_T:
61       stats->t++;
62       return;
63 
64    /* Fused varying+texture loads 2 FP32 components of varying for texture
65     * coordinates and then textures */
66    case VA_UNIT_VT:
67       stats->ls += (2 * 2);
68       stats->t++;
69       return;
70 
71    /* Nothing to do here */
72    case VA_UNIT_NONE:
73       return;
74    }
75 
76    unreachable("Invalid unit");
77 }
78