amd64_new_nodes.h 4.37 KB
Newer Older
1
2
/*
 * This file is part of libFirm.
3
 * Copyright (C) 2012 University of Karlsruhe.
4
5
6
7
8
9
 */

/**
 * @file
 * @brief   Function prototypes for the assembler ir node constructors.
 */
10
11
#ifndef FIRM_BE_AMD64_AMD64_NEW_NODES_H
#define FIRM_BE_AMD64_AMD64_NEW_NODES_H
12
13

#include "amd64_nodes_attr.h"
Matthias Braun's avatar
Matthias Braun committed
14
#include "gen_amd64_new_nodes.h"
15

Matthias Braun's avatar
Matthias Braun committed
16
17
18
19
20
21
22
23
24
25
26
27
static inline amd64_attr_t *get_amd64_attr(ir_node *node)
{
	assert(is_amd64_irn(node));
	return (amd64_attr_t*)get_irn_generic_attr(node);
}

static inline const amd64_attr_t *get_amd64_attr_const(const ir_node *node)
{
	assert(is_amd64_irn(node));
	return (const amd64_attr_t*)get_irn_generic_attr_const(node);
}

28
29
30
31
32
static inline bool amd64_has_binop_attr(const ir_node *node)
{
	const amd64_attr_t *attr = get_amd64_attr_const(node);
	return attr->op_mode == AMD64_OP_REG_REG
	    || attr->op_mode == AMD64_OP_REG_IMM
33
	    || attr->op_mode == AMD64_OP_REG_ADDR
34
35
36
37
38
39
40
	    || attr->op_mode == AMD64_OP_ADDR_REG
	    || attr->op_mode == AMD64_OP_ADDR_IMM;
}

static inline bool amd64_has_addr_attr(const ir_node *node)
{
	const amd64_attr_t *attr = get_amd64_attr_const(node);
41
	return amd64_has_binop_attr(node)
42
43
		|| attr->op_mode == AMD64_OP_ADDR
		|| attr->op_mode == AMD64_OP_REG
44
45
		|| attr->op_mode == AMD64_OP_OUTREG_REG
		|| attr->op_mode == AMD64_OP_OUTREG_ADDR
46
		|| attr->op_mode == AMD64_OP_IMM32;
47
48
}

Matthias Braun's avatar
Matthias Braun committed
49
50
static inline amd64_addr_attr_t *get_amd64_addr_attr(ir_node *node)
{
51
	assert(amd64_has_addr_attr(node));
Matthias Braun's avatar
Matthias Braun committed
52
53
54
55
56
57
	return (amd64_addr_attr_t*)get_irn_generic_attr(node);
}

static inline const amd64_addr_attr_t *get_amd64_addr_attr_const(
		const ir_node *node)
{
58
	assert(amd64_has_addr_attr(node));
Matthias Braun's avatar
Matthias Braun committed
59
60
61
62
63
	return (const amd64_addr_attr_t*)get_irn_generic_attr_const(node);
}

static inline amd64_binop_addr_attr_t *get_amd64_binop_addr_attr(ir_node *node)
{
64
	assert(amd64_has_binop_attr(node));
Matthias Braun's avatar
Matthias Braun committed
65
66
67
68
69
70
	return (amd64_binop_addr_attr_t*)get_irn_generic_attr(node);
}

static inline const amd64_binop_addr_attr_t *get_amd64_binop_addr_attr_const(
		const ir_node *node)
{
71
	assert(amd64_has_binop_attr(node));
Matthias Braun's avatar
Matthias Braun committed
72
73
74
	return (const amd64_binop_addr_attr_t*)get_irn_generic_attr_const(node);
}

75
76
77
78
79
80
81
static inline bool amd64_has_shift_attr(const ir_node *node)
{
	const amd64_attr_t *attr = get_amd64_attr_const(node);
	return attr->op_mode == AMD64_OP_SHIFT_REG
	    || attr->op_mode == AMD64_OP_SHIFT_IMM;
}

