]> git.mdlowis.com Git - proto/obnc.git/commitdiff
moved TODO to dedicated file. removed offset from item type. Defined types for possib...
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 28 May 2021 16:08:18 +0000 (12:08 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 28 May 2021 16:08:18 +0000 (12:08 -0400)
cerise/TODO.md
cerise/backend/c99/codegen.c
cerise/inc/cerise.h
cerise/src/grammar.c
cerise/tests/Module.m

index a75a7b7f8ef4fe5cbef83b423e79f2322dc9bbb2..e7a684c617188558ccad2068b461b23ca76e8f38 100644 (file)
@@ -1 +1,32 @@
-* Optimize variable initialization to use constants
+# Doing
+
+* Cleanup the lexer
+
+# Up Next
+
+* Fix array access in structs
+* Implement module scoped identifiers
+* Implement an SSA backend
+* Implement pointers
+    * Ownership semantics: Ownership you can count on
+    * Concurrency: Biased reference counting
+
+# Backlog
+
+* Implement record extension
+* Implement logical operators: and, or, not
+* Implement string types
+* Implement while, for, do/repeat loops
+* Track uninitialized variables/globals
+* Nested procedure definitions
+* check that module name matches filename
+
+# Order of Operations for Implementing Memory Management
+
+* Implement new operator
+* Enforce single owner pointers
+* Implement borrowed pointers
+* Implement biased refcounting for borrowed pointers
+
+
+
index 6f00c37cca41482caae0bb67005c3c862bd63724..71378b153b402054f9ea665449b850593472e7c6 100644 (file)
@@ -149,7 +149,7 @@ static char* temp(Item* a)
     }
     else if (a->mode == ITEM_FIELD)
     {
-        snprintf(name, sizeof(name), "*((%s)(_T%d + %d))", typetoptr(a->type), a->reg, a->offset);
+        snprintf(name, sizeof(name), "*((%s)(_T%d + %lld))", typetoptr(a->type), a->reg, a->imm.i);
     }
     else
     {
@@ -184,6 +184,7 @@ static void load_var(Parser* p, Item* item)
                 {
                     printf(" = %c%s;\n", (isref ? '&' : ' '), item->imm.s);
                 }
+                item->imm.i = 0;
                 break;
 
             case ITEM_MVAR:
@@ -196,6 +197,7 @@ static void load_var(Parser* p, Item* item)
                 {
                     printf(" = %c%s_%s;\n", (isref ? '&' : ' '), p->name, item->imm.s);
                 }
+                item->imm.i = 0;
                 break;
 
             default:
@@ -495,5 +497,5 @@ void codegen_field(Parser* p, Item* record, char* name)
     Field* f = get_field(p, record->type, name);
     record->mode = ITEM_FIELD;
     record->type = f->type;
-    record->offset += f->offset;
+    record->imm.i += f->offset;
 }
index f05cf0b4326ea6e025d3ae4c6ef8c8f5c413cf2e..941562ffeec443dca49971cf31ac9630327999c6 100644 (file)
@@ -133,7 +133,6 @@ typedef struct Item {
     Symbol* sym;
     Type* type;
     int reg;
-    int offset;
     ImmValue imm;
 } Item;
 
@@ -226,6 +225,27 @@ void codegen_return(Parser* p, Item* item);
 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;
+} Operand;
+
+typedef struct {
+    int opcode;
+    Operand dest;
+    Operand arg1;
+    Operand arg2;
+} Operation;
+
+typedef struct {
+    size_t nops;
+    size_t mops;
+    Operation** ops;
+} Block;
+
 /*
 
 typedef struct AnfNode {
index b1e38d91a99d426321558e7887cdd0b8c307d2a1..e17d87327ab10801db6ecd4abde76228e674e592 100644 (file)
@@ -4,30 +4,6 @@
 #include <fcntl.h>
 #include <sys/stat.h>
 
-/* TODO
-    * Implement logical operators: and, or, not
-    * Implement module scoped identifiers
-    * Implement strings types
-    * Implement records and record access
-    * Implement while, for, do/repeat loops
-    * Track uninitialized variables/globals
-    * Implement pointers
-        * Ownership semantics: Ownership you can count on
-        * Concurrency: Biased reference counting
-    * Nested procedure definitions
-    * Implement record extension
-    * Cleanup the lexer
-*/
-
-/* Order of Operations for Implementing Memory Management
-
-    * Implement new operator
-    * Enforce single owner pointers
-    * Implement borrowed pointers
-    * Implement biased refcounting for borrowed pointers
-
-*/
-
 //#define TRACE
 #ifdef TRACE
     static int Indent = 0;
index 665c1eb754ed50601de278a48410a86d044e1d6a..4421a0f6f9f1e9544f264ea58e1c3032b69c32ea 100644 (file)
@@ -114,5 +114,5 @@ begin
 #    c = e[1][c];
 #  c = f.dim.w;
   f.dim.h = 0;
-#  f.label[0] = 42;
+  f.label[0] = 42;
 end