diff --git a/llvm/include/llvm/IR/IntrinsicsAArch64.td b/llvm/include/llvm/IR/IntrinsicsAArch64.td --- a/llvm/include/llvm/IR/IntrinsicsAArch64.td +++ b/llvm/include/llvm/IR/IntrinsicsAArch64.td @@ -2700,6 +2700,12 @@ def int_aarch64_sme_set_tpidr2 : DefaultAttrsIntrinsic<[], [llvm_i64_ty], [IntrNoMem, IntrHasSideEffects]>; + + def int_aarch64_sme_start_pstateza + : DefaultAttrsIntrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>; + def int_aarch64_sme_stop_pstateza + : DefaultAttrsIntrinsic<[], [], [IntrNoMem, IntrHasSideEffects]>; + // Clamp // diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp --- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp +++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp @@ -1145,6 +1145,9 @@ } } + if (Subtarget->hasSME()) + setOperationAction(ISD::INTRINSIC_VOID, MVT::Other, Custom); + if (Subtarget->hasSVE()) { for (auto VT : {MVT::nxv16i8, MVT::nxv8i16, MVT::nxv4i32, MVT::nxv2i64}) { setOperationAction(ISD::BITREVERSE, VT, Custom); @@ -4554,6 +4557,18 @@ SDValue PStateSM = getPStateSM(DAG, Chain, Attrs, DL, Op.getValueType()); return DAG.getMergeValues({PStateSM, Chain}, DL); } + case Intrinsic::aarch64_sme_start_pstateza: + return DAG.getNode( + AArch64ISD::SMSTART, DL, MVT::Other, + Op->getOperand(0), // Chain + DAG.getTargetConstant((int32_t)(AArch64SVCR::SVCRZA), DL, MVT::i32), + DAG.getConstant(0, DL, MVT::i64), DAG.getConstant(1, DL, MVT::i64)); + case Intrinsic::aarch64_sme_stop_pstateza: + return DAG.getNode( + AArch64ISD::SMSTOP, DL, MVT::Other, + Op->getOperand(0), // Chain + DAG.getTargetConstant((int32_t)(AArch64SVCR::SVCRZA), DL, MVT::i32), + DAG.getConstant(0, DL, MVT::i64), DAG.getConstant(1, DL, MVT::i64)); } } @@ -5596,6 +5611,7 @@ return LowerToPredicatedOp(Op, DAG, AArch64ISD::MULHS_PRED); case ISD::MULHU: return LowerToPredicatedOp(Op, DAG, AArch64ISD::MULHU_PRED); + case ISD::INTRINSIC_VOID: case ISD::INTRINSIC_W_CHAIN: return LowerINTRINSIC_W_CHAIN(Op, DAG); case ISD::INTRINSIC_WO_CHAIN: diff --git a/llvm/test/CodeGen/AArch64/sme-toggle-pstateza.ll b/llvm/test/CodeGen/AArch64/sme-toggle-pstateza.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sme-toggle-pstateza.ll @@ -0,0 +1,16 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=aarch64 -mattr=+sme -verify-machineinstrs < %s | FileCheck %s + +define void @toggle_pstate_za() { +; CHECK-LABEL: toggle_pstate_za: +; CHECK: // %bb.0: +; CHECK-NEXT: smstart za +; CHECK-NEXT: smstop za +; CHECK-NEXT: ret + call void @llvm.aarch64.sme.start.pstateza() + call void @llvm.aarch64.sme.stop.pstateza() + ret void +} + +declare void @llvm.aarch64.sme.start.pstateza() +declare void @llvm.aarch64.sme.stop.pstateza()