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
17 #include "ia32_nodes_attr.h"
22 #include "beemitter.h"
24 #include "gen_ia32_regalloc_if.h"
27 #define SET_IA32_ORIG_NODE(n, o)
29 #define SET_IA32_ORIG_NODE(n, o) set_ia32_orig_node(n, o)
32 typedef struct ia32_isa_t ia32_isa_t;
33 typedef struct ia32_irn_ops_t ia32_irn_ops_t;
34 typedef struct ia32_intrinsic_env_t ia32_intrinsic_env_t;
36 typedef struct ia32_irg_data_t {
37 ir_node **blk_sched; /**< an array containing the scheduled blocks */
38 unsigned do_x87_sim:1; /**< set to 1 if x87 simulation should be enforced */
39 unsigned dump:1; /**< set to 1 if graphs should be dumped */
40 ir_node *noreg_gp; /**< unique NoReg_GP node */
41 ir_node *noreg_fp; /**< unique NoReg_FP node */
42 ir_node *noreg_xmm; /**< unique NoReg_XMM node */
44 ir_node *fpu_trunc_mode; /**< truncate fpu mode */
45 ir_node *get_eip; /**< get eip node */
52 arch_env_t base; /**< must be derived from arch_env_t */
53 pmap *tv_ent; /**< A map of entities that store const tarvals */
54 int fpu_arch; /**< FPU architecture */
58 * A helper type collecting needed info for IA32 intrinsic lowering.
60 struct ia32_intrinsic_env_t {
61 ir_entity *divdi3; /**< entity for __divdi3 library call */
62 ir_entity *moddi3; /**< entity for __moddi3 library call */
63 ir_entity *udivdi3; /**< entity for __udivdi3 library call */
64 ir_entity *umoddi3; /**< entity for __umoddi3 library call */
67 typedef enum transformer_t {
76 /** The selected transformer. */
77 extern transformer_t be_transformer;
80 #define be_transformer TRANSFORMER_DEFAULT
83 /** The mode for the floating point control word. */
84 extern ir_mode *ia32_mode_fpcw;
85 /** extended floatingpoint mode */
86 extern ir_mode *ia32_mode_E;
87 extern ir_type *ia32_type_E;
89 static inline ia32_irg_data_t *ia32_get_irg_data(const ir_graph *irg)
91 return (ia32_irg_data_t*) be_birg_from_irg(irg)->isa_link;
94 static inline void ia32_request_x87_sim(ir_graph const *const irg)
96 ia32_irg_data_t *const d = ia32_get_irg_data(irg);
101 * Returns the unique per irg GP NoReg node.
103 ir_node *ia32_new_NoReg_gp(ir_graph *irg);
104 ir_node *ia32_new_NoReg_xmm(ir_graph *irg);
105 ir_node *ia32_new_NoReg_fp(ir_graph *irg);
108 * Returns the unique per irg FPU truncation mode node.
110 ir_node *ia32_new_Fpu_truncate(ir_graph *irg);
113 * Split instruction with source AM into Load and separate instruction.
114 * @return result of the Load
116 ir_node *ia32_turn_back_am(ir_node *node);
119 * Maps all intrinsic calls that the backend support
120 * and map all instructions the backend did not support
123 void ia32_handle_intrinsics(void);
126 * Ia32 implementation.
128 * @param method the method type of the emulation function entity
129 * @param op the emulated ir_op
130 * @param imode the input mode of the emulated opcode
131 * @param omode the output mode of the emulated opcode
132 * @param context the context parameter
134 ir_entity *ia32_create_intrinsic_fkt(ir_type *method, const ir_op *op,
135 const ir_mode *imode, const ir_mode *omode,
139 * Return the stack entity that contains the return address.
141 ir_entity *ia32_get_return_address_entity(ir_graph *irg);
144 * Return the stack entity that contains the frame address.
146 ir_entity *ia32_get_frame_address_entity(ir_graph *irg);