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)
{
default: assert(!"unknown"); break;
}
}
- else if (node->arg_type->form == FORM_REAL)
+ else if (node->left_type->form == FORM_REAL)
{
switch(node->code)
{
{
if (is_const)
{
- print_const(expr->arg_type, value);
+ print_const(expr->left_type, value);
}
else
{
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);
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("");
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(", ");
node->code = code;
node->mode = mode;
node->dest.symid = 0;
- node->dest.symver = 0; /* TODO: increment temp ver */
+ node->dest.symver = 0;
return node;
}
{
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;
(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;
}
(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;
}
(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;
}
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)
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)
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);
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;
/* 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)
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;
assert(!"not a left.valid form");
}
- a->arg_type = a->ret_type;
+ a->left_type = a->ret_type;
return a;
}