]> git.mdlowis.com Git - proto/obnc.git/commitdiff
started sketching API for intermediate language implementation
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 7 Jun 2021 20:44:27 +0000 (16:44 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 7 Jun 2021 20:44:27 +0000 (16:44 -0400)
cerise/inc/cerise.h

index 4dc00c1d6a2b498b4c726164130b749e4b96d869..f159d7efcb4076a1be6606483a3ce7f5478e4c9d 100644 (file)
@@ -231,18 +231,22 @@ void codegen_index(Parser* p, Item* array, Item* index);
 void codegen_field(Parser* p, Item* record, char* name);
 
 typedef union {
-    struct {
-        char* name;
-        long version;
-    } var;
-    ImmValue imm;
+    long i;
+    double f;
+    char* s;
 } Operand;
 
 typedef struct {
-    int opcode;
-    Operand dest;
-    Operand arg1;
-    Operand arg2;
+    int code : 28;
+    int type : 4;
+    union {
+        Operand args[3];
+        struct {
+            size_t nargs;
+            size_t margs;
+            long* args;
+        } call;
+    }
 } Operation;
 
 typedef struct {
@@ -251,6 +255,14 @@ typedef struct {
     Operation** ops;
 } Block;
 
+long ir_startblock(Parser* p);
+void ir_endblock(Parser* p);
+void ir_rawop(Parser* p, Operation* op);
+void ir_binopi(Parser* p, int op, long dest, long arg, long imm);
+void ir_binopf(Parser* p, int op, long dest, long arg, double imm);
+void ir_unnopi(Parser* p, int op, long dest, long imm);
+void ir_unopf(Parser* p, int op, long dest, double imm);
+
 /* <op> <reg>, <base>+<off> */
 /* <op> <base>+<off>, <reg> */
 /* <op> <reg>, <reg> */