if (!in)
return false;
- if (!ir_instr_op(in, 0, target, true) ||
+ if (!ir_instr_op(in, 0, target, (op < INSTR_STOREP_F || op > INSTR_STOREP_FNC)) ||
!ir_instr_op(in, 1, what, false))
{
ir_instr_delete(in);
return ir_block_create_general_instr(self, ctx, label, op, ent, field, outype);
}
-ir_value* ir_block_create_add(ir_block *self, lex_ctx ctx,
- const char *label,
- ir_value *left, ir_value *right)
-{
- int op = 0;
- int l = left->vtype;
- int r = right->vtype;
- 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;
- break;
-#if 0
- case TYPE_INTEGER:
- op = INSTR_ADD_I;
- break;
-#endif
- case TYPE_VECTOR:
- op = INSTR_ADD_V;
- break;
- }
- } else {
-#if 0
- if ( (l == TYPE_FLOAT && r == TYPE_INTEGER) )
- op = INSTR_ADD_FI;
- else if ( (l == TYPE_INTEGER && r == TYPE_FLOAT) )
- 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, ctx, label, op, left, right);
-}
-
-ir_value* ir_block_create_sub(ir_block *self, lex_ctx ctx,
- const char *label,
- ir_value *left, ir_value *right)
-{
- int op = 0;
- int l = left->vtype;
- int r = right->vtype;
- if (l == r) {
-
- 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;
- break;
-#if 0
- case TYPE_INTEGER:
- op = INSTR_SUB_I;
- break;
-#endif
- case TYPE_VECTOR:
- op = INSTR_SUB_V;
- break;
- }
- } else {
-#if 0
- if ( (l == TYPE_FLOAT && r == TYPE_INTEGER) )
- op = INSTR_SUB_FI;
- else if ( (l == TYPE_INTEGER && r == TYPE_FLOAT) )
- 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, ctx, label, op, left, right);
-}
-
-ir_value* ir_block_create_mul(ir_block *self, lex_ctx ctx,
- const char *label,
- ir_value *left, ir_value *right)
-{
- int op = 0;
- int l = left->vtype;
- int r = right->vtype;
- if (l == r) {
-
- 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;
- break;
-#if 0
- case TYPE_INTEGER:
- op = INSTR_MUL_I;
- break;
-#endif
- case TYPE_VECTOR:
- op = INSTR_MUL_V;
- break;
- }
- } else {
- if ( (l == TYPE_VECTOR && r == TYPE_FLOAT) )
- op = INSTR_MUL_VF;
- else if ( (l == TYPE_FLOAT && r == TYPE_VECTOR) )
- op = INSTR_MUL_FV;
-#if 0
- else if ( (l == TYPE_VECTOR && r == TYPE_INTEGER) )
- op = INSTR_MUL_VI;
- else if ( (l == TYPE_INTEGER && r == TYPE_VECTOR) )
- op = INSTR_MUL_IV;
- else if ( (l == TYPE_FLOAT && r == TYPE_INTEGER) )
- op = INSTR_MUL_FI;
- else if ( (l == TYPE_INTEGER && r == TYPE_FLOAT) )
- op = INSTR_MUL_IF;
-#endif
- else {
- irerror(self->context, "invalid type for ir_block_create_mul: %s", type_name[l]);
- return NULL;
- }
- }
- return ir_block_create_binop(self, ctx, label, op, left, right);
-}
-
-ir_value* ir_block_create_div(ir_block *self, lex_ctx ctx,
- const char *label,
- ir_value *left, ir_value *right)
-{
- int op = 0;
- int l = left->vtype;
- int r = right->vtype;
- if (l == r) {
-
- 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;
- break;
-#if 0
- case TYPE_INTEGER:
- op = INSTR_DIV_I;
- break;
-#endif
- }
- } else {
-#if 0
- if ( (l == TYPE_VECTOR && r == TYPE_FLOAT) )
- op = INSTR_DIV_VF;
- else if ( (l == TYPE_FLOAT && r == TYPE_INTEGER) )
- op = INSTR_DIV_FI;
- else if ( (l == TYPE_INTEGER && r == TYPE_FLOAT) )
- 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, ctx, label, op, left, right);
-}
-
/* PHI resolving breaks the SSA, and must thus be the last
* step before life-range calculation.
*/
ir_value* ir_block_create_general_instr(ir_block *self, lex_ctx, const char *label,
int op, ir_value *a, ir_value *b, int outype);
-ir_value* ir_block_create_add(ir_block*, lex_ctx, const char *label, ir_value *l, ir_value *r);
-ir_value* ir_block_create_sub(ir_block*, lex_ctx, const char *label, ir_value *l, ir_value *r);
-ir_value* ir_block_create_mul(ir_block*, lex_ctx, const char *label, ir_value *l, ir_value *r);
-ir_value* ir_block_create_div(ir_block*, lex_ctx, const char *label, ir_value *l, ir_value *r);
ir_instr* ir_block_create_phi(ir_block*, lex_ctx, const char *label, int vtype);
ir_value* ir_phi_value(ir_instr*);
void ir_phi_add(ir_instr*, ir_block *b, ir_value *v);