child, side);
}
-#if 0
-static
-struct ir_op *make_op_binary_numeric(enum op_type bin_op_type,
- const char *op_str, struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- struct ir_op *op = NULL;
-
- if (right->data_type == IR_DATA_STRING
- || right->data_type == IR_DATA_STRING) {
- fprintf(stderr, "[error] binary operation '%s' not allowed on string literal\n", op_str);
- goto error;
- }
- if (left->data_type == IR_DATA_UNKNOWN
- || right->data_type == IR_DATA_UNKNOWN) {
- fprintf(stderr, "[error] binary operation '%s' has unknown type for both children\n", op_str);
- goto error;
-
- }
-
- op = calloc(sizeof(struct ir_op_binary), 1);
- if (!op)
- return NULL;
- op->op = IR_OP_BINARY;
- op->u.binary.type = bin_op_type;
- op->u.binary.left = left;
- op->u.binary.right = right;
- op->side = side;
-
- /*
- * The field that is not a field ref will select type.
- */
- if (left->data_type != IR_DATA_FIELD_REF
- && left->data_type != IR_DATA_GET_CONTEXT_REF)
- op->data_type = left->data_type;
- else
- op->data_type = right->data_type;
-
- if (left->signedness == IR_SIGNED
- || right->signedness == IR_SIGNED) {
- op->signedness = IR_SIGNED;
- } else if (left->signedness == IR_SIGN_DYN
- || right->signedness == IR_SIGN_DYN) {
- op->signedness = IR_SIGN_DYN;
- } else if (left->signedness == IR_UNSIGNED
- && right->signedness == IR_UNSIGNED) {
- op->signedness = IR_UNSIGNED;
- } else {
- op->signedness = IR_SIGN_UNKNOWN;
- }
-
- return op;
-
-error:
- free(op);
- return NULL;
-}
-
-static
-struct ir_op *make_op_binary_mul(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_MUL, "*", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_div(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_DIV, "/", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_mod(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_MOD, "%", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_plus(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_PLUS, "+", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_minus(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_MINUS, "-", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_rshift(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_RSHIFT, ">>", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_lshift(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_LSHIFT, "<<", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_and(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_BIN_AND, "&", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_or(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_BIN_OR, "|", left, right, side);
-}
-
-static
-struct ir_op *make_op_binary_xor(struct ir_op *left, struct ir_op *right,
- enum ir_side side)
-{
- return make_op_binary_numeric(AST_OP_BIN_XOR, "^", left, right, side);
-}
-#endif //0
-
static
struct ir_op *make_op_binary_compare(enum op_type bin_op_type,
const char *op_str, struct ir_op *left, struct ir_op *right,