]> git.mdlowis.com Git - proto/obnc.git/commitdiff
renamed type field
authorMichael D. Lowis <mike@mdlowis.com>
Tue, 20 Sep 2022 16:23:53 +0000 (12:23 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Tue, 20 Sep 2022 16:23:53 +0000 (12:23 -0400)
cerise/backend/ssa/codegen.c
cerise/inc/cerise.h
cerise/src/ssa.c

index 508f5316afe5ed4c9d8c99fa65b71f0fad2a4f1b..7173caad7464d22ee79e9035efd61f75101902f3 100644 (file)
@@ -199,7 +199,7 @@ static void print_const(Type* type, SsaValue* val)
 char* binop_name(SsaNode* node)
 {
     char* name = NULL;
-    if (node->arg_type->form == FORM_INT)
+    if (node->left_type->form == FORM_INT)
     {
         switch(node->code)
         {
@@ -219,7 +219,7 @@ char* binop_name(SsaNode* node)
             default:   assert(!"unknown"); break;
         }
     }
-    else if (node->arg_type->form == FORM_REAL)
+    else if (node->left_type->form == FORM_REAL)
     {
         switch(node->code)
         {
@@ -252,7 +252,7 @@ void print_operand(Parser* p, SsaNode* expr, int is_const, SsaValue* value)
 {
     if (is_const)
     {
-        print_const(expr->arg_type, value);
+        print_const(expr->left_type, value);
     }
     else
     {
@@ -288,7 +288,7 @@ void print_op(Parser* p, SsaNode* expr)
             else if (expr->code == STORE)
             {
                 printf("    store ");
-                emit_type(expr->arg_type);
+                emit_type(expr->left_type);
                 print_operand(p, expr, expr->lconst, &(expr->left));
                 printf(", ");
                 emit_type(expr->ret_type);
@@ -301,15 +301,15 @@ void print_op(Parser* p, SsaNode* expr)
                 printf("    ");
                 print_ident(p, &(expr->dest));
                 printf(" = getelementptr ");
-                emit_type(expr->arg_type);
+                emit_type(expr->left_type);
                 printf(", ");
-                emit_type(expr->arg_type);
+                emit_type(expr->left_type);
                 printf("* ");
                 print_ident(p, &(expr->left.var));
                 printf(", ");
-                emit_type(expr->arg_type->base);
+                emit_type(expr->left_type->base);
                 printf(" 0, ");
-                emit_type(expr->arg_type->base);
+                emit_type(expr->left_type->base);
                 printf(" ");
                 print_operand(p, expr, expr->rconst, &(expr->right));
                 puts("");
@@ -365,7 +365,7 @@ void print_op(Parser* p, SsaNode* expr)
             printf("    ");
             print_ident(p, &(expr->dest));
             printf(" = %s ", binop_name(expr));
-            emit_type(expr->arg_type);
+            emit_type(expr->left_type);
             printf(" ");
             print_operand(p, expr, expr->lconst, &(expr->left));
             printf(", ");
index 41354c6bd632dc533a8fdc4e1c840d2237975cc7..61353dbd79b60aafab4a12f177369bb3fd28e17b 100644 (file)
@@ -135,7 +135,8 @@ typedef struct SsaNode {
     unsigned int lconst : 1;
     unsigned int rconst : 1;
     Type* ret_type;
-    Type* arg_type;
+    Type* left_type;
+    Type* right_type;
     SsaVar dest;
     SsaValue left;
     SsaValue right;
index 87b68f4543a9acc085cf691216142ae1bc4a57fb..13689b812720b1ebece0bcef9c6b3e489c5b6e0a 100644 (file)
@@ -119,7 +119,7 @@ static SsaNode* ssa_node(int code, int mode)
     node->code = code;
     node->mode = mode;
     node->dest.symid = 0;
-    node->dest.symver = 0; /* TODO: increment temp ver */
+    node->dest.symver = 0;
     return node;
 }
 
@@ -137,7 +137,8 @@ SsaNode* ssa_ident(Parser* p, long long index)
     {
         node = ssa_node(IDENT, MODE_VAR);
         node->ret_type = sym->type;
-        node->arg_type = sym->type;
+        node->left_type = sym->type;
+        node->right_type = sym->type;
         node->loaded = !sym->global;
         node->dest.symid = index;
         node->dest.symver = sym->version;
@@ -152,7 +153,7 @@ SsaNode* ssa_bool(Parser* p, bool val)
     (void)p;
     SsaNode* node = ssa_node(BOOL, MODE_CONST);
     node->ret_type = &BoolType;
-    node->arg_type = &BoolType;
+    node->left_type = &BoolType;
     node->left.val.i = val;
     return node;
 }
@@ -162,7 +163,7 @@ SsaNode* ssa_int(Parser* p, long long val)
     (void)p;
     SsaNode* node = ssa_node(INT, MODE_CONST);
     node->ret_type = &IntType;
-    node->arg_type = &IntType;
+    node->left_type = &IntType;
     node->left.val.i = val;
     return node;
 }
@@ -172,7 +173,7 @@ SsaNode* ssa_real(Parser* p, double val)
     (void)p;
     SsaNode* node = ssa_node(REAL, MODE_CONST);
     node->ret_type = &RealType;
-    node->arg_type = &RealType;
+    node->left_type = &RealType;
     node->left.val.f = val;
     return node;
 }
@@ -189,7 +190,7 @@ SsaNode* ssa_store(Parser* p, SsaNode* dest, SsaNode* value)
     load(p, value);
     SsaNode* node = ssa_node(STORE, MODE_MEMORY);
     node->ret_type = dest->ret_type;
-    node->arg_type = dest->ret_type;
+    node->left_type = dest->ret_type;
     node->dest = dest->left.var;
 
     if (value->mode == MODE_CONST)
@@ -224,7 +225,7 @@ SsaNode* ssa_index(Parser* p, SsaNode* array, SsaNode* index)
     load(p, index);
     SsaNode* node = ssa_node('[', MODE_MEMORY);
     node->ret_type = array->ret_type->base;
-    node->arg_type = array->ret_type;
+    node->left_type = array->ret_type;
     node->left = array->left;
 
 //    if (index->mode == MODE_CONST)
@@ -266,7 +267,7 @@ SsaNode* ssa_if(Parser* p, SsaNode* cond, SsaBlock* br1, SsaBlock* br2)
     cond = load(p, cond);
     SsaNode* node = ssa_node(IF, MODE_CTRL);
     node->ret_type = &VoidType;
-    node->arg_type = &BoolType;
+    node->left_type = &BoolType;
     node->left.block = br1;
     node->right.block = br2;
     node = load(p, node);
@@ -289,14 +290,14 @@ SsaNode* ssa_return(Parser* p, SsaNode* expr)
             load(p, expr);
         }
         node->ret_type = expr->ret_type;
-        node->arg_type = expr->ret_type;
+        node->left_type = expr->ret_type;
         node = load(p, node);
         node->dest = expr->dest;
     }
     else
     {
         node->ret_type = &VoidType;
-        node->arg_type = &VoidType;
+        node->left_type = &VoidType;
         node = load(p, node);
     }
     return node;
@@ -348,7 +349,7 @@ static SsaNode* binop(Parser* p, int op, SsaNode* left, SsaNode* right)
 
         /* set the result type appropriately */
         node->ret_type = left->ret_type;
-        node->arg_type = left->ret_type;
+        node->left_type = left->ret_type;
 
         /* comparison ops are handled specially */
         switch (op)
@@ -378,7 +379,7 @@ static SsaNode* unop(Parser* p, int op, SsaNode* operand)
         operand = load(p, operand);
         node = ssa_node(op, MODE_UNOP);
         node->ret_type = operand->ret_type;
-        node->arg_type = operand->ret_type;
+        node->left_type = operand->ret_type;
         node->left.var = operand->dest;
     }
     return node;
@@ -483,7 +484,7 @@ static SsaNode* const_binop(int op, SsaNode* a, SsaNode* b)
         assert(!"not a left.valid form");
     }
 
-    a->arg_type = a->ret_type;
+    a->left_type = a->ret_type;
     return a;
 }