All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 3/3] asm: output *memory* operands need their address as *input*
Date: Sun, 21 Feb 2021 23:28:34 +0100	[thread overview]
Message-ID: <20210221222834.7974-4-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20210221222834.7974-1-luc.vanoostenryck@gmail.com>

The addresses needed by memory output operands are linearized
(and placed) after the ASM instruction needing them.

So, split add_asm_output() in 2 parts: one generating only the
addresses for memory operands and called before issuing the body,
and another one doing the usual copy of (non-memory) output operands
back into their corresponding variables.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 linearize.c                  | 31 +++++++++++++++++++++++--------
 validation/linear/asm-out0.c |  1 -
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/linearize.c b/linearize.c
index 6efa47492869..33d641b40de6 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2144,19 +2144,29 @@ static void add_asm_input(struct entrypoint *ep, struct instruction *insn, struc
 	add_asm_rule(insn, &insn->asm_rules->inputs, op, pseudo);
 }
 
+static void add_asm_output_address(struct entrypoint *ep, struct instruction *insn, struct asm_operand *op)
+{
+	pseudo_t pseudo;
+
+	if (!op->is_memory)
+		return;
+
+	pseudo = linearize_expression(ep, op->expr);
+	add_asm_rule(insn, &insn->asm_rules->outputs, op, pseudo);
+}
+
 static void add_asm_output(struct entrypoint *ep, struct instruction *insn, struct asm_operand *op)
 {
 	struct access_data ad = { NULL, };
 	pseudo_t pseudo;
 
-	if (op->is_memory) {
-		pseudo = linearize_expression(ep, op->expr);
-	} else {
-		if (!linearize_address_gen(ep, op->expr, &ad))
-			return;
-		pseudo = alloc_pseudo(insn);
-		linearize_store_gen(ep, pseudo, &ad);
-	}
+	if (op->is_memory)
+		return;
+
+	if (!linearize_address_gen(ep, op->expr, &ad))
+		return;
+	pseudo = alloc_pseudo(insn);
+	linearize_store_gen(ep, pseudo, &ad);
 
 	add_asm_rule(insn, &insn->asm_rules->outputs, op, pseudo);
 }
@@ -2184,6 +2194,11 @@ static pseudo_t linearize_asm_statement(struct entrypoint *ep, struct statement
 		add_asm_input(ep, insn, op);
 	} END_FOR_EACH_PTR(op);
 
+	/* ... and the addresses for memory outputs */
+	FOR_EACH_PTR(stmt->asm_outputs, op) {
+		add_asm_output_address(ep, insn, op);
+	} END_FOR_EACH_PTR(op);
+
 	add_one_insn(ep, insn);
 
 	/* Assign the outputs */
diff --git a/validation/linear/asm-out0.c b/validation/linear/asm-out0.c
index 64d154ed5ad7..a8e0be693d87 100644
--- a/validation/linear/asm-out0.c
+++ b/validation/linear/asm-out0.c
@@ -7,7 +7,6 @@ static void asm_out0(void)
 /*
  * check-name: asm-out0
  * check-command: test-linearize -fdump-ir $file
- * check-known-to-fail
  *
  * check-output-start
 asm_out0:
-- 
2.30.0


      parent reply	other threads:[~2021-02-21 22:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-21 22:28 [PATCH 0/3] output *memory* operands need their address as *input* Luc Van Oostenryck
2021-02-21 22:28 ` [PATCH 1/3] asm: add testcase for problem with output addresses Luc Van Oostenryck
2021-02-21 22:28 ` [PATCH 2/3] asm: factor out add_asm_rule() from add_asm_{in,out}put() Luc Van Oostenryck
2021-02-21 22:28 ` Luc Van Oostenryck [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210221222834.7974-4-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.