[clang] [llvm] [LoongArch] Support amcas[_db].{b/h/w/d} instructions. (PR #114189)

via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 31 18:44:57 PDT 2024


================
@@ -1562,7 +1562,9 @@ unsigned LoongArchAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
   unsigned Opc = Inst.getOpcode();
   switch (Opc) {
   default:
-    if (Opc >= LoongArch::AMADD_D && Opc <= LoongArch::AMXOR_W) {
+    // amcas[_db].{b/h/w/d} didn't need this judgement
+    if ((Opc >= LoongArch::AMADD_B && Opc <= LoongArch::AMAND__DB_W) ||
+        (Opc >= LoongArch::AMMAX_D && Opc <= LoongArch::AMXOR__DB_W)) {
----------------
tangaac wrote:

> Ah. This is very prone to breakage as correct operation relies on the order of insn definitions in the TableGen files.

I think so.

After v1.1 instructions added, AMADD_B has the smallest opc because of dictionary order.
While AMXOR__DB_W already has the largest opc, not AMXOR_W. The previous code should be a bug.

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


More information about the cfe-commits mailing list