From a5e5749e41de721c2e982f42f6ba27fc2b6d69c1 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Mon, 4 Aug 2025 00:43:51 -0400 Subject: add projection nodes, fix peephole optimization --- ir.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'ir.h') diff --git a/ir.h b/ir.h index 432c96c..0a8a9c2 100644 --- a/ir.h +++ b/ir.h @@ -15,19 +15,33 @@ typedef enum { } TypeLevel; typedef enum { + T_NONE, T_TUPLE, T_BOOL, T_INT } BaseType; typedef struct Type { - BaseType t; TypeLevel lvl; + BaseType t; struct Type *next; } Type; +typedef struct Value { + Type type; + union { + int64_t i; + uint64_t u; + DYNARR(struct Value) tuple; + }; +} Value; + +struct Node; int type_eql(Type *a, Type *b); int type_base_eql(Type *a, Type *b); +int type_check(struct Node *n); +Str type_desc(Type *t, Arena *arena); +void type_err(struct Node *n, Lexer *l); /* nodes */ @@ -47,14 +61,6 @@ typedef enum { const char *node_type_name(NodeType t); -typedef struct { - Type type; - union { - int64_t i; - uint64_t u; - }; -} Value; - typedef struct Node { union { struct Node *prev_free; @@ -101,7 +107,11 @@ void node_die(Node *n, Proc *p); void node_del_out(Node *n, Node *p); void node_del_in(Node *n, Node *p); void node_kill(Node *n, Proc *p); + void node_add(Proc *p, Node *src, Node *dest); +void node_add_out(Proc *p, Node *a, Node *b); +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, ...); -- cgit v1.2.3