diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-01-24 23:45:26 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-09-27 02:17:34 +0200 |
commit | 4bee9b6dcb6dfcc2799d29ff7e5d42c6637b1f4d (patch) | |
tree | 52b307ab84ffdfd5c99aace305b0927c073aaa93 | |
parent | 46471e07907092f13f389869f617078285f61ae0 (diff) | |
download | sparse-4bee9b6dcb6dfcc2799d29ff7e5d42c6637b1f4d.tar.gz |
asm: use parse_asm_constraint() to verify constraints
In extended ASM statements, output constraints need to be
prefixed with "=" or "+" and input constraints must not. This
is checked in verify_{output,input}_constraint() where the
constraint string is analyzed to look after these two chars.
However, the needed information is now already available thanks
to parse_asm_constraint().
So, use the result of the parsing of the constraint strings to
avoid to analyze again these strings during their verification.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | evaluate.c | 35 |
1 files changed, 15 insertions, 20 deletions
@@ -3561,24 +3561,22 @@ static void parse_asm_constraint(struct asm_operand *op) op->is_memory = 0; } -static void verify_output_constraint(struct expression *expr, const char *constraint) +static void verify_output_constraint(struct asm_operand *op) { - switch (*constraint) { - case '=': /* Assignment */ - case '+': /* Update */ - break; - default: + struct expression *expr = op->constraint; + const char *constraint = expr->string->data; + + if (!op->is_assign) expression_error(expr, "output constraint is not an assignment constraint (\"%s\")", constraint); - } } -static void verify_input_constraint(struct expression *expr, const char *constraint) +static void verify_input_constraint(struct asm_operand *op) { - switch (*constraint) { - case '=': /* Assignment */ - case '+': /* Update */ + struct expression *expr = op->constraint; + const char *constraint = expr->string->data; + + if (op->is_assign) expression_error(expr, "input constraint with assignment (\"%s\")", constraint); - } } static void evaluate_asm_statement(struct statement *stmt) @@ -3587,18 +3585,16 @@ static void evaluate_asm_statement(struct statement *stmt) struct asm_operand *op; struct symbol *sym; - expr = stmt->asm_string; - if (!expr) + if (!stmt->asm_string) return; FOR_EACH_PTR(stmt->asm_outputs, op) { /* Identifier */ /* Constraint */ - expr = op->constraint; - if (expr) { + if (op->constraint) { parse_asm_constraint(op); - verify_output_constraint(expr, expr->string->data); + verify_output_constraint(op); } /* Expression */ @@ -3614,10 +3610,9 @@ static void evaluate_asm_statement(struct statement *stmt) /* Identifier */ /* Constraint */ - expr = op->constraint; - if (expr) { + if (op->constraint) { parse_asm_constraint(op); - verify_input_constraint(expr, expr->string->data); + verify_input_constraint(op); } /* Expression */ |