Skip to content

Commit fa63642

Browse files
ReVe1uvKane Wang
andauthored
[RISC-V][GlobaISel] Legalize G_ATOMIC_CMPXCHG and G_ATOMIC_CMPXCHG_WITH_SUCCESS (#157634)
This change introduces legalization for `G_ATOMIC_CMPXCHG` and `G_ATOMIC_CMPXCHG_WITH_SUCCESS`. Additionally, support for the `riscv_masked_cmpxchg intrinsic` is added to legalizeIntrinsic, ensuring that masked compare-and-exchange operations are recognized during legalization. --------- Co-authored-by: Kane Wang <kanewang95@foxmail.com>
1 parent 1723f80 commit fa63642

File tree

7 files changed

+6578
-5
lines changed

7 files changed

+6578
-5
lines changed

llvm/lib/Target/RISCV/GISel/RISCVLegalizerInfo.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,10 @@ RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST)
702702
.customIf(all(typeIsLegalIntOrFPVec(0, IntOrFPVecTys, ST),
703703
typeIsLegalIntOrFPVec(1, IntOrFPVecTys, ST)));
704704

705-
getActionDefinitionsBuilder(G_ATOMICRMW_ADD)
705+
getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG_WITH_SUCCESS)
706+
.lowerIf(all(typeInSet(0, {s8, s16, s32, s64}), typeIs(2, p0)));
707+
708+
getActionDefinitionsBuilder({G_ATOMIC_CMPXCHG, G_ATOMICRMW_ADD})
706709
.legalFor(ST.hasStdExtA(), {{sXLen, p0}})
707710
.libcallFor(!ST.hasStdExtA(), {{s8, p0}, {s16, p0}, {s32, p0}, {s64, p0}})
708711
.clampScalar(0, sXLen, sXLen);
@@ -751,6 +754,7 @@ bool RISCVLegalizerInfo::legalizeIntrinsic(LegalizerHelper &Helper,
751754
}
752755
case Intrinsic::riscv_masked_atomicrmw_add:
753756
case Intrinsic::riscv_masked_atomicrmw_sub:
757+
case Intrinsic::riscv_masked_cmpxchg:
754758
return true;
755759
}
756760
}

0 commit comments

Comments
 (0)