summaryrefslogtreecommitdiff
path: root/ir.h
diff options
context:
space:
mode:
authorWormHeamer2025-08-07 02:47:23 -0400
committerWormHeamer2025-08-07 02:47:23 -0400
commit739b4852d2a826ba2985c7db2f5c778050f72250 (patch)
treefec019eb1aac70ee23b6a16d61e4976780c353fe /ir.h
parent6040eafed3e94efdea6f71b7018e978024193572 (diff)
preliminary peephole optimization of if statements
Diffstat (limited to 'ir.h')
-rw-r--r--ir.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/ir.h b/ir.h
index ff75163..c7fa118 100644
--- a/ir.h
+++ b/ir.h
@@ -12,7 +12,8 @@ typedef enum {
T_TOP, /* may or may not be a constant */
T_CONST, /* known compile-time constant */
T_BOT, /* known not a constant */
- T_CTRL /* bottom of control flow */
+ T_CTRL, /* control flow bottom */
+ T_XCTRL, /* control flow top (dead) */
} TypeLevel;
typedef enum {
@@ -75,7 +76,7 @@ typedef struct Node {
int walked;
NodeType type;
LexSpan src_pos;
- NodeInputs in;
+ NodeInputs in; /* note: index 0 used for control flow */
NodeOutputs out;
Value val;
};
@@ -133,7 +134,7 @@ void node_add_in(Proc *p, Node *a, Node *b);
void node_remove(Proc *p, Node *src, Node *dest);
Node *node_new_empty(Proc *p, NodeType t);
-Node *node_newv(Proc *p, NodeType t, ...);
+Node *node_newv(Proc *p, NodeType t, Node *ctrl, ...);
Node *node_dedup_lit(Proc *p, Value v);
Value node_compute(Node *n, Lexer *l);
Node *node_peephole(Node *n, Proc *p, Lexer *l);
@@ -153,5 +154,6 @@ NameBinding *scope_find(Scope *scope, Str name);
NameBinding *scope_bind(Scope *scope, Str name, Node *value, LexSpan pos, Proc *proc);
NameBinding *scope_update(Scope *scope, Str name, Node *to, Proc *proc);
void scope_collect(Scope *scope, Proc *proc, ScopeNameList *nl, Arena *arena);
+void scope_uncollect(Scope *scope, Proc *proc, ScopeNameList *nl);
#endif