ia32_bearch_t.h 3.13 KB
Newer Older
Christian Würdig's avatar
Christian Würdig committed
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
Christian Würdig's avatar
Christian Würdig committed
4
5
 */

Christian Würdig's avatar
Christian Würdig committed
6
7
8
9
10
/**
 * @file
 * @brief       This is the main ia32 firm backend driver.
 * @author      Christian Wuerdig
 */
11
12
#ifndef FIRM_BE_IA32_IA32_BEARCH_T_H
#define FIRM_BE_IA32_IA32_BEARCH_T_H
13

14
#include "beirg.h"
15
#include "pmap.h"
16
#include "x86_cconv.h"
17
#include "x86_x87.h"
18

Christian Würdig's avatar
Christian Würdig committed
19
#ifdef NDEBUG
yb9976's avatar
yb9976 committed
20
#define SET_IA32_ORIG_NODE(n, o) ((void)(n), (void)(o), (void)0)
21
#else
22
#define SET_IA32_ORIG_NODE(n, o) set_ia32_orig_node(n, o)
23
#endif
Christian Würdig's avatar
Christian Würdig committed
24

25
26
#define IA32_REGISTER_SIZE 4

27
typedef struct ia32_irg_data_t {
Matthias Braun's avatar
Matthias Braun committed
28
	bool      do_x87_sim;     /**< Should simulate x87 register stack. */
29
	bool      omit_fp;        /**< No frame pointer is used. */
30
	ir_node  *noreg_gp;       /**< unique NoReg_GP node */
31
	ir_node  *noreg_fp;       /**< unique NoReg_FP node */
32
33
34
35
36
	ir_node  *noreg_xmm;      /**< unique NoReg_XMM node */

	ir_node  *fpu_trunc_mode; /**< truncate fpu mode */
	ir_node  *get_eip;        /**< get eip node */
} ia32_irg_data_t;
37

38
extern pmap *ia32_tv_ent; /**< A map of entities that store const tarvals */
39

40
/** The mode for the floating point control word. */
41
extern ir_mode *ia32_mode_fpcw;
42
43
44
45
extern ir_mode *ia32_mode_gp;
extern ir_mode *ia32_mode_float64;
extern ir_mode *ia32_mode_float32;
extern ir_mode *ia32_mode_flags;
46

47
48
static inline ia32_irg_data_t *ia32_get_irg_data(const ir_graph *irg)
{
Matthias Braun's avatar
Matthias Braun committed
49
	return (ia32_irg_data_t*)be_birg_from_irg(irg)->isa_link;
50
}
51

52
53
54
55
56
57
static inline void ia32_request_x87_sim(ir_graph const *const irg)
{
	ia32_irg_data_t *const d = ia32_get_irg_data(irg);
	d->do_x87_sim = true;
}

Christian Würdig's avatar
Christian Würdig committed
58
/**
Christian Würdig's avatar
Christian Würdig committed
59
 * Returns the unique per irg GP NoReg node.
Christian Würdig's avatar
Christian Würdig committed
60
 */
61
62
ir_node *ia32_new_NoReg_gp(ir_graph *irg);
ir_node *ia32_new_NoReg_xmm(ir_graph *irg);
63
ir_node *ia32_new_NoReg_fp(ir_graph *irg);
64

65
/**
66
 * Returns the unique per irg FPU truncation mode node.
67
 */
68
ir_node *ia32_new_Fpu_truncate(ir_graph *irg);
69

70
71
72
73
/**
 * Split instruction with source AM into Load and separate instruction.
 * @return result of the Load
 */
74
ir_node *ia32_turn_back_am(ir_node *node);
75

Matthias Braun's avatar
Matthias Braun committed
76
void ia32_lower64(void);
77

78
79
80
/**
 * Return the stack entity that contains the return address.
 */
81
ir_entity *ia32_get_return_address_entity(ir_graph *irg);
82

83
84
85
/**
 * Return the stack entity that contains the frame address.
 */
86
ir_entity *ia32_get_frame_address_entity(ir_graph *irg);
87

88
89
90
91
92
93
94
95
/**
 * creates global offset table (GOT) for position independent code (PIC) and
 * adjusts address calculations for it.
 */
void ia32_adjust_pic(ir_graph *irg);

ir_node *ia32_get_pic_base(ir_graph *irg);

96
97
98
99
100
static inline bool ia32_is_8bit_val(int32_t const v)
{
	return -128 <= v && v < 128;
}

101
102
103
104
105
/**
 * Determine how function parameters and return values are passed.
 * Decides what goes to register or to stack and what stack offsets/
 * datatypes are used.
 */
Matthias Braun's avatar
Matthias Braun committed
106
107
x86_cconv_t *ia32_decide_calling_convention(ir_type const *function_type,
                                            ir_graph *irg);
108

109
110
int ia32_get_sp_change(ir_node *node);

111
112
void ia32_cconv_init(void);

Matthias Braun's avatar
Cleanup    
Matthias Braun committed
113
114
115
116
117
118
119
120
121
122
123
/**
 * Handle switching of fpu mode
 */
void ia32_setup_fpu_mode(ir_graph *irg);

/**
 * Check 2-Addresscode constraints and call peephole optimizations.
 * @param irg  The irg to finish
 */
void ia32_finish_irg(ir_graph *irg);

124
#endif