-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AArch64][SME] Lower memchr to __arm_sc_memchr in streaming[-compatible] functions #168896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b90315b
4b834bc
f1f20f8
e43acbf
014d8df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,29 +156,35 @@ SDValue AArch64SelectionDAGInfo::EmitMOPS(unsigned Opcode, SelectionDAG &DAG, | |
| } | ||
|
|
||
| SDValue AArch64SelectionDAGInfo::EmitStreamingCompatibleMemLibCall( | ||
| SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src, | ||
| SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Op0, SDValue Op1, | ||
| SDValue Size, RTLIB::Libcall LC) const { | ||
| const AArch64Subtarget &STI = | ||
| DAG.getMachineFunction().getSubtarget<AArch64Subtarget>(); | ||
| const AArch64TargetLowering *TLI = STI.getTargetLowering(); | ||
| TargetLowering::ArgListTy Args; | ||
| Args.emplace_back(Dst, PointerType::getUnqual(*DAG.getContext())); | ||
| Args.emplace_back(Op0, PointerType::getUnqual(*DAG.getContext())); | ||
|
|
||
| RTLIB::Libcall NewLC; | ||
| switch (LC) { | ||
| case RTLIB::MEMCPY: { | ||
| NewLC = RTLIB::SC_MEMCPY; | ||
| Args.emplace_back(Src, PointerType::getUnqual(*DAG.getContext())); | ||
| Args.emplace_back(Op1, PointerType::getUnqual(*DAG.getContext())); | ||
| break; | ||
| } | ||
| case RTLIB::MEMMOVE: { | ||
| NewLC = RTLIB::SC_MEMMOVE; | ||
| Args.emplace_back(Src, PointerType::getUnqual(*DAG.getContext())); | ||
| Args.emplace_back(Op1, PointerType::getUnqual(*DAG.getContext())); | ||
| break; | ||
| } | ||
| case RTLIB::MEMSET: { | ||
| NewLC = RTLIB::SC_MEMSET; | ||
| Args.emplace_back(DAG.getZExtOrTrunc(Src, DL, MVT::i32), | ||
| Args.emplace_back(DAG.getZExtOrTrunc(Op1, DL, MVT::i32), | ||
| Type::getInt32Ty(*DAG.getContext())); | ||
| break; | ||
| } | ||
| case RTLIB::MEMCHR: { | ||
| NewLC = RTLIB::SC_MEMCHR; | ||
| Args.emplace_back(DAG.getZExtOrTrunc(Op1, DL, MVT::i32), | ||
| Type::getInt32Ty(*DAG.getContext())); | ||
| break; | ||
| } | ||
|
|
@@ -194,7 +200,11 @@ SDValue AArch64SelectionDAGInfo::EmitStreamingCompatibleMemLibCall( | |
| PointerType *RetTy = PointerType::getUnqual(*DAG.getContext()); | ||
| CLI.setDebugLoc(DL).setChain(Chain).setLibCallee( | ||
| TLI->getLibcallCallingConv(NewLC), RetTy, Symbol, std::move(Args)); | ||
| return TLI->LowerCallTo(CLI).second; | ||
|
|
||
| auto [Result, ChainOut] = TLI->LowerCallTo(CLI); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean the return value of memset, memmove, etc are discarded? I know that the returned pointers are just the destination and are almost certainly ignored at the programmer's level, but if there's some extra-paranoid code out there which verifies the return value what happens? Is it handled elsewhere?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's right. However, the hooks for the calls other than memchr are only used to lower the intrinsics, which return void. The memchr hook is used to replace the standard libcall (and there's no memchr intrinsic). |
||
| if (LC == RTLIB::MEMCHR) | ||
| return DAG.getMergeValues({Result, ChainOut}, DL); | ||
| return ChainOut; | ||
| } | ||
|
|
||
| SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemcpy( | ||
|
|
@@ -255,6 +265,19 @@ SDValue AArch64SelectionDAGInfo::EmitTargetCodeForMemmove( | |
| return SDValue(); | ||
| } | ||
|
|
||
| std::pair<SDValue, SDValue> AArch64SelectionDAGInfo::EmitTargetCodeForMemchr( | ||
| SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Src, | ||
| SDValue Char, SDValue Length, MachinePointerInfo SrcPtrInfo) const { | ||
| auto *AFI = DAG.getMachineFunction().getInfo<AArch64FunctionInfo>(); | ||
| SMEAttrs Attrs = AFI->getSMEFnAttrs(); | ||
| if (LowerToSMERoutines && !Attrs.hasNonStreamingInterfaceAndBody()) { | ||
| SDValue Result = EmitStreamingCompatibleMemLibCall( | ||
| DAG, dl, Chain, Src, Char, Length, RTLIB::MEMCHR); | ||
| return std::make_pair(Result.getValue(0), Result.getValue(1)); | ||
| } | ||
| return std::make_pair(SDValue(), SDValue()); | ||
| } | ||
|
|
||
| static const int kSetTagLoopThreshold = 176; | ||
|
|
||
| static SDValue EmitUnrolledSetTag(SelectionDAG &DAG, const SDLoc &dl, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.