summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChristoph Mallon <christoph.mallon@gmx.de>2018-04-17 08:22:06 +0200
committerChristoph Mallon <christoph.mallon@gmx.de>2018-05-11 09:21:09 +0200
commite41782b3a72bb6bb68630be6e732a169e537217d (patch)
tree38c07f462381ac583a5c3e4e453ed6f8489bb9b7
parentcfb40030a2a17147a7674df814425a42d4b1bcbd (diff)
Simplify collection of output constraints when building IR for an asm statement.
-rw-r--r--src/firm/ast2firm.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/firm/ast2firm.c b/src/firm/ast2firm.c
index 6248c6b..534f1fc 100644
--- a/src/firm/ast2firm.c
+++ b/src/firm/ast2firm.c
@@ -4568,8 +4568,9 @@ static ir_node *asm_statement_to_firm(const asm_statement_t *statement)
unsigned next_pos = 0;
- ir_node **ins = NEW_ARR_F(ir_node*, 0);
- ir_asm_constraint *in_constraints = NEW_ARR_F(ir_asm_constraint, 0);
+ ir_node **ins = NEW_ARR_F(ir_node*, 0);
+ ir_asm_constraint *in_constraints = NEW_ARR_F(ir_asm_constraint, 0);
+ ir_asm_constraint *out_constraints = NEW_ARR_F(ir_asm_constraint, 0);
const expression_t *out_exprs[n_outputs];
ir_node *out_addrs[n_outputs];
@@ -4607,8 +4608,7 @@ static ir_node *asm_statement_to_firm(const asm_statement_t *statement)
constraint.pos = pos;
constraint.constraint = constraints;
constraint.mode = get_ir_mode_storage(expr->base.type);
-
- obstack_grow(&asm_obst, &constraint, sizeof(constraint));
+ ARR_APP1(ir_asm_constraint, out_constraints, constraint);
} else {
/* the only case where an argument doesn't "write" is when it is
* a memor operand (so we really write to the pointed memory instead
@@ -4627,9 +4627,6 @@ static ir_node *asm_statement_to_firm(const asm_statement_t *statement)
ARR_APP1(ir_asm_constraint, in_constraints, constraint);
}
}
- assert(obstack_object_size(&asm_obst)
- == out_size * sizeof(ir_asm_constraint));
- ir_asm_constraint *output_constraints = obstack_finish(&asm_obst);
for (const entity_t *entity = statement->inputs; entity != NULL;
entity = entity->base.next) {
@@ -4657,11 +4654,13 @@ static ir_node *asm_statement_to_firm(const asm_statement_t *statement)
size_t const n_ins = ARR_LEN(ins);
assert(ARR_LEN(in_constraints) == n_ins);
+ assert(ARR_LEN(out_constraints) == out_size);
+
/* create asm node */
dbg_info *dbgi = get_dbg_info(&statement->base.pos);
ident *asm_text = new_id_from_str(statement->normalized_text->begin);
ir_node *node = new_d_ASM(dbgi, mem, n_ins, ins, in_constraints,
- out_size, output_constraints,
+ out_size, out_constraints,
n_clobbers, clobbers, asm_text);
if (statement->is_volatile) {
@@ -4685,6 +4684,7 @@ static ir_node *asm_statement_to_firm(const asm_statement_t *statement)
set_value_for_expression_addr(out_expr, proj, addr);
}
+ DEL_ARR_F(out_constraints);
DEL_ARR_F(in_constraints);
DEL_ARR_F(ins);