filename | src/xlat/xiropt.h |
changeset | 1006:3a169c224c12 |
author | nkeynes |
date | Sun Apr 12 07:24:45 2009 +0000 (15 years ago) |
branch | xlat-refactor |
permissions | -rw-r--r-- |
last change | Restructure operand types - rename to forms to avoid conflict for actual data types temporary operands are now a first class form remove explicit types for immediates - now implied by opcode Initial work on promote-source-reg pass |
view | annotate | diff | log | raw |
1 /**
2 * $Id: livevar.h 931 2008-10-31 02:57:59Z nkeynes $
3 *
4 * IR optimizations
5 *
6 * Copyright (c) 2009 Nathan Keynes.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
19 #ifndef lxdream_xiropt_H
20 #define lxdream_xiropt_H 1
22 #include "lxdream.h"
23 #include "xlat/xir.h"
25 /**
26 * Live range data-structure. For each value defined by a program block,
27 * we track it's def, last use, and distance between. This is slightly
28 * complicated by two additional concerns around dead store elimination:
29 * * A value may be coherent or dirty (ie value is consistent with the
30 * in-memory state data or not)
31 * * At the end of it's range, a value may be live, unconditionally
32 * dead, or conditionally dead, depending on whether the home memory
33 * location is overwritten before the end of the block.
34 * A value is _conditionally_ dead if it is overwritten within the block,
35 * but may be exposed by an exception.
36 *
37 * We represent this by an additional field visible_length - the length of
38 * time (in instructions) that the value is (potentially) externally visible.
39 * It takes the following values:
40 * -1 - Always visible (ie live at end of block)
41 * 0 - Never visible (ie coherent)
42 * == use_length - dead after last use
43 * > use_length - eventually dead at end of visibility
44 */
45 struct live_range {
46 xir_op_t def; /* Value defining instruction */
47 xir_offset_t def_offset; /* Offset of def relative to start of block */
48 xir_op_t range_end; /* Last use of the value */
49 xir_offset_t use_length; /* Length of range to last real use */
50 xir_offset_t visible_length; /* Length of full range of visibility */
51 };
53 /**
54 * Replaces registers with immediates where the value is constant. Also
55 * kills align instructions where the value can be determined to be
56 * aligned already (either constant address or redundant alignment check),
57 * and sat* instructions where S can be determined.
58 *
59 * Performs a single forward pass over the IR.
60 */
61 void xir_constant_propagation( xir_basic_block_t xbb, xir_op_t begin, xir_op_t end );
63 /**
64 * Kill any instructions where the result cannot be exposed - that is, the value
65 * is overwritten before the end of the block. Values that may be exposed by an
66 * exception (but are otherwise dead) are removed by adding repair code to the
67 * exception path where possible (essentially if the value can be reconstructed
68 * from live values).
69 *
70 * Performs a single backwards pass over the IR
71 */
72 void xir_dead_code_elimination( xir_basic_block_t xbb, xir_op_t begin, xir_op_t end );
74 /**
75 * Compute live range data for the code in the range start..end.
76 * @param start First instruction to consider
77 * @param end terminating instruction (not included in analysis). NULL for
78 * entire block.
79 * @param live_ranges output buffer to receive live-range data
80 * @param live_ranges_size Number of entries in live_ranges.
81 * @return TRUE on success, FALSE if the algorithm ran out of buffer space.
82 */
83 gboolean xir_live_range_calculate( xir_op_t begin, xir_op_t end,
84 struct live_range *live_ranges, unsigned int live_ranges_size );
86 void xir_live_range_dump( struct live_range *ranges );
89 #endif /* !lxdream_livevar_H */
.