summaryrefslogtreecommitdiffhomepage
path: root/ir/be/beasm.c
diff options
context:
space:
mode:
authorChristoph Mallon <mallon@cs.uni-saarland.de>2015-05-29 17:03:51 +0200
committerChristoph Mallon <mallon@cs.uni-saarland.de>2015-06-05 17:40:47 +0200
commit1f3c079d5e5d586556b52f8c44ad02cf12045617 (patch)
tree11fbe80b11cbaf1d144d57c6a915eb54a6557e73 /ir/be/beasm.c
parent64a748df3508ba10300669157c8eb2a8778a0faf (diff)
be: Factorise the code to count the number of asm operands.
Diffstat (limited to 'ir/be/beasm.c')
-rw-r--r--ir/be/beasm.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/ir/be/beasm.c b/ir/be/beasm.c
index 908f082..65fec31 100644
--- a/ir/be/beasm.c
+++ b/ir/be/beasm.c
@@ -150,6 +150,25 @@ void be_parse_asm_constraints_internal(be_asm_constraint_t *const constraint, id
constraint->immediate_type = immediate_type;
}
+unsigned be_count_asm_operands(ir_node const *const node)
+{
+ unsigned n_operands = 0;
+
+ ir_asm_constraint const *const out_constraints = get_ASM_output_constraints(node);
+ unsigned const n_out_constraints = get_ASM_n_output_constraints(node);
+ for (unsigned i = 0; i < n_out_constraints; ++i) {
+ n_operands = MAX(n_operands, out_constraints[i].pos + 1);
+ }
+
+ ir_asm_constraint const *const in_constraints = get_ASM_input_constraints(node);
+ unsigned const n_inputs = get_ASM_n_inputs(node);
+ for (unsigned i = 0; i < n_inputs; ++i) {
+ n_operands = MAX(n_operands, in_constraints[i].pos + 1);
+ }
+
+ return n_operands;
+}
+
static bool can_match(arch_register_req_t const *const in, arch_register_req_t const *const out)
{
if (in->cls != out->cls)