]> git.mdlowis.com Git - proto/obnc.git/commitdiff
checkpoint commit
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 26 Jul 2021 04:06:47 +0000 (00:06 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 26 Jul 2021 04:06:47 +0000 (00:06 -0400)
cerise/inc/cerise.h
cerise/src/grammar.c
cerise/src/ssa.c

index 2dc7dc9a3197c246f4ad287cbe0c445111e07a64..866d5836e4081600310f5c15f30f617f5ad9dd8f 100644 (file)
@@ -163,7 +163,7 @@ typedef struct {
     char* name;
     long curr_reg;
     size_t scope;
-
+    size_t blockid;
     SsaBlock* curr_block;
     SsaBlock* curr_join;
 
@@ -242,7 +242,7 @@ SsaNode* ssa_store(Parser* p, SsaNode* dest, SsaNode* value);
 SsaNode* ssa_fieldref(Parser* p, SsaNode* record, char* fname);
 SsaNode* ssa_index(Parser* p, SsaNode* array, SsaNode* index);
 
-SsaBlock* ssa_block(void);
+SsaBlock* ssa_block(Parser* p);
 void ssa_block_add(SsaBlock* blk, SsaNode* stmt);
 
 SsaNode* ssa_if(SsaNode* cond, SsaBlock* br1, SsaBlock* br2);
index 10d08393453ca2eddd461140fe0ee6f97305517f..f2dbed1c6d9c6038f429142819f2da98f188f0ed 100644 (file)
@@ -395,7 +395,7 @@ static Type* type(Parser* p)
 static SsaBlock* statement_seq(Parser* p)
 {
     ENTER_RULE();
-    p->curr_block = ssa_block();
+    p->curr_block = ssa_block(p);
 
     do
     {
@@ -531,7 +531,7 @@ void proc_decl(Parser* p)
     /* parse the private declarations */
     if (accept(p, CONST))
     {
-        p->curr_block = ssa_block();
+        p->curr_block = ssa_block(p);
         const_decl(p);
     }
 
index 0612aed9a3f1dcb37c2b97927304331c115d19f3..9daf689cdf413ba35498c1706e6956260c316421 100644 (file)
@@ -125,9 +125,11 @@ SsaNode* ssa_index(Parser* p, SsaNode* array, SsaNode* index)
     return NULL;
 }
 
-SsaBlock* ssa_block(void)
+SsaBlock* ssa_block(Parser* p)
 {
-    return calloc(1, sizeof(SsaBlock));
+    SsaBlock* block = calloc(1, sizeof(SsaBlock));
+    block->id = p->blockid++;
+    return block;
 }
 
 void ssa_block_add(SsaBlock* blk, SsaNode* node)