From 43f58927d693fbe18a7db2e20f540da13bc15cd3 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sun, 19 Apr 2009 04:56:40 -0700 Subject: [PATCH] X86: Implement a locking version of CMPXCHG. --- .../isa/insts/general_purpose/semaphores.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/arch/x86/isa/insts/general_purpose/semaphores.py b/src/arch/x86/isa/insts/general_purpose/semaphores.py index f23241863..a34e2a3c7 100644 --- a/src/arch/x86/isa/insts/general_purpose/semaphores.py +++ b/src/arch/x86/isa/insts/general_purpose/semaphores.py @@ -79,6 +79,25 @@ def macroop CMPXCHG_P_R { mov rax, rax, t1, flags=(nCZF,) }; +def macroop CMPXCHG_LOCKED_M_R { + ldstl t1, seg, sib, disp + sub t0, rax, t1, flags=(OF, SF, ZF, AF, PF, CF) + + mov t1, t1, reg, flags=(CZF,) + stul t1, seg, sib, disp + mov rax, rax, t1, flags=(nCZF,) +}; + +def macroop CMPXCHG_LOCKED_P_R { + rdip t7 + ldstl t1, seg, riprel, disp + sub t0, rax, t1, flags=(OF, SF, ZF, AF, PF, CF) + + mov t1, t1, reg, flags=(CZF,) + stul t1, seg, riprel, disp + mov rax, rax, t1, flags=(nCZF,) +}; + def macroop XADD_M_R { ldst t1, seg, sib, disp add t2, t1, reg, flags=(OF,SF,ZF,AF,PF,CF) -- 2.30.2