diff mbox series

[3/5] asm-mem: does it clobber memory?

Message ID 20210221223452.8075-4-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series teach memory simplification about ASM instructions | expand

Commit Message

Luc Van Oostenryck Feb. 21, 2021, 10:34 p.m. UTC
An asm statement can specify that it clobbers memory.
Add this info directly in the corresponding instruction, avoiding
the need to scan the clobber list each time.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 linearize.c | 8 +++++++-
 linearize.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/linearize.c b/linearize.c
index 33d641b40de6..4140b60caebd 100644
--- a/linearize.c
+++ b/linearize.c
@@ -2174,7 +2174,7 @@  static void add_asm_output(struct entrypoint *ep, struct instruction *insn, stru
 static pseudo_t linearize_asm_statement(struct entrypoint *ep, struct statement *stmt)
 {
 	struct instruction *insn;
-	struct expression *expr;
+	struct expression *expr, *clob;
 	struct asm_rules *rules;
 	struct asm_operand *op;
 
@@ -2206,6 +2206,12 @@  static pseudo_t linearize_asm_statement(struct entrypoint *ep, struct statement
 		add_asm_output(ep, insn, op);
 	} END_FOR_EACH_PTR(op);
 
+	/* and finally, look if it clobbers memory */
+	FOR_EACH_PTR(stmt->asm_clobbers, clob) {
+		if (!strcmp(clob->string->data, "memory"))
+			insn->clobber_memory = 1;
+	} END_FOR_EACH_PTR(clob);
+
 	return VOID;
 }
 
diff --git a/linearize.h b/linearize.h
index a77e4b3e5f6f..fb51327684bb 100644
--- a/linearize.h
+++ b/linearize.h
@@ -150,6 +150,7 @@  struct instruction {
 		struct /* asm */ {
 			const char *string;
 			struct asm_rules *asm_rules;
+			int clobber_memory:1;
 		};
 	};
 };