amd64_new_nodes.h 3.68 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
		|| attr->op_mode == AMD64_OP_IMM32;
45
46
}

Matthias Braun's avatar
Matthias Braun committed
47
48
static inline amd64_addr_attr_t *get_amd64_addr_attr(ir_node *node)
{
49
	assert(amd64_has_addr_attr(node));
Matthias Braun's avatar
Matthias Braun committed
50
51
52
53
54
55
	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)
{
56
	assert(amd64_has_addr_attr(node));
Matthias Braun's avatar
Matthias Braun committed
57
58
59
60
61
	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)
{
62
	assert(amd64_has_binop_attr(node));
Matthias Braun's avatar
Matthias Braun committed
63
64
65
66
67
68
	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)
{
69
	assert(amd64_has_binop_attr(node));
Matthias Braun's avatar
Matthias Braun committed
70
71
72
	return (const amd64_binop_addr_attr_t*)get_irn_generic_attr_const(node);
}

73
74
75
76
77
78
79
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
80
81
82
static inline const amd64_shift_attr_t *get_amd64_shift_attr_const(
		const ir_node *node)
{
83
	assert(amd64_has_shift_attr(node));
Matthias Braun's avatar
Matthias Braun committed
84
85
86
87
88
	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)
{
89
	assert(amd64_has_shift_attr(node));
Matthias Braun's avatar
Matthias Braun committed
90
91
92
93
94
95
	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)
{
96
	assert(is_amd64_jmp_switch(node));
Matthias Braun's avatar
Matthias Braun committed
97
98
99
100
101
	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)
{
102
	assert(is_amd64_jmp_switch(node));
Matthias Braun's avatar
Matthias Braun committed
103
104
105
106
107
108
	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)
{
109
	assert(is_amd64_jcc(node));
Matthias Braun's avatar
Matthias Braun committed
110
111
112
113
114
	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)
{
115
	assert(is_amd64_jcc(node));
Matthias Braun's avatar
Matthias Braun committed
116
117
	return (amd64_cc_attr_t*)get_irn_generic_attr(node);
}
118

Matthias Braun's avatar
Matthias Braun committed
119
120
121
static inline const amd64_movimm_attr_t *get_amd64_movimm_attr_const(
		const ir_node *node)
{
122
	assert(is_amd64_mov_imm(node));
Matthias Braun's avatar
Matthias Braun committed
123
124
	return (const amd64_movimm_attr_t*)get_irn_generic_attr_const(node);
}
125

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

132
133
134
135
/* Include the generated headers */
#include "gen_amd64_new_nodes.h"

#endif