]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
2 | Copyright 1988-2022 Free Software Foundation, Inc. | |
3 | This is part of the GCC manual. | |
4 | For copying conditions, see the copyright.rst file. | |
5 | ||
6 | .. index:: sharing of RTL components, RTL structure sharing assumptions | |
7 | ||
8 | .. _sharing: | |
9 | ||
10 | Structure Sharing Assumptions | |
11 | ***************************** | |
12 | ||
13 | The compiler assumes that certain kinds of RTL expressions are unique; | |
14 | there do not exist two distinct objects representing the same value. | |
15 | In other cases, it makes an opposite assumption: that no RTL expression | |
16 | object of a certain kind appears in more than one place in the | |
17 | containing structure. | |
18 | ||
19 | These assumptions refer to a single function; except for the RTL | |
20 | objects that describe global variables and external functions, | |
21 | and a few standard objects such as small integer constants, | |
22 | no RTL objects are common to two functions. | |
23 | ||
24 | .. index:: reg, RTL sharing | |
25 | ||
26 | * Each pseudo-register has only a single ``reg`` object to represent it, | |
27 | and therefore only a single machine mode. | |
28 | ||
29 | .. index:: symbolic label, symbol_ref, RTL sharing | |
30 | ||
31 | * For any symbolic label, there is only one ``symbol_ref`` object | |
32 | referring to it. | |
33 | ||
34 | .. index:: const_int, RTL sharing | |
35 | ||
36 | * All ``const_int`` expressions with equal values are shared. | |
37 | ||
38 | .. index:: const_poly_int, RTL sharing | |
39 | ||
40 | * All ``const_poly_int`` expressions with equal modes and values | |
41 | are shared. | |
42 | ||
43 | .. index:: pc, RTL sharing | |
44 | ||
45 | * There is only one ``pc`` expression. | |
46 | ||
47 | .. index:: const_double, RTL sharing | |
48 | ||
49 | * There is only one ``const_double`` expression with value 0 for | |
50 | each floating point mode. Likewise for values 1 and 2. | |
51 | ||
52 | .. index:: const_vector, RTL sharing | |
53 | ||
54 | * There is only one ``const_vector`` expression with value 0 for | |
55 | each vector mode, be it an integer or a double constant vector. | |
56 | ||
57 | .. index:: label_ref, RTL sharing, scratch, RTL sharing | |
58 | ||
59 | * No ``label_ref`` or ``scratch`` appears in more than one place in | |
60 | the RTL structure; in other words, it is safe to do a tree-walk of all | |
61 | the insns in the function and assume that each time a ``label_ref`` | |
62 | or ``scratch`` is seen it is distinct from all others that are seen. | |
63 | ||
64 | .. index:: mem, RTL sharing | |
65 | ||
66 | * Only one ``mem`` object is normally created for each static | |
67 | variable or stack slot, so these objects are frequently shared in all | |
68 | the places they appear. However, separate but equal objects for these | |
69 | variables are occasionally made. | |
70 | ||
71 | .. index:: asm_operands, RTL sharing | |
72 | ||
73 | * When a single ``asm`` statement has multiple output operands, a | |
74 | distinct ``asm_operands`` expression is made for each output operand. | |
75 | However, these all share the vector which contains the sequence of input | |
76 | operands. This sharing is used later on to test whether two | |
77 | ``asm_operands`` expressions come from the same statement, so all | |
78 | optimizations must carefully preserve the sharing if they copy the | |
79 | vector at all. | |
80 | ||
81 | * No RTL object appears in more than one place in the RTL structure | |
82 | except as described above. Many passes of the compiler rely on this | |
83 | by assuming that they can modify RTL objects in place without unwanted | |
84 | side-effects on other insns. | |
85 | ||
86 | .. index:: unshare_all_rtl | |
87 | ||
88 | * During initial RTL generation, shared structure is freely introduced. | |
89 | After all the RTL for a function has been generated, all shared | |
90 | structure is copied by ``unshare_all_rtl`` in :samp:`emit-rtl.cc`, | |
91 | after which the above rules are guaranteed to be followed. | |
92 | ||
93 | .. index:: copy_rtx_if_shared | |
94 | ||
95 | * During the combiner pass, shared structure within an insn can exist | |
96 | temporarily. However, the shared structure is copied before the | |
97 | combiner is finished with the insn. This is done by calling | |
98 | ``copy_rtx_if_shared``, which is a subroutine of | |
3ed1b4ce | 99 | ``unshare_all_rtl``. |