amd64_new_nodes.h 3.94 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

Matthias Braun's avatar
Matthias Braun committed
19
20
21
22
23
24
25
26
27
28
29
30
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);
}

31
32
33
34
35
36
37
38
39
40
41
42
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);
43
	return (amd64_has_binop_attr(node)
44
45
46
47
48
		|| 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
49
50
	    || attr->op_mode == AMD64_OP_RAX_ADDR
	    || attr->op_mode == AMD64_OP_RAX_REG)
51
52
	    && (get_irn_op(node) != op_amd64_Xor0)
	    && (get_irn_op(node) != op_amd64_Xorp0);
53
54
}

Matthias Braun's avatar
Matthias Braun committed
55
56
static inline amd64_addr_attr_t *get_amd64_addr_attr(ir_node *node)
{
57
	assert(amd64_has_addr_attr(node));
Matthias Braun's avatar
Matthias Braun committed
58
59
60
61
62
63
	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)
{
64
	assert(amd64_has_addr_attr(node));
Matthias Braun's avatar
Matthias Braun committed
65
66
67
68
69
	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)
{
70
	assert(amd64_has_binop_attr(node));
Matthias Braun's avatar
Matthias Braun committed
71
72
73
74
75
76
	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)
{
77
	assert(amd64_has_binop_attr(node));
Matthias Braun's avatar
Matthias Braun committed
78
79
80
	return (const amd64_binop_addr_attr_t*)get_irn_generic_attr_const(node);
}

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

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

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

140
141
142
143
/* Include the generated headers */
#include "gen_amd64_new_nodes.h"

#endif