becopyopt: Remove the unnecessary attribute name from struct copy_opt_t.
[libfirm] / ir / be / beirg.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief       Backend irg - a ir_graph with additional analysis information.
9  * @author      Matthias Braun
10  * @date        05.05.2006
11  */
12 #ifndef FIRM_BE_BEIRG_H
13 #define FIRM_BE_BEIRG_H
14
15 #include "be.h"
16 #include "be_types.h"
17 #include "be_t.h"
18 #include "irtypes.h"
19
20 void be_assure_live_sets(ir_graph *irg);
21 void be_assure_live_chk(ir_graph *irg);
22 /**
23  * Liveness is invalid (call when nodes have been added but the control
24  * flow has not been changed)
25  */
26 void be_invalidate_live_sets(ir_graph *irg);
27 /**
28  * Call when control flow has changed.
29  * be_invalidate_live_sets() is called.
30  */
31 void be_invalidate_live_chk(ir_graph *irg);
32
33 /**
34  * frees all memory allocated by birg structures (liveness, ...).
35  * The memory of the birg structure itself is not freed.
36  */
37 void be_free_birg(ir_graph *irg);
38
39 /** The number of parts of the stack layout. */
40 #define N_FRAME_TYPES 3
41
42 /**
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.
50  */
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. */
55
56         ir_type *order[N_FRAME_TYPES]; /**< arg, between and frame types ordered. */
57
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) */
62 };
63
64 /**
65  * An ir_graph with additional analysis data about this irg. Also includes some
66  * backend structures
67  */
68 typedef struct be_irg_t {
69         be_main_env_t             *main_env;
70         be_lv_t                   *lv;
71         be_stack_layout_t          stack_layout;
72         unsigned                  *allocatable_regs; /**< registers available for the
73                                                           allocator */
74         arch_register_req_t const *sp_req;           /**< requirements for stackpointer producing
75                                                           nodes. */
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*/
81 } be_irg_t;
82
83 static inline be_irg_t *be_birg_from_irg(const ir_graph *irg)
84 {
85         return (be_irg_t*) irg->be_data;
86 }
87
88 static inline be_main_env_t *be_get_irg_main_env(const ir_graph *irg)
89 {
90         return be_birg_from_irg(irg)->main_env;
91 }
92
93 static inline be_lv_t *be_get_irg_liveness(const ir_graph *irg)
94 {
95         return be_birg_from_irg(irg)->lv;
96 }
97
98 static inline const arch_env_t *be_get_irg_arch_env(const ir_graph *irg)
99 {
100         return be_birg_from_irg(irg)->main_env->arch_env;
101 }
102
103 static inline struct obstack *be_get_be_obst(const ir_graph *irg)
104 {
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);
108         return obst;
109 }
110
111 static inline be_stack_layout_t *be_get_irg_stack_layout(const ir_graph *irg)
112 {
113         return &be_birg_from_irg(irg)->stack_layout;
114 }
115
116 #endif