Matthias Braun's avatar
Matthias Braun committed
82
83
84
static inline const amd64_shift_attr_t *get_amd64_shift_attr_const(
		const ir_node *node)
{
85
	assert(amd64_has_shift_attr(node));
Matthias Braun's avatar
Matthias Braun committed
86
87
88
89
90
	return (const amd64_shift_attr_t*)get_irn_generic_attr_const(node);
}

static inline amd64_shift_attr_t *get_amd64_shift_attr(ir_node *node)
{
91
	assert(amd64_has_shift_attr(node));
Matthias Braun's avatar
Matthias Braun committed
92
93
94
95
96
97
	return (amd64_shift_attr_t*)get_irn_generic_attr(node);
}

static inline const amd64_switch_jmp_attr_t *get_amd64_switch_jmp_attr_const(
		const ir_node *node)
{
98
	assert(is_amd64_jmp_switch(node));
Matthias Braun's avatar
Matthias Braun committed
99
100
101
102
103
	return (const amd64_switch_jmp_attr_t*)get_irn_generic_attr_const(node);
}

static inline amd64_switch_jmp_attr_t *get_amd64_switch_jmp_attr(ir_node *node)
{
104
	assert(is_amd64_jmp_switch(node));
Matthias Braun's avatar
Matthias Braun committed
105
106
107
	return (amd64_switch_jmp_attr_t*)get_irn_generic_attr(node);
}

Andreas Fried's avatar
Andreas Fried committed
108
109
110
111
112
static inline bool amd64_has_cc_attr(const ir_node *node)
{
	return is_amd64_jcc(node) || is_amd64_setcc(node);
}

Matthias Braun's avatar
Matthias Braun committed
113
114
115
static inline const amd64_cc_attr_t *get_amd64_cc_attr_const(
	const ir_node *node)
{
Andreas Fried's avatar
Andreas Fried committed
116
	assert(amd64_has_cc_attr(node));
Matthias Braun's avatar
Matthias Braun committed
117
118
119
120
121
	return (const amd64_cc_attr_t*)get_irn_generic_attr_const(node);
}

static inline amd64_cc_attr_t *get_amd64_cc_attr(ir_node *node)
{
Andreas Fried's avatar
Andreas Fried committed
122
	assert(amd64_has_cc_attr(node));
Matthias Braun's avatar
Matthias Braun committed
123
124
	return (amd64_cc_attr_t*)get_irn_generic_attr(node);
}
125

Matthias Braun's avatar
Matthias Braun committed
126
127
128
static inline const amd64_movimm_attr_t *get_amd64_movimm_attr_const(
		const ir_node *node)
{
129
	assert(is_amd64_mov_imm(node));
Matthias Braun's avatar
Matthias Braun committed
130
131
	return (const amd64_movimm_attr_t*)get_irn_generic_attr_const(node);
}
132

Matthias Braun's avatar
Matthias Braun committed
133
134
static inline amd64_movimm_attr_t *get_amd64_movimm_attr(ir_node *node)
{
135
	assert(is_amd64_mov_imm(node));
Matthias Braun's avatar
Matthias Braun committed
136
137
	return (amd64_movimm_attr_t*)get_irn_generic_attr(node);
}
138

139
140
141
142
143
144
145
146
147
148
149
150
151
static inline const amd64_call_addr_attr_t *get_amd64_call_addr_attr_const(
	const ir_node *node)
{
	assert(is_amd64_call(node));
	return (const amd64_call_addr_attr_t*)get_irn_generic_attr_const(node);
}

static inline amd64_call_addr_attr_t *get_amd64_call_addr_attr (ir_node *node)
{
	assert(is_amd64_call(node));
	return (amd64_call_addr_attr_t*)get_irn_generic_attr(node);
}

152
153
154
amd64_insn_mode_t get_amd64_insn_mode(const ir_node *node);
int get_insn_mode_bits(amd64_insn_mode_t insn_mode);

155
156
157
158
/* Include the generated headers */
#include "gen_amd64_new_nodes.h"

#endif