summaryrefslogtreecommitdiff
path: root/ir.h
diff options
context:
space:
mode:
authorWormHeamer2025-08-04 00:43:51 -0400
committerWormHeamer2025-08-04 00:43:51 -0400
commita5e5749e41de721c2e982f42f6ba27fc2b6d69c1 (patch)
treeb35b1934468b49384cb185a058e4a1098cb9379e /ir.h
parent487e48e985c6fa6762454af661f666fbe77fcdd1 (diff)
add projection nodes, fix peephole optimization
Diffstat (limited to 'ir.h')
-rw-r--r--ir.h28
1 files changed, 19 insertions, 9 deletions
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, ...);