mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
Fix the lost line numbers on simple assignments.
Instead of storing the generating statement in the dagnode, the generating expression is stored in the daglabel. The daglabel's expression pointer is updated each time the label is attached to a node. Now I know why debugging optimized code can be... interesting.
This commit is contained in:
parent
43d77900d5
commit
0bb2fc1891
2 changed files with 17 additions and 15 deletions
|
@ -52,6 +52,7 @@ typedef struct daglabel_s {
|
|||
const char *opcode; ///< not if op
|
||||
struct operand_s *op; ///< not if opcode;
|
||||
struct dagnode_s *dagnode; ///< node with which this label is associated
|
||||
struct expr_s *expr; ///< expression associated with this label
|
||||
} daglabel_t;
|
||||
|
||||
typedef struct dagnode_s {
|
||||
|
@ -62,7 +63,6 @@ typedef struct dagnode_s {
|
|||
st_type_t type; ///< type of node (st_node = leaf)
|
||||
daglabel_t *label; ///< ident/const if leaf node, or operator
|
||||
etype_t tl;
|
||||
struct statement_s *statement; ///< statement generating this node
|
||||
/// \name child nodes
|
||||
/// All three child nodes will be null if this node is a leaf
|
||||
/// If \a a is null, both \a b and \a c must also be null. If \a is not
|
||||
|
|
|
@ -115,12 +115,13 @@ daglabel_string (daglabel_t *label)
|
|||
}
|
||||
|
||||
static daglabel_t *
|
||||
opcode_label (const char *opcode)
|
||||
opcode_label (const char *opcode, expr_t *expr)
|
||||
{
|
||||
daglabel_t *label;
|
||||
|
||||
label = new_label ();
|
||||
label->opcode = opcode;
|
||||
label->expr = expr;
|
||||
return label;
|
||||
}
|
||||
|
||||
|
@ -169,7 +170,7 @@ operand_label (operand_t *op)
|
|||
}
|
||||
|
||||
static dagnode_t *
|
||||
leaf_node (operand_t *op)
|
||||
leaf_node (operand_t *op, expr_t *expr)
|
||||
{
|
||||
daglabel_t *label;
|
||||
dagnode_t *node;
|
||||
|
@ -180,6 +181,7 @@ leaf_node (operand_t *op)
|
|||
node->tl = op->type;
|
||||
label = operand_label (op);
|
||||
label->dagnode = node;
|
||||
label->expr = expr;
|
||||
node->label = label;
|
||||
return node;
|
||||
}
|
||||
|
@ -298,17 +300,17 @@ dag_create (const flownode_t *flownode)
|
|||
|
||||
flow_analyze_statement (s, 0, 0, 0, operands);
|
||||
if (!(ny = node (operands[1]))) {
|
||||
ny = leaf_node (operands[1]);
|
||||
ny = leaf_node (operands[1], s->expr);
|
||||
if (s->type == st_assign) {
|
||||
*dagtail = ny;
|
||||
dagtail = &ny->next;
|
||||
}
|
||||
}
|
||||
if (!(nz = node (operands[2])))
|
||||
nz = leaf_node (operands[2]);
|
||||
nz = leaf_node (operands[2], s->expr);
|
||||
if (!(nw = node (operands[3])))
|
||||
nw = leaf_node (operands[3]);
|
||||
op = opcode_label (s->opcode);
|
||||
nw = leaf_node (operands[3], s->expr);
|
||||
op = opcode_label (s->opcode, s->expr);
|
||||
if (s->type == st_assign) {
|
||||
n = ny;
|
||||
} else {
|
||||
|
@ -318,7 +320,6 @@ dag_create (const flownode_t *flownode)
|
|||
}
|
||||
if (!n) {
|
||||
n = new_node ();
|
||||
n->statement = s;
|
||||
n->type = s->type;
|
||||
n->label = op;
|
||||
n->a = ny;
|
||||
|
@ -343,6 +344,7 @@ dag_create (const flownode_t *flownode)
|
|||
if (lx) {
|
||||
if (lx->prev)
|
||||
daglabel_detatch (lx);
|
||||
lx->expr = s->expr;
|
||||
dagnode_attach_label (n, lx);
|
||||
}
|
||||
}
|
||||
|
@ -432,7 +434,7 @@ generate_assignments (sblock_t *block, operand_t *src, daglabel_t *var)
|
|||
while (dst->op_type == op_alias)
|
||||
dst = dst->o.alias;
|
||||
}
|
||||
st = build_statement ("=", src, vop, 0, 0);//FIXME expr
|
||||
st = build_statement ("=", src, vop, 0, var->expr);
|
||||
sblock_add_statement (block, st);
|
||||
var = var->next;
|
||||
}
|
||||
|
@ -461,15 +463,15 @@ dag_gencode (sblock_t *block, const dagnode_t *dagnode)
|
|||
opb = fix_op_type (dag_gencode (block, dagnode->b),
|
||||
dagnode->tb);
|
||||
if (!(var = dagnode->identifiers)) {
|
||||
opc = temp_operand (get_type (dagnode->statement->expr));
|
||||
opc = temp_operand (get_type (dagnode->label->expr));
|
||||
} else {
|
||||
opc = fix_op_type (var->op,
|
||||
extract_type (dagnode->statement->expr));
|
||||
extract_type (dagnode->label->expr));
|
||||
var = var->next;
|
||||
}
|
||||
dst = opc;
|
||||
st = build_statement (dagnode->label->opcode, opa, opb, opc,
|
||||
dagnode->statement->expr);
|
||||
dagnode->label->expr);
|
||||
sblock_add_statement (block, st);
|
||||
generate_assignments (block, opc, var);
|
||||
break;
|
||||
|
@ -482,7 +484,7 @@ dag_gencode (sblock_t *block, const dagnode_t *dagnode)
|
|||
opc = fix_op_type (dag_gencode (block, dagnode->c),
|
||||
dagnode->tc);
|
||||
st = build_statement (dagnode->label->opcode, opa, opb, opc,
|
||||
dagnode->statement->expr);
|
||||
dagnode->label->expr);
|
||||
sblock_add_statement (block, st);
|
||||
break;
|
||||
case st_move:
|
||||
|
@ -498,7 +500,7 @@ dag_gencode (sblock_t *block, const dagnode_t *dagnode)
|
|||
opc = fix_op_type (dag_gencode (block, dagnode->c),
|
||||
dagnode->tc);
|
||||
st = build_statement (dagnode->label->opcode, opa, opb, opc,
|
||||
dagnode->statement->expr);
|
||||
dagnode->label->expr);
|
||||
sblock_add_statement (block, st);
|
||||
break;
|
||||
case st_flow:
|
||||
|
@ -507,7 +509,7 @@ dag_gencode (sblock_t *block, const dagnode_t *dagnode)
|
|||
opb = fix_op_type (dag_gencode (block, dagnode->b),
|
||||
dagnode->tb);
|
||||
st = build_statement (dagnode->label->opcode, opa, opb, 0,
|
||||
dagnode->statement->expr);
|
||||
dagnode->label->expr);
|
||||
sblock_add_statement (block, st);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue