mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-31 05:00:35 +00:00
Change dags from binary to trinary.
I'd forgotten some instructions take three inputs that can benefit from CSE.
This commit is contained in:
parent
0fefeb73fe
commit
60108c688c
2 changed files with 24 additions and 10 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue