be: Remove cruft from bearch_*_t.h.
[libfirm] / ir / be / ia32 / bearch_ia32_t.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief       This is the main ia32 firm backend driver.
9  * @author      Christian Wuerdig
10  */
11 #ifndef FIRM_BE_IA32_BEARCH_IA32_T_H
12 #define FIRM_BE_IA32_BEARCH_IA32_T_H
13
14 #include "config.h"
15
16 #include "bearch.h"
17 #include "beirg.h"
18 #include "pmap.h"
19
20 #ifdef NDEBUG
21 #define SET_IA32_ORIG_NODE(n, o)
22 #else  /* ! NDEBUG */
23 #define SET_IA32_ORIG_NODE(n, o) set_ia32_orig_node(n, o)
24 #endif /* NDEBUG */
25
26 typedef struct ia32_isa_t            ia32_isa_t;
27 typedef struct ia32_intrinsic_env_t  ia32_intrinsic_env_t;
28
29 typedef struct ia32_irg_data_t {
30         ir_node  **blk_sched;     /**< an array containing the scheduled blocks */
31         unsigned do_x87_sim:1;    /**< set to 1 if x87 simulation should be enforced */
32         unsigned dump:1;          /**< set to 1 if graphs should be dumped */
33         ir_node  *noreg_gp;       /**< unique NoReg_GP node */
34         ir_node  *noreg_fp;       /**< unique NoReg_FP node */
35         ir_node  *noreg_xmm;      /**< unique NoReg_XMM node */
36
37         ir_node  *fpu_trunc_mode; /**< truncate fpu mode */
38         ir_node  *get_eip;        /**< get eip node */
39 } ia32_irg_data_t;
40
41 /**
42  * IA32 ISA object
43  */
44 struct ia32_isa_t {
45         arch_env_t             base;     /**< must be derived from arch_env_t */
46         pmap                  *tv_ent;   /**< A map of entities that store const tarvals */
47         int                    fpu_arch; /**< FPU architecture */
48 };
49
50 /**
51  * A helper type collecting needed info for IA32 intrinsic lowering.
52  */
53 struct ia32_intrinsic_env_t {
54         ir_entity  *divdi3;  /**< entity for __divdi3 library call */
55         ir_entity  *moddi3;  /**< entity for __moddi3 library call */
56         ir_entity  *udivdi3; /**< entity for __udivdi3 library call */
57         ir_entity  *umoddi3; /**< entity for __umoddi3 library call */
58 };
59
60 typedef enum transformer_t {
61         TRANSFORMER_DEFAULT,
62 #ifdef FIRM_GRGEN_BE
63         TRANSFORMER_PBQP,
64         TRANSFORMER_RAND
65 #endif
66 } transformer_t;
67
68 #ifdef FIRM_GRGEN_BE
69 /** The selected transformer. */
70 extern transformer_t be_transformer;
71
72 #else
73 #define be_transformer TRANSFORMER_DEFAULT
74 #endif
75
76 /** The mode for the floating point control word. */
77 extern ir_mode *ia32_mode_fpcw;
78 /** extended floatingpoint mode */
79 extern ir_mode *ia32_mode_E;
80 extern ir_type *ia32_type_E;
81
82 static inline ia32_irg_data_t *ia32_get_irg_data(const ir_graph *irg)
83 {
84         return (ia32_irg_data_t*) be_birg_from_irg(irg)->isa_link;
85 }
86
87 static inline void ia32_request_x87_sim(ir_graph const *const irg)
88 {
89         ia32_irg_data_t *const d = ia32_get_irg_data(irg);
90         d->do_x87_sim = true;
91 }
92
93 /**
94  * Returns the unique per irg GP NoReg node.
95  */
96 ir_node *ia32_new_NoReg_gp(ir_graph *irg);
97 ir_node *ia32_new_NoReg_xmm(ir_graph *irg);
98 ir_node *ia32_new_NoReg_fp(ir_graph *irg);
99
100 /**
101  * Returns the unique per irg FPU truncation mode node.
102  */
103 ir_node *ia32_new_Fpu_truncate(ir_graph *irg);
104
105 /**
106  * Split instruction with source AM into Load and separate instruction.
107  * @return result of the Load
108  */
109 ir_node *ia32_turn_back_am(ir_node *node);
110
111 /**
112  * Maps all intrinsic calls that the backend support
113  * and map all instructions the backend did not support
114  * to runtime calls.
115  */
116 void ia32_handle_intrinsics(void);
117
118 /**
119  * Ia32 implementation.
120  *
121  * @param method   the method type of the emulation function entity
122  * @param op       the emulated ir_op
123  * @param imode    the input mode of the emulated opcode
124  * @param omode    the output mode of the emulated opcode
125  * @param context  the context parameter
126  */
127 ir_entity *ia32_create_intrinsic_fkt(ir_type *method, const ir_op *op,
128                                      const ir_mode *imode, const ir_mode *omode,
129                                      void *context);
130
131 /**
132  * Return the stack entity that contains the return address.
133  */
134 ir_entity *ia32_get_return_address_entity(ir_graph *irg);
135
136 /**
137  * Return the stack entity that contains the frame address.
138  */
139 ir_entity *ia32_get_frame_address_entity(ir_graph *irg);
140
141 #endif