diff --git a/tools/qfcc/include/dags.h b/tools/qfcc/include/dags.h index b0104d241..e9d58047d 100644 --- a/tools/qfcc/include/dags.h +++ b/tools/qfcc/include/dags.h @@ -39,8 +39,19 @@ typedef struct daglabel_s { typedef struct dagnode_s { struct dagnode_s *next; daglabel_t *label; ///< ident/const if leaf node, or operator - struct dagnode_s *left; ///< null if leaf node - struct dagnode_s *right; ///< null if unary op + /// \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 + /// null, either \a b or \a c or even both may be non-null. Both \a b and + /// \a c being non-null is reserved for the few opcodes that take three + /// inputs (rcall2+, 3 op state, indirect move, indexed pointer assignment) + /// \a b and \a c are used to help keep track of the original statement + /// operands + //@{ + struct dagnode_s *a; + struct dagnode_s *b; + struct dagnode_s *c; + //@} daglabel_t *identifiers; ///< list of identifiers with value of this node } dagnode_t; diff --git a/tools/qfcc/source/dot_dag.c b/tools/qfcc/source/dot_dag.c index 69fd44c77..2f4355fa0 100644 --- a/tools/qfcc/source/dot_dag.c +++ b/tools/qfcc/source/dot_dag.c @@ -51,18 +51,21 @@ static void print_node (dstring_t *dstr, dagnode_t *node) { - if (!node->left && node->right) { - // broken node (right is not null) + if (!node->a && (node->b || node->c)) { dasprintf (dstr, " \"dag_%p\" [label=\"bad node\"];\n", node); return; } - if (node->left) - dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\";\n", node, node->left); - if (node->right) - dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\";\n", node, node->right); + if (node->a) + dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\" [label=a];\n", node, + node->a); + if (node->b) + dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\" [label=b];\n", node, + node->b); + if (node->c) + dasprintf (dstr, " \"dag_%p\" -> \"dag_%p\" [label=c];\n", node, + node->c); dasprintf (dstr, " \"dag_%p\" [%slabel=\"%s\"];\n", node, - node->left ? "" : "shape=none,", - daglabel_string (node->label)); + node->a ? "" : "shape=none,", daglabel_string (node->label)); if (node->identifiers) { daglabel_t *id;