"field",
"function",
"pointer",
-#if 0
"integer",
-#endif
- "variant"
+ "variant",
+ "struct",
+ "union",
+ "array"
};
size_t type_sizeof[TYPE_COUNT] = {
1, /* TYPE_FIELD */
1, /* TYPE_FUNCTION */
1, /* TYPE_POINTER */
-#if 0
1, /* TYPE_INTEGER */
-#endif
3, /* TYPE_VARIANT */
+ 0, /* TYPE_STRUCT */
+ 0, /* TYPE_UNION */
+ 0, /* TYPE_ARRAY */
};
uint16_t type_store_instr[TYPE_COUNT] = {
INSTR_STORE_ENT, /* should use I */
#if 0
INSTR_STORE_I, /* integer type */
+#else
+ INSTR_STORE_F,
#endif
INSTR_STORE_V, /* variant, should never be accessed */
+
+ AINSTR_END, /* struct */
+ AINSTR_END, /* union */
+ AINSTR_END, /* array */
+};
+
+uint16_t field_store_instr[TYPE_COUNT] = {
+ INSTR_STORE_FLD,
+ INSTR_STORE_FLD,
+ INSTR_STORE_FLD,
+ INSTR_STORE_V,
+ INSTR_STORE_FLD,
+ INSTR_STORE_FLD,
+ INSTR_STORE_FLD,
+ INSTR_STORE_FLD,
+#if 0
+ INSTR_STORE_FLD, /* integer type */
+#else
+ INSTR_STORE_FLD,
+#endif
+
+ INSTR_STORE_V, /* variant, should never be accessed */
+
+ AINSTR_END, /* struct */
+ AINSTR_END, /* union */
+ AINSTR_END, /* array */
};
uint16_t type_storep_instr[TYPE_COUNT] = {
INSTR_STOREP_ENT, /* should use I */
#if 0
INSTR_STOREP_ENT, /* integer type */
+#else
+ INSTR_STOREP_F,
#endif
INSTR_STOREP_V, /* variant, should never be accessed */
+
+ AINSTR_END, /* struct */
+ AINSTR_END, /* union */
+ AINSTR_END, /* array */
};
uint16_t type_eq_instr[TYPE_COUNT] = {
INSTR_EQ_E, /* should use I */
#if 0
INSTR_EQ_I,
+#else
+ INSTR_EQ_F,
#endif
INSTR_EQ_V, /* variant, should never be accessed */
+
+ AINSTR_END, /* struct */
+ AINSTR_END, /* union */
+ AINSTR_END, /* array */
};
uint16_t type_ne_instr[TYPE_COUNT] = {
INSTR_NE_E, /* should use I */
#if 0
INSTR_NE_I,
+#else
+ INSTR_NE_F,
#endif
INSTR_NE_V, /* variant, should never be accessed */
+
+ AINSTR_END, /* struct */
+ AINSTR_END, /* union */
+ AINSTR_END, /* array */
};
MEM_VEC_FUNCTIONS(ir_value_vector, ir_value*, v)
case TYPE_INTEGER: op = INSTR_LOAD_I; break;
#endif
default:
+ irerror(self->context, "invalid type for ir_block_create_load_from_ent: %s", type_name[outype]);
return NULL;
}
if (l == r) {
switch (l) {
default:
+ irerror(self->context, "invalid type for ir_block_create_add: %s", type_name[l]);
return NULL;
case TYPE_FLOAT:
op = INSTR_ADD_F;
op = INSTR_ADD_IF;
else
#endif
+ {
+ irerror(self->context, "invalid type for ir_block_create_add: %s", type_name[l]);
return NULL;
+ }
}
return ir_block_create_binop(self, label, op, left, right);
}
switch (l) {
default:
+ irerror(self->context, "invalid type for ir_block_create_sub: %s", type_name[l]);
return NULL;
case TYPE_FLOAT:
op = INSTR_SUB_F;
op = INSTR_SUB_IF;
else
#endif
+ {
+ irerror(self->context, "invalid type for ir_block_create_sub: %s", type_name[l]);
return NULL;
+ }
}
return ir_block_create_binop(self, label, op, left, right);
}
switch (l) {
default:
+ irerror(self->context, "invalid type for ir_block_create_mul: %s", type_name[l]);
return NULL;
case TYPE_FLOAT:
op = INSTR_MUL_F;
else if ( (l == TYPE_INTEGER && r == TYPE_FLOAT) )
op = INSTR_MUL_IF;
#endif
- else
+ else {
+ irerror(self->context, "invalid type for ir_block_create_mul: %s", type_name[l]);
return NULL;
+ }
}
return ir_block_create_binop(self, label, op, left, right);
}
switch (l) {
default:
+ irerror(self->context, "invalid type for ir_block_create_div: %s", type_name[l]);
return NULL;
case TYPE_FLOAT:
op = INSTR_DIV_F;
op = INSTR_DIV_IF;
else
#endif
+ {
+ irerror(self->context, "invalid type for ir_block_create_div: %s", type_name[l]);
return NULL;
+ }
}
return ir_block_create_binop(self, label, op, left, right);
}
stmt.opcode = INSTR_STORE_F;
stmt.o3.u1 = 0;
- stmt.opcode = type_store_instr[param->vtype];
+ if (param->vtype == TYPE_FIELD)
+ stmt.opcode = field_store_instr[param->fieldtype];
+ else
+ stmt.opcode = type_store_instr[param->vtype];
stmt.o1.u1 = ir_value_code_addr(param);
stmt.o2.u1 = OFS_PARM0 + 3 * p;
if (code_statements_add(stmt) < 0)
if (retvalue && retvalue->store != store_return && retvalue->life_count)
{
/* not to be kept in OFS_RETURN */
- stmt.opcode = type_store_instr[retvalue->vtype];
+ if (retvalue->vtype == TYPE_FIELD)
+ stmt.opcode = field_store_instr[retvalue->vtype];
+ else
+ stmt.opcode = type_store_instr[retvalue->vtype];
stmt.o1.u1 = OFS_RETURN;
stmt.o2.u1 = ir_value_code_addr(retvalue);
stmt.o3.u1 = 0;