Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright © 2010 Intel Corporation
  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 DEALINGS
  21.  * IN THE SOFTWARE.
  22.  *
  23.  * Authors:
  24.  *    Eric Anholt <eric@anholt.net>
  25.  *
  26.  */
  27.  
  28. struct ra_class;
  29. struct ra_regs;
  30.  
  31. /* @{
  32.  * Register set setup.
  33.  *
  34.  * This should be done once at backend initializaion, as
  35.  * ra_set_finalize is O(r^2*c^2).  The registers may be virtual
  36.  * registers, such as aligned register pairs that conflict with the
  37.  * two real registers from which they are composed.
  38.  */
  39. struct ra_regs *ra_alloc_reg_set(void *mem_ctx, unsigned int count);
  40. void ra_set_allocate_round_robin(struct ra_regs *regs);
  41. unsigned int ra_alloc_reg_class(struct ra_regs *regs);
  42. void ra_add_reg_conflict(struct ra_regs *regs,
  43.                          unsigned int r1, unsigned int r2);
  44. void ra_add_transitive_reg_conflict(struct ra_regs *regs,
  45.                                     unsigned int base_reg, unsigned int reg);
  46. void ra_class_add_reg(struct ra_regs *regs, unsigned int c, unsigned int reg);
  47. void ra_set_num_conflicts(struct ra_regs *regs, unsigned int class_a,
  48.                           unsigned int class_b, unsigned int num_conflicts);
  49. void ra_set_finalize(struct ra_regs *regs, unsigned int **conflicts);
  50. /** @} */
  51.  
  52. /** @{ Interference graph setup.
  53.  *
  54.  * Each interference graph node is a virtual variable in the IL.  It
  55.  * is up to the user to ra_set_node_class() for the virtual variable,
  56.  * and compute live ranges and ra_node_interfere() between conflicting
  57.  * live ranges.
  58.  */
  59. struct ra_graph *ra_alloc_interference_graph(struct ra_regs *regs,
  60.                                              unsigned int count);
  61. void ra_set_node_class(struct ra_graph *g, unsigned int n, unsigned int c);
  62. void ra_add_node_interference(struct ra_graph *g,
  63.                               unsigned int n1, unsigned int n2);
  64. /** @} */
  65.  
  66. /** @{ Graph-coloring register allocation */
  67. GLboolean ra_simplify(struct ra_graph *g);
  68. void ra_optimistic_color(struct ra_graph *g);
  69. GLboolean ra_select(struct ra_graph *g);
  70. GLboolean ra_allocate_no_spills(struct ra_graph *g);
  71.  
  72. unsigned int ra_get_node_reg(struct ra_graph *g, unsigned int n);
  73. void ra_set_node_reg(struct ra_graph * g, unsigned int n, unsigned int reg);
  74. void ra_set_node_spill_cost(struct ra_graph *g, unsigned int n, float cost);
  75. int ra_get_best_spill_node(struct ra_graph *g);
  76. /** @} */
  77.  
  78.