diff mbox series

[14/18] asm: missing evaluation of asm statements

Message ID 20190927234322.5157-17-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series add missing expansion of ASM operands | expand

Commit Message

Luc Van Oostenryck Sept. 27, 2019, 11:43 p.m. UTC
The operands of extended ASM need to have their type evaluated,
exactly like any other expression.

So, add the missing evaluation of ASM operands.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 evaluate.c                  | 18 ++++++++++++++++++
 validation/eval/asm-memop.c |  1 -
 2 files changed, 18 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/evaluate.c b/evaluate.c
index f0f9b4b34..4f7efc480 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -3579,6 +3579,22 @@  static void verify_input_constraint(struct asm_operand *op)
 		expression_error(expr, "input constraint with assignment (\"%s\")", constraint);
 }
 
+static void evaluate_asm_memop(struct asm_operand *op)
+{
+	if (op->is_memory) {
+		struct expression *expr = op->expr;
+		struct expression *addr;
+
+		// implicit addressof
+		addr = alloc_expression(expr->pos, EXPR_PREOP);
+		addr->op = '&';
+		addr->unop = expr;
+
+		evaluate_addressof(addr);
+		op->expr = addr;
+	}
+}
+
 static void evaluate_asm_statement(struct statement *stmt)
 {
 	struct expression *expr;
@@ -3604,6 +3620,7 @@  static void evaluate_asm_statement(struct statement *stmt)
 		if (!lvalue_expression(expr))
 			warning(expr->pos, "asm output is not an lvalue");
 		evaluate_assign_to(expr, expr->ctype);
+		evaluate_asm_memop(op);
 	} END_FOR_EACH_PTR(op);
 
 	FOR_EACH_PTR(stmt->asm_inputs, op) {
@@ -3618,6 +3635,7 @@  static void evaluate_asm_statement(struct statement *stmt)
 		/* Expression */
 		if (!evaluate_expression(op->expr))
 			return;
+		evaluate_asm_memop(op);
 	} END_FOR_EACH_PTR(op);
 
 	FOR_EACH_PTR(stmt->asm_clobbers, expr) {
diff --git a/validation/eval/asm-memop.c b/validation/eval/asm-memop.c
index 9bbb3a305..33ba0e5a5 100644
--- a/validation/eval/asm-memop.c
+++ b/validation/eval/asm-memop.c
@@ -9,7 +9,6 @@  void fo3(int *p) { asm volatile ("op %0" :: "m" (*p)); }
 /*
  * check-name: eval-asm-memop
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-start
 fo0: