3 * File name: ir/ana/irmemory.h
4 * Purpose: Memory disambiguator
9 * Copyright: (c) 2006-2007 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
12 #ifndef _FIRM_MEMORY_H
13 #define _FIRM_MEMORY_H
15 #include "firm_types.h"
17 /** The alias relation of two memory addresses. */
19 no_alias, /**< No alias. */
20 may_alias, /**< Unknown state, may alias. */
21 sure_alias /**< Sure alias. */
24 /** The state of the address taken flags. */
26 ir_address_taken_not_computed, /**< Address taken flag is not computed. */
27 ir_address_taken_computed /**< Address taken flag is computed. */
28 } ir_address_taken_computed_state;
30 /** Possible options for the memory disambiguator. */
32 opt_non_opt = 0, /**< no options */
33 opt_strong_typed = 1, /**< strong typed source language */
34 } disambuigator_options;
37 * A source language specific memory disambiguator function.
38 * Called by get_alias_relation().
40 typedef ir_alias_relation (*DISAMBIGUATOR_FUNC)(
42 ir_node *adr1, ir_mode *mode1,
43 ir_node *adr2, ir_mode *mode2);
46 * Determine the alias relation between two addresses.
48 * @param irg The current graph.
49 * @param adr1 The first address.
50 * @param mode1 The mode of the first memory access.
51 * @param adr2 The second address.
52 * @param mode2 The mode of the second memory access.
53 * @param options Additional options.
55 * The memory disambiguator tries to determine the alias state between
56 * two memory addresses. The following rules are used:
58 * - variables from different segments never alias (R1)
59 * - a global variable and a local one never alias (R1 b)
60 * - a global variable and a TLS one never alias (R1 c)
61 * - a local variable and a TLS one never alias (R1 d)
62 * - two different variables never alias (R2)
63 * - if one is a variable which address has never taken
64 * there is no alias (R3)
65 * - if two memory addresses have the same base and there offsets
66 * do not describe overlapping regions there is no alias (R4)
67 * - if opt_strong_typed is set and both addresses describe entities,
68 * different types never alias (R5)
70 * If none of these rules apply, the points-to framework must be
71 * interrogated to detect the alias relation.
73 ir_alias_relation get_alias_relation(
75 ir_node *adr1, ir_mode *mode1,
76 ir_node *adr2, ir_mode *mode2,
80 * Set a source language specific memory disambiguator function.
82 * @param func The callback.
84 void set_language_memory_disambiguator(DISAMBIGUATOR_FUNC func);
87 * Initialize the relation cache.
89 void mem_disambig_init(void);
92 * Determine the alias relation between two addresses and
95 * @param irg The current graph.
96 * @param adr1 The first address.
97 * @param mode1 The mode of the first memory access.
98 * @param adr2 The second address.
99 * @param mode2 The mode of the second memory access.
100 * @param options Additional options.
102 * @see get_alias_relation()
104 ir_alias_relation get_alias_relation_ex(
106 ir_node *adr1, ir_mode *mode1,
107 ir_node *adr2, ir_mode *mode2,
111 * Free the relation cache.
113 void mem_disambig_term(void);
116 * Returns the current address taken state of the graph.
118 ir_address_taken_computed_state get_irg_address_taken_state(const ir_graph *irg);
121 * Sets the current address taken state of the graph.
123 void set_irg_address_taken_state(ir_graph *irg, ir_address_taken_computed_state state);
126 * Assure that the address taken flag is computed for the given graph.
128 void assure_irg_address_taken_computed(ir_graph *irg);
131 * Returns the current address taken state of the globals.
133 ir_address_taken_computed_state get_irp_globals_address_taken_state(void);
136 * Sets the current address taken state of the globals.
138 void set_irp_globals_address_taken_state(ir_address_taken_computed_state state);
141 * Assure that the address taken flag is computed for the globals.
143 void assure_irp_globals_address_taken_computed(void);
145 #endif /* _FIRM_MEMORY_H */