From 36e6ec10069fe84aa677ab9ea4446e7fa3332886 Mon Sep 17 00:00:00 2001 From: taitep Date: Tue, 13 Jan 2026 16:46:53 +0100 Subject: Implement Zalrsc --- src/decode.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/decode.rs') diff --git a/src/decode.rs b/src/decode.rs index 480fdff..be0dbc3 100644 --- a/src/decode.rs +++ b/src/decode.rs @@ -4,6 +4,8 @@ // This file is part of TRVE (https://gitea.taitep.se/taitep/trve) // See LICENSE file in the project root for full license text. +use std::sync::atomic::Ordering; + const MASK_REGISTER: u32 = 0x1f; #[derive(Clone, Copy)] @@ -104,7 +106,22 @@ impl Instruction { } /// Mostly/only used for the SYSTEM opcode + #[inline] pub fn funct12(self) -> u16 { (self.0 >> 20) as u16 } + + /// Looks at the aq/rl bits of atomic instructions and converts to an Ordering + #[inline] + pub fn amo_ordering(self) -> Ordering { + let aq = self.0 >> 26 & 1 != 0; + let rl = self.0 >> 25 & 1 != 0; + + match (aq, rl) { + (false, false) => Ordering::Relaxed, + (false, true) => Ordering::Release, + (true, false) => Ordering::Acquire, + (true, true) => Ordering::AcqRel, + } + } } -- cgit v1.2.3