mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-13 08:27:39 +00:00
Handle attached identifier labels correctly.
I'd forgotten I had the prev field. Makes for much cleaner code.
This commit is contained in:
parent
0cedf0d13a
commit
0ccf4093e4
2 changed files with 27 additions and 14 deletions
|
@ -36,8 +36,11 @@
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
typedef struct daglabel_s {
|
typedef struct daglabel_s {
|
||||||
|
/// \name attached identifer linked list
|
||||||
|
//@{
|
||||||
struct daglabel_s *next;
|
struct daglabel_s *next;
|
||||||
struct daglabel_s **prev;
|
struct daglabel_s **prev;
|
||||||
|
//@}
|
||||||
const char *opcode; ///< not if op
|
const char *opcode; ///< not if op
|
||||||
struct operand_s *op; ///< not if opcode;
|
struct operand_s *op; ///< not if opcode;
|
||||||
struct dagnode_s *dagnode; ///< node with which this label is associated
|
struct dagnode_s *dagnode; ///< node with which this label is associated
|
||||||
|
|
|
@ -221,6 +221,26 @@ dagnode_match (const dagnode_t *n, const daglabel_t *op,
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dagnode_attach_label (dagnode_t *n, daglabel_t *l)
|
||||||
|
{
|
||||||
|
if (n->identifiers)
|
||||||
|
n->identifiers->prev = &l->next;
|
||||||
|
l->next = n->identifiers;
|
||||||
|
l->prev = &n->identifiers;
|
||||||
|
l->dagnode = n;
|
||||||
|
n->identifiers = l;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
daglabel_detatch (daglabel_t *l)
|
||||||
|
{
|
||||||
|
if (l->next)
|
||||||
|
l->next->prev = l->prev;
|
||||||
|
*l->prev = l->next;
|
||||||
|
l->dagnode = 0;
|
||||||
|
}
|
||||||
|
|
||||||
dagnode_t *
|
dagnode_t *
|
||||||
make_dag (const sblock_t *block)
|
make_dag (const sblock_t *block)
|
||||||
{
|
{
|
||||||
|
@ -230,7 +250,7 @@ make_dag (const sblock_t *block)
|
||||||
|
|
||||||
for (s = block->statements; s; s = s->next) {
|
for (s = block->statements; s; s = s->next) {
|
||||||
operand_t *x = 0, *y = 0, *z = 0, *w = 0;
|
operand_t *x = 0, *y = 0, *z = 0, *w = 0;
|
||||||
dagnode_t *n = 0, *nx, *ny, *nz, *nw;
|
dagnode_t *n = 0, *ny, *nz, *nw;
|
||||||
daglabel_t *op, *lx;
|
daglabel_t *op, *lx;
|
||||||
int simp;
|
int simp;
|
||||||
|
|
||||||
|
@ -259,20 +279,10 @@ make_dag (const sblock_t *block)
|
||||||
dagnodes = n;
|
dagnodes = n;
|
||||||
}
|
}
|
||||||
lx = operand_label (x);
|
lx = operand_label (x);
|
||||||
if ((nx = node (x))) {
|
|
||||||
daglabel_t **l;
|
|
||||||
for (l = &nx->identifiers; *l; l = &(*l)->next) {
|
|
||||||
if (*l == lx) {
|
|
||||||
*l = (*l)->next;
|
|
||||||
lx->next = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lx) {
|
if (lx) {
|
||||||
lx->next = n->identifiers;
|
if (lx->prev)
|
||||||
n->identifiers = lx;
|
daglabel_detatch (lx);
|
||||||
lx->dagnode = n;
|
dagnode_attach_label (n, lx);
|
||||||
}
|
}
|
||||||
dag = n;
|
dag = n;
|
||||||
// c = a * b
|
// c = a * b
|
||||||
|
|
Loading…
Reference in a new issue