ia32_bearch_t.h 2.99 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 <limits.h>
15
#include "beirg.h"
16
#include "pmap.h"
17
#include "x86_cconv.h"
18
#include "x86_x87.h"
19

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

26
27
#define IA32_REGISTER_SIZE 4

28
typedef struct ia32_irg_data_t {
Matthias Braun's avatar
Matthias Braun committed
29
	bool      do_x87_sim;     /**< Should simulate x87 register stack. */
30
	bool      omit_fp;        /**< No frame pointer is used. */
31
	ir_node  *noreg_gp;       /**< unique NoReg_GP node */
32
	ir_node  *noreg_fp;       /**< unique NoReg_FP node */
33
34
35
36
37
	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;
38

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

41
/** The mode for the floating point control word. */
42
extern ir_mode *ia32_mode_fpcw;
43
extern ir_mode *ia32_mode_8h; /**< Mode for high 8bit registers */
44
45
46
47
extern ir_mode *ia32_mode_gp;
extern ir_mode *ia32_mode_float64;
extern ir_mode *ia32_mode_float32;
extern ir_mode *ia32_mode_flags;
48

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

54
55
56
57
58
59
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
60
/**
Christian Würdig's avatar
Christian Würdig committed
61
 * Returns the unique per irg GP NoReg node.
Christian Würdig's avatar
Christian Würdig committed
62
 */
63
64
ir_node *ia32_new_NoReg_gp(ir_graph *irg);
ir_node *ia32_new_NoReg_xmm(ir_graph *irg);
65
ir_node *ia32_new_NoReg_fp(ir_graph *irg);
66

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

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

Matthias Braun's avatar
Matthias Braun committed
78
void ia32_lower64(void);
79

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

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

90
91
92
93
94
95
96
97
/**
 * 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);

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

103
104
105
106
107
/**
 * 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
108
109
x86_cconv_t *ia32_decide_calling_convention(ir_type const *function_type,
                                            ir_graph *irg);
110

111
112
int ia32_get_sp_change(ir_node *node);

113
114
void ia32_cconv_init(void);

115
#endif