TEMPLATE_new_nodes.c 2.91 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
 */

6
/**
Matthias Braun's avatar
Matthias Braun committed
7
8
9
10
 * @file
 * @brief   This file implements the creation of the achitecture specific firm
 *          opcodes and the coresponding node constructors for the TEMPLATE
 *          assembler irg.
11
12
13
14
15
16
17
18
19
20
 */
#include <stdlib.h>

#include "irprog_t.h"
#include "irgraph_t.h"
#include "irnode_t.h"
#include "irmode_t.h"
#include "ircons_t.h"
#include "iropt_t.h"
#include "irop.h"
Christian Würdig's avatar
Christian Würdig committed
21
#include "irprintf.h"
22
#include "xmalloc.h"
23
#include "bedump.h"
24
25
26
27
28
29
30
31

#include "TEMPLATE_nodes_attr.h"
#include "TEMPLATE_new_nodes.h"
#include "gen_TEMPLATE_regalloc_if.h"

/**
 * Dumper interface for dumping TEMPLATE nodes in vcg.
 * @param F        the output file
32
 * @param n        the node to dump
33
34
 * @param reason   indicates which kind of information should be dumped
 */
35
static void TEMPLATE_dump_node(FILE *F, const ir_node *n, dump_reason_t reason)
36
{
37
	switch (reason) {
38
39
40
	case dump_node_opcode_txt:
		fprintf(F, "%s", get_irn_opname(n));
		break;
41

42
	case dump_node_mode_txt:
43
		fprintf(F, "[%s]", get_mode_name(get_irn_mode(n)));
44
45
46
		break;

	case dump_node_nodeattr_txt:
47

48
49
		/* TODO: dump some attributes which should show up */
		/* in node name in dump (e.g. consts or the like)  */
50

51
52
53
		break;

	case dump_node_info_txt:
54
		be_dump_reqs_and_registers(F, n);
55
56
57
		break;
	}
}
58

59
60
const TEMPLATE_attr_t *get_TEMPLATE_attr_const(const ir_node *node)
{
61
	assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
Matthias Braun's avatar
Matthias Braun committed
62
	return (const TEMPLATE_attr_t *)get_irn_generic_attr_const(node);
63
64
}

65
66
TEMPLATE_attr_t *get_TEMPLATE_attr(ir_node *node)
{
67
	assert(is_TEMPLATE_irn(node) && "need TEMPLATE node to get attributes");
68
	return (TEMPLATE_attr_t *)get_irn_generic_attr(node);
69
70
}

71
static void set_TEMPLATE_value(ir_node *const node, ir_entity *const entity, ir_tarval *const value)
72
73
74
{
	TEMPLATE_attr_t *attr = get_TEMPLATE_attr(node);
	attr->entity = entity;
75
	attr->value  = value;
76
77
}

78
static int TEMPLATE_attrs_equal(const ir_node *a, const ir_node *b)
79
80
81
{
	const TEMPLATE_attr_t *attr_a = get_TEMPLATE_attr_const(a);
	const TEMPLATE_attr_t *attr_b = get_TEMPLATE_attr_const(b);
82
83
	return attr_a->value == attr_b->value
	    && attr_a->entity == attr_b->entity;
84
85
}

86
87
88
89
90
91
92
93
94
95
96
97
98
static void TEMPLATE_copy_attr(ir_graph *irg, const ir_node *old_node,
                               ir_node *new_node)
{
	struct obstack *obst    = get_irg_obstack(irg);
	const void     *attr_old = get_irn_generic_attr_const(old_node);
	void           *attr_new = get_irn_generic_attr(new_node);
	backend_info_t *old_info = be_get_info(old_node);
	backend_info_t *new_info = be_get_info(new_node);

	/* copy the attributes */
	memcpy(attr_new, attr_old, get_op_attr_size(get_irn_op(old_node)));

	/* copy out flags */
99
	new_info->flags = old_info->flags;
100
101
102
103
104
	new_info->out_infos =
		DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos);
	new_info->in_reqs = old_info->in_reqs;
}

105
106
/* Include the generated constructor functions */
#include "gen_TEMPLATE_new_nodes.c.inl"