~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/panfrost/bifrost/valhall/va_compiler.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (C) 2021 Collabora Ltd.
3
 
 *
4
 
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 
 * copy of this software and associated documentation files (the "Software"),
6
 
 * to deal in the Software without restriction, including without limitation
7
 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
 
 * and/or sell copies of the Software, and to permit persons to whom the
9
 
 * Software is furnished to do so, subject to the following conditions:
10
 
 *
11
 
 * The above copyright notice and this permission notice (including the next
12
 
 * paragraph) shall be included in all copies or substantial portions of the
13
 
 * Software.
14
 
 *
15
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18
 
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 
 * 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 THE
21
 
 * SOFTWARE.
22
 
 *
23
 
 * Authors (Collabora):
24
 
 *      Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
25
 
 */
26
 
 
27
 
#ifndef __VALHALL_COMPILER_H
28
 
#define __VALHALL_COMPILER_H
29
 
 
30
 
#include "compiler.h"
31
 
#include "valhall.h"
32
 
 
33
 
#ifdef __cplusplus
34
 
extern "C" {
35
 
#endif
36
 
 
37
 
bool va_validate_fau(bi_instr *I);
38
 
void va_validate(FILE *fp, bi_context *ctx);
39
 
void va_repair_fau(bi_builder *b, bi_instr *I);
40
 
void va_fuse_add_imm(bi_instr *I);
41
 
void va_lower_constants(bi_context *ctx, bi_instr *I);
42
 
void va_lower_isel(bi_instr *I);
43
 
uint64_t va_pack_instr(const bi_instr *I);
44
 
 
45
 
static inline unsigned
46
 
va_fau_page(enum bir_fau value)
47
 
{
48
 
   /* Uniform slots of FAU have a 7-bit index. The top 2-bits are the page; the
49
 
    * bottom 5-bits are specified in the source.
50
 
    */
51
 
   if (value & BIR_FAU_UNIFORM) {
52
 
      unsigned slot = value & ~BIR_FAU_UNIFORM;
53
 
      unsigned page = slot >> 5;
54
 
 
55
 
      assert(page <= 3);
56
 
      return page;
57
 
   }
58
 
 
59
 
   /* Special indices are also paginated */
60
 
   switch (value) {
61
 
   case BIR_FAU_TLS_PTR:
62
 
   case BIR_FAU_WLS_PTR:
63
 
      return 1;
64
 
   case BIR_FAU_LANE_ID:
65
 
   case BIR_FAU_CORE_ID:
66
 
   case BIR_FAU_PROGRAM_COUNTER:
67
 
      return 3;
68
 
   default:
69
 
      return 0;
70
 
   }
71
 
}
72
 
 
73
 
static inline unsigned
74
 
va_select_fau_page(const bi_instr *I)
75
 
{
76
 
   bi_foreach_src(I, s) {
77
 
      if (I->src[s].type == BI_INDEX_FAU)
78
 
         return va_fau_page((enum bir_fau) I->src[s].value);
79
 
   }
80
 
 
81
 
   return 0;
82
 
}
83
 
 
84
 
/** Cycle model for Valhall. Results need to be normalized */
85
 
struct va_stats {
86
 
   /** Counts per pipe */
87
 
   unsigned fma, cvt, sfu, v, ls, t;
88
 
};
89
 
 
90
 
void
91
 
va_count_instr_stats(bi_instr *I, struct va_stats *stats);
92
 
 
93
 
#ifdef __cplusplus
94
 
} /* extern C */
95
 
#endif
96
 
 
97
 
#endif