Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  * Copyright (C) 2009 Nicolai Haehnle.
  3.  * Copyright 2010 Tom Stellard <tstellar@gmail.com>
  4.  *
  5.  * All Rights Reserved.
  6.  *
  7.  * Permission is hereby granted, free of charge, to any person obtaining
  8.  * a copy of this software and associated documentation files (the
  9.  * "Software"), to deal in the Software without restriction, including
  10.  * without limitation the rights to use, copy, modify, merge, publish,
  11.  * distribute, sublicense, and/or sell copies of the Software, and to
  12.  * permit persons to whom the Software is furnished to do so, subject to
  13.  * the following conditions:
  14.  *
  15.  * The above copyright notice and this permission notice (including the
  16.  * next paragraph) shall be included in all copies or substantial
  17.  * portions of the Software.
  18.  *
  19.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20.  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  22.  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  23.  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  24.  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  25.  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  26.  *
  27.  */
  28.  
  29. #ifndef RADEON_DATAFLOW_H
  30. #define RADEON_DATAFLOW_H
  31.  
  32. #include "radeon_program_constants.h"
  33.  
  34. struct radeon_compiler;
  35. struct rc_instruction;
  36. struct rc_swizzle_caps;
  37. struct rc_src_register;
  38. struct rc_pair_instruction_arg;
  39. struct rc_pair_instruction_source;
  40. struct rc_pair_sub_instruction;
  41. struct rc_compiler;
  42.  
  43.  
  44. /**
  45.  * Help analyze and modify the register accesses of instructions.
  46.  */
  47. /*@{*/
  48. typedef void (*rc_read_write_chan_fn)(void * userdata, struct rc_instruction * inst,
  49.                         rc_register_file file, unsigned int index, unsigned int chan);
  50. void rc_for_all_reads_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata);
  51. void rc_for_all_writes_chan(struct rc_instruction * inst, rc_read_write_chan_fn cb, void * userdata);
  52.  
  53. typedef void (*rc_read_write_mask_fn)(void * userdata, struct rc_instruction * inst,
  54.                         rc_register_file file, unsigned int index, unsigned int mask);
  55. void rc_for_all_reads_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata);
  56. void rc_for_all_writes_mask(struct rc_instruction * inst, rc_read_write_mask_fn cb, void * userdata);
  57.  
  58. typedef void (*rc_read_src_fn)(void * userdata, struct rc_instruction * inst,
  59.                         struct rc_src_register * src);
  60. void rc_for_all_reads_src(struct rc_instruction * inst, rc_read_src_fn cb,
  61.                         void * userdata);
  62.  
  63. typedef void (*rc_pair_read_arg_fn)(void * userdata,
  64.         struct rc_instruction * inst, struct rc_pair_instruction_arg * arg,
  65.         struct rc_pair_instruction_source * src);
  66. void rc_pair_for_all_reads_arg(struct rc_instruction * inst,
  67.                                         rc_pair_read_arg_fn cb, void * userdata);
  68.  
  69. typedef void (*rc_remap_register_fn)(void * userdata, struct rc_instruction * inst,
  70.                         rc_register_file * pfile, unsigned int * pindex);
  71. void rc_remap_registers(struct rc_instruction * inst, rc_remap_register_fn cb, void * userdata);
  72. /*@}*/
  73.  
  74. struct rc_reader {
  75.         struct rc_instruction * Inst;
  76.         unsigned int WriteMask;
  77.         union {
  78.                 struct {
  79.                         struct rc_src_register * Src;
  80.                 } I;
  81.                 struct {
  82.                         struct rc_pair_instruction_arg * Arg;
  83.                         struct rc_pair_instruction_source * Src;
  84.                 } P;
  85.         } U;
  86. };
  87.  
  88. struct rc_reader_data {
  89.         unsigned int Abort;
  90.         unsigned int AbortOnRead;
  91.         unsigned int AbortOnWrite;
  92.         unsigned int LoopDepth;
  93.         unsigned int InElse;
  94.         struct rc_instruction * Writer;
  95.  
  96.         unsigned int ReaderCount;
  97.         unsigned int ReadersReserved;
  98.         struct rc_reader * Readers;
  99.  
  100.         /* If this flag is enabled, rc_get_readers will exit as soon possbile
  101.          * after the Abort flag is set.*/
  102.         unsigned int ExitOnAbort;
  103.         void * CbData;
  104. };
  105.  
  106. void rc_get_readers(
  107.         struct radeon_compiler * c,
  108.         struct rc_instruction * writer,
  109.         struct rc_reader_data * data,
  110.         rc_read_src_fn read_normal_cb,
  111.         rc_pair_read_arg_fn read_pair_cb,
  112.         rc_read_write_mask_fn write_cb);
  113.  
  114. void rc_get_readers_sub(
  115.         struct radeon_compiler * c,
  116.         struct rc_instruction * writer,
  117.         struct rc_pair_sub_instruction * sub_writer,
  118.         struct rc_reader_data * data,
  119.         rc_read_src_fn read_normal_cb,
  120.         rc_pair_read_arg_fn read_pair_cb,
  121.         rc_read_write_mask_fn write_cb);
  122. /**
  123.  * Compiler passes based on dataflow analysis.
  124.  */
  125. /*@{*/
  126. typedef void (*rc_dataflow_mark_outputs_fn)(void * userdata, void * data,
  127.                         void (*mark_fn)(void * data, unsigned int index, unsigned int mask));
  128. void rc_dataflow_deadcode(struct radeon_compiler * c, void *user);
  129. void rc_dataflow_swizzles(struct radeon_compiler * c, void *user);
  130. /*@}*/
  131.  
  132. void rc_optimize(struct radeon_compiler * c, void *user);
  133. void rc_inline_literals(struct radeon_compiler *c, void *user);
  134.  
  135. #endif /* RADEON_DATAFLOW_H */
  136.