[llvm] [RISCV] Initial ISel support for the experimental zacas extension (PR #67918)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 4 19:30:04 PST 2023
================
@@ -10451,13 +10460,73 @@ static SDValue customLegalizeToWOpWithSExt(SDNode *N, SelectionDAG &DAG) {
return DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, NewRes);
}
+// Create an even/odd pair of X registers holding integer value V.
+static SDValue createGPRPairNode(SelectionDAG &DAG, SDValue V, MVT VT,
+ MVT SubRegVT) {
+ SDLoc DL(V.getNode());
+ SDValue VLo = DAG.getAnyExtOrTrunc(V, DL, SubRegVT);
+ SDValue VHi = DAG.getAnyExtOrTrunc(
+ DAG.getNode(
+ ISD::SRL, DL, VT, V,
+ DAG.getConstant(SubRegVT == MVT::i64 ? 64 : 32, DL, SubRegVT)),
+ DL, SubRegVT);
+ SDValue RegClass = DAG.getTargetConstant(
+ VT == MVT::i128 ? RISCV::GPRPI128RegClassID : RISCV::GPRPI64RegClassID,
+ DL, MVT::i32);
+ SDValue SubReg0 = DAG.getTargetConstant(RISCV::sub_32, DL, MVT::i32);
+ SDValue SubReg1 = DAG.getTargetConstant(RISCV::sub_32_hi, DL, MVT::i32);
+ const SDValue Ops[] = {RegClass, VLo, SubReg0, VHi, SubReg1};
+ return SDValue(
+ DAG.getMachineNode(TargetOpcode::REG_SEQUENCE, DL, MVT::Untyped, Ops), 0);
+}
+
+static void ReplaceCMP_SWAP_2XLenResults(SDNode *N,
+ SmallVectorImpl<SDValue> &Results,
+ SelectionDAG &DAG,
+ const RISCVSubtarget &Subtarget) {
+ MVT VT = N->getSimpleValueType(0);
+ assert(N->getValueType(0) == (Subtarget.is64Bit() ? MVT::i128 : MVT::i64) &&
+ "AtomicCmpSwap on types less than 2*XLen should be legal");
+ assert(Subtarget.hasStdExtZacas());
+ MVT SubRegVT = (VT == MVT::i64 ? MVT::i32 : MVT::i64);
----------------
topperc wrote:
Can we just use Subtarget.getXLenVT() here?
https://github.com/llvm/llvm-project/pull/67918
More information about the llvm-commits
mailing list