From 739b4852d2a826ba2985c7db2f5c778050f72250 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Thu, 7 Aug 2025 02:47:23 -0400 Subject: preliminary peephole optimization of if statements --- ir.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'ir.h') 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 -- cgit v1.2.3