2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief This is the main ia32 firm backend driver.
9 * @author Christian Wuerdig
11 #ifndef FIRM_BE_IA32_BEARCH_IA32_T_H
12 #define FIRM_BE_IA32_BEARCH_IA32_T_H
21 #define SET_IA32_ORIG_NODE(n, o)
23 #define SET_IA32_ORIG_NODE(n, o) set_ia32_orig_node(n, o)
26 typedef struct ia32_isa_t ia32_isa_t;
27 typedef struct ia32_intrinsic_env_t ia32_intrinsic_env_t;
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 */
37 ir_node *fpu_trunc_mode; /**< truncate fpu mode */
38 ir_node *get_eip; /**< get eip node */
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 */
51 * A helper type collecting needed info for IA32 intrinsic lowering.
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 */
60 typedef enum transformer_t {
69 /** The selected transformer. */
70 extern transformer_t be_transformer;
73 #define be_transformer TRANSFORMER_DEFAULT
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;
82 static inline ia32_irg_data_t *ia32_get_irg_data(const ir_graph *irg)
84 return (ia32_irg_data_t*) be_birg_from_irg(irg)->isa_link;
87 static inline void ia32_request_x87_sim(ir_graph const *const irg)
89 ia32_irg_data_t *const d = ia32_get_irg_data(irg);
94 * Returns the unique per irg GP NoReg node.
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);
101 * Returns the unique per irg FPU truncation mode node.
103 ir_node *ia32_new_Fpu_truncate(ir_graph *irg);
106 * Split instruction with source AM into Load and separate instruction.
107 * @return result of the Load
109 ir_node *ia32_turn_back_am(ir_node *node);
112 * Maps all intrinsic calls that the backend support
113 * and map all instructions the backend did not support
116 void ia32_handle_intrinsics(void);
119 * Ia32 implementation.
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
127 ir_entity *ia32_create_intrinsic_fkt(ir_type *method, const ir_op *op,
128 const ir_mode *imode, const ir_mode *omode,
132 * Return the stack entity that contains the return address.
134 ir_entity *ia32_get_return_address_entity(ir_graph *irg);
137 * Return the stack entity that contains the frame address.
139 ir_entity *ia32_get_frame_address_entity(ir_graph *irg);