[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);
----------------
SixWeining wrote:

Consistent with existing code.
```suggestion
  unsigned Rd = fieldFromInstruction(Insn, 0, 5);
  unsigned Rj = fieldFromInstruction(Insn, 5, 5);
  unsigned Rk = fieldFromInstruction(Insn, 10, 5);
```

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


More information about the llvm-commits mailing list