amd64_new_nodes.h 4.08 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 <stdint.h>
Matthias Braun's avatar
Matthias Braun committed
14
15

#include "irnode_t.h"
16
#include "amd64_nodes_attr.h"
Matthias Braun's avatar
Matthias Braun committed
17
#include "gen_amd64_new_nodes.h"
18

19
20
enum {
	pn_amd64_Call_mem       = 0,
21
22
	pn_amd64_Call_flags     = 1,
	pn_amd64_Call_first_res = 2,
23
24
25
26
27
};
enum {
	n_amd64_Return_stack = 1,
};

Matthias Braun's avatar
Matthias Braun committed
28
29
30
31
32
33
34
35
36
37
38
39
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);
}

40
41
42
43
44
45
46
47
48
49
50
51
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
	    || 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);
52
	return (amd64_has_binop_attr(node)
53
54
55
56
57
		|| attr->op_mode == AMD64_OP_ADDR
		|| attr->op_mode == AMD64_OP_REG
	    || attr->op_mode == AMD64_OP_UNOP_ADDR
	    || attr->op_mode == AMD64_OP_UNOP_IMM32
	    || attr->op_mode == AMD64_OP_UNOP_REG
58
59
	    || attr->op_mode == AMD64_OP_RAX_ADDR
	    || attr->op_mode == AMD64_OP_RAX_REG)
60
61
	    && (get_irn_op(node) != op_amd64_xor_0)
	    && (get_irn_op(node) != op_amd64_xorpd_0);
62
63
}

Matthias Braun's avatar
Matthias Braun committed
64
65
static inline amd64_addr_attr_t *get_amd64_addr_attr(ir_node *node)
{
66
	assert(amd64_has_addr_attr(node));
Matthias Braun's avatar
Matthias Braun committed
67
68
69
70
71
72
	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)
{
73
	assert(amd64_has_addr_attr(node));
Matthias Braun's avatar
Matthias Braun committed
74
75
76
77
78
	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)
{
79
	assert(amd64_has_binop_attr(node));
Matthias Braun's avatar
Matthias Braun committed
80
81
82
83
84
85
	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)
{
86
	assert(amd64_has_binop_attr(node));
Matthias Braun's avatar
Matthias Braun committed
87
88
89
	return (const amd64_binop_addr_attr_t*)get_irn_generic_attr_const(node);
}

90
91
92
93
94
95
96
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
97
98
99
static inline const amd64_shift_attr_t *get_amd64_shift_attr_const(
		const ir_node *node)
{
100
	assert(amd64_has_shift_attr(node));
Matthias Braun's avatar
Matthias Braun committed
101
102
103
104
105
	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)
{
106
	assert(amd64_has_shift_attr(node));
Matthias Braun's avatar
Matthias Braun committed
107
108
109
110
111
112
	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)
{
113
	assert(is_amd64_jmp_switch(node));
Matthias Braun's avatar
Matthias Braun committed
114
115
116
117
118
	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)
{
119
	assert(is_amd64_jmp_switch(node));
Matthias Braun's avatar
Matthias Braun committed
120
121
122
123
124
125
	return (amd64_switch_jmp_attr_t*)get_irn_generic_attr(node);
}

static inline const amd64_cc_attr_t *get_amd64_cc_attr_const(
	const ir_node *node)
{
126
	assert(is_amd64_jcc(node));
Matthias Braun's avatar
Matthias Braun committed
127
128
129
130
131
	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)
{
132
	assert(is_amd64_jcc(node));
Matthias Braun's avatar
Matthias Braun committed
133
134
	return (amd64_cc_attr_t*)get_irn_generic_attr(node);
}
135

Matthias Braun's avatar
Matthias Braun committed
136
137
138
static inline const amd64_movimm_attr_t *get_amd64_movimm_attr_const(
		const ir_node *node)
{
139
	assert(is_amd64_mov_imm(node));
Matthias Braun's avatar
Matthias Braun committed
140
141
	return (const amd64_movimm_attr_t*)get_irn_generic_attr_const(node);
}
142

Matthias Braun's avatar
Matthias Braun committed
143
144
static inline amd64_movimm_attr_t *get_amd64_movimm_attr(ir_node *node)
{
145
	assert(is_amd64_mov_imm(node));
Matthias Braun's avatar
Matthias Braun committed
146
147
	return (amd64_movimm_attr_t*)get_irn_generic_attr(node);
}
148

149
150
151
152
/* Include the generated headers */
#include "gen_amd64_new_nodes.h"

#endif