[llvm] [LoongArch] Add support for the ud macro instruction (PR #171583)

Lu Weining via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 10 18:12:06 PST 2025


================
@@ -157,6 +157,29 @@ static DecodeStatus decodeSImmOperand(MCInst &Inst, uint64_t Imm,
   return MCDisassembler::Success;
 }
 
+// Decode AMOSWAP.W and UD, which share the same base encoding.
+// If rk == 1 and rd == rj, interpret the instruction as UD;
+// otherwise decode as AMSWAP.W.
+static DecodeStatus DecodeAMOrUDInstruction(MCInst &Inst, unsigned Insn,
+                                            uint64_t Address,
+                                            const MCDisassembler *Decoder) {
+  unsigned rd = fieldFromInstruction(Insn, 0, 5);
+  unsigned rj = fieldFromInstruction(Insn, 5, 5);
+  unsigned rk = fieldFromInstruction(Insn, 10, 5);
+
+  if (rk == 1 && rd == rj) {
----------------
SixWeining wrote:

Why `rk` must be `1`?

https://github.com/llvm/llvm-project/pull/171583


More information about the llvm-commits mailing list