2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Backend irg - a ir_graph with additional analysis information.
9 * @author Matthias Braun
12 #ifndef FIRM_BE_BEIRG_H
13 #define FIRM_BE_BEIRG_H
20 void be_assure_live_sets(ir_graph *irg);
21 void be_assure_live_chk(ir_graph *irg);
23 * Liveness is invalid (call when nodes have been added but the control
24 * flow has not been changed)
26 void be_invalidate_live_sets(ir_graph *irg);
28 * Call when control flow has changed.
29 * be_invalidate_live_sets() is called.
31 void be_invalidate_live_chk(ir_graph *irg);
34 * frees all memory allocated by birg structures (liveness, ...).
35 * The memory of the birg structure itself is not freed.
37 void be_free_birg(ir_graph *irg);
39 /** The number of parts of the stack layout. */
40 #define N_FRAME_TYPES 3
43 * This type describes the stack layout.
44 * The stack is divided into 3 parts:
45 * - arg_type: A struct type describing the stack arguments and its order.
46 * - between_type: A struct type describing the stack layout between arguments
47 * and frame type. In architectures that put the return address
48 * automatically on the stack, the return address is put here.
49 * - frame_type: A class type describing the frame layout.
51 struct be_stack_layout_t {
52 ir_type *arg_type; /**< A type describing the stack argument layout. */
53 ir_type *between_type; /**< A type describing the "between" layout. */
54 ir_type *frame_type; /**< The frame type. */
56 ir_type *order[N_FRAME_TYPES]; /**< arg, between and frame types ordered. */
58 int initial_offset; /**< the initial difference between stack pointer and frame pointer */
59 int initial_bias; /**< the initial stack bias */
60 bool sp_relative : 1; /**< entities are addressed relative to
61 stack pointer (omit-fp mode) */
65 * An ir_graph with additional analysis data about this irg. Also includes some
68 typedef struct be_irg_t {
69 be_main_env_t *main_env;
71 be_stack_layout_t stack_layout;
72 unsigned *allocatable_regs; /**< registers available for the
74 arch_register_req_t const *sp_req; /**< requirements for stackpointer producing
76 struct obstack obst; /**< birg obstack (mainly used to keep
77 register constraints which we can't keep
78 in the irg obst, because it gets replaced
79 during code selection) */
80 void *isa_link; /**< architecture specific per-graph data*/
83 static inline be_irg_t *be_birg_from_irg(const ir_graph *irg)
85 return (be_irg_t*) irg->be_data;
88 static inline be_main_env_t *be_get_irg_main_env(const ir_graph *irg)
90 return be_birg_from_irg(irg)->main_env;
93 static inline be_lv_t *be_get_irg_liveness(const ir_graph *irg)
95 return be_birg_from_irg(irg)->lv;
98 static inline const arch_env_t *be_get_irg_arch_env(const ir_graph *irg)
100 return be_birg_from_irg(irg)->main_env->arch_env;
103 static inline struct obstack *be_get_be_obst(const ir_graph *irg)
105 be_irg_t *const birg = be_birg_from_irg(irg);
106 struct obstack *const obst = &birg->obst;
107 assert(obstack_object_size(obst) == 0);
111 static inline be_stack_layout_t *be_get_irg_stack_layout(const ir_graph *irg)
113 return &be_birg_from_irg(irg)->stack_layout;