-
Notifications
You must be signed in to change notification settings - Fork 15
/
be-track-6800.c
151 lines (137 loc) · 2.17 KB
/
be-track-6800.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "compiler.h"
#include "backend.h"
#include "backend-6800.h"
/*
* Start with some simple X versus S tracking
* to clean up the local accesses
*/
uint16_t x_fpoff;
unsigned x_fprel;
uint8_t a_val;
uint8_t b_val;
unsigned a_valid;
unsigned b_valid;
unsigned d_valid;
static struct node d_node;
void invalidate_all(void)
{
x_fprel = 0;
a_valid = 0;
b_valid = 0;
d_valid = 0;
}
void invalidate_x(void)
{
x_fprel = 0;
}
void invalidate_a(void)
{
a_valid = 0;
}
void invalidate_b(void)
{
b_valid = 0;
}
void invalidate_d(void)
{
d_valid = 0;
}
void invalidate_work(void)
{
a_valid = 0;
b_valid = 0;
d_valid = 0;
}
void invalidate_mem(void)
{
/* If memory changes it might be an alias to the value cached in AB */
switch(d_node.op) {
case T_LREF:
case T_LBREF:
case T_NREF:
d_valid = 0;
}
}
void set_d_node(struct node *n)
{
memcpy(&d_node, n, sizeof(struct node));
switch(d_node.op) {
case T_LSTORE:
d_node.op = T_LREF;
break;
case T_LBSTORE:
d_node.op = T_LBREF;
break;
case T_NSTORE:
d_node.op = T_NREF;
break;
case T_RSTORE:
d_node.op = T_RREF;
break;
case T_NREF:
case T_LBREF:
case T_LREF:
case T_NAME:
case T_LABEL:
case T_LOCAL:
case T_ARGUMENT:
break;
default:
d_valid = 0;
return;
}
d_valid = 1;
}
/* D holds the content pointed to by n */
void set_d_node_ptr(struct node *n)
{
memcpy(&d_node, n, sizeof(struct node));
switch(d_node.op) {
case T_NAME:
d_node.op = T_NREF;
break;
case T_LABEL:
d_node.op = T_LBREF;
break;
case T_ARGUMENT:
d_node.value += argbase + frame_len;
/* Fall through */
case T_LOCAL:
d_node.op = T_LREF;
break;
default:
d_valid = 0;
return;
}
d_valid = 1;
}
/* Do we need to check fields by type or will the default filling
be sufficient ? */
unsigned d_holds_node(struct node *n)
{
if (d_valid == 0)
return 0;
if (d_node.op != n->op)
return 0;
if (d_node.val2 != n->val2)
return 0;
if (d_node.snum != n->snum)
return 0;
if (d_node.value != n->value)
return 0;
return 1;
}
void modify_a(uint8_t val)
{
a_val = val;
d_valid = 0;
}
void modify_b(uint8_t val)
{
b_val = val;
d_valid = 0;
}