• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2017 Gert Wollny
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
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  */
23 
24 #ifndef MESA_GLSL_TO_TGSI_TEMPRENAME_H
25 #define MESA_GLSL_TO_TGSI_TEMPRENAME_H
26 
27 #include "st_glsl_to_tgsi_private.h"
28 
29 /** Storage to record the required life time of a temporary register
30  * begin == end == -1 indicates that the register can be reused without
31  * limitations. Otherwise, "begin" indicates the first instruction in which
32  * a write operation may target this temporary, and end indicates the
33  * last instruction in which a value can be read from this temporary.
34  * Hence, a register R2 can be merged with a register R1 if R1.end <= R2.begin.
35  */
36 struct lifetime {
37    int begin;
38    int end;
39 };
40 
41 /** Evaluates the required life times of temporary registers in a shader.
42  * The life time estimation can only be run sucessfully if the shader doesn't
43  * call a subroutine.
44  * @param[in] mem_ctx a memory context that can be used with the ralloc_* functions
45  * @param[in] instructions the shader to be anlzyed
46  * @param[in] ntemps number of temporaries reserved for this shader
47  * @param[in,out] lifetimes memory location to store the estimated required
48  *   life times for each temporary register. The parameter must point to
49  *   allocated memory that can hold ntemps lifetime structures. On output
50  *   the life times contains the life times for the registers with the
51  *   exception of TEMP[0].
52  * @returns: true if the lifetimes were estimated, false if not (i.e. if a
53  * subroutine was called).
54  */
55 bool
56 get_temp_registers_required_lifetimes(void *mem_ctx, exec_list *instructions,
57                                       int ntemps, struct lifetime *lifetimes);
58 /** Estimate the merge remapping of the registers.
59  * @param[in] mem_ctx a memory context that can be used with the ralloc_* functions
60  * @param[in] ntemps number of temporaries reserved for this shader
61  * @param[in] lifetimes required life time for each temporary register.
62  * @param[in,out] result memory location to store the register remapping table.
63  *  On input the parameter must point to allocated memory that can hold the
64  *  renaming information for ntemps registers, on output the mapping is stored.
65  *  Note that TEMP[0] is not considered for register renaming.
66  */
67 void get_temp_registers_remapping(void *mem_ctx, int ntemps,
68                                   const struct lifetime* lifetimes,
69                                   struct rename_reg_pair *result);
70 
71 #endif