TCGOp *tcg_op_insert_after(TCGContext *s, TCGOp *op,
TCGOpcode, TCGType, unsigned nargs);
+/*
+ * For a binary opcode OP, return true if the second input operand allows IMM.
+ */
+bool tcg_op_imm_match(TCGOpcode op, TCGType type, tcg_target_ulong imm);
+
#endif /* TCG_INTERNAL_H */
}
}
-static const TCGArgConstraint *opcode_args_ct(const TCGOp *op)
+static const TCGArgConstraint *op_args_ct(TCGOpcode opc, TCGType type,
+ unsigned flags)
{
- TCGOpcode opc = op->opc;
- TCGType type = TCGOP_TYPE(op);
- unsigned flags = TCGOP_FLAGS(op);
const TCGOpDef *def = &tcg_op_defs[opc];
const TCGOutOp *outop = all_outop[opc];
TCGConstraintSetIndex con_set;
return all_cts[con_set];
}
+static const TCGArgConstraint *opcode_args_ct(const TCGOp *op)
+{
+ return op_args_ct(op->opc, TCGOP_TYPE(op), TCGOP_FLAGS(op));
+}
+
+bool tcg_op_imm_match(TCGOpcode opc, TCGType type, tcg_target_ulong imm)
+{
+ const TCGArgConstraint *args_ct = op_args_ct(opc, type, 0);
+ const TCGOpDef *def = &tcg_op_defs[opc];
+
+ tcg_debug_assert(def->nb_oargs == 1);
+ tcg_debug_assert(def->nb_iargs == 2);
+ return tcg_target_const_match(imm, args_ct[2].ct, type, 0, 0);
+}
+
static void remove_label_use(TCGOp *op, int idx)
{
TCGLabel *label = arg_label(op->args[idx]);