@@ -8820,6 +8820,45 @@ static void checkAddrSpaceIsValidForLibcall(const TargetLowering *TLI,
88208820 Twine(AS));
88218821 }
88228822}
8823+ std::pair<SDValue, SDValue>
8824+ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
8825+ SDValue Mem1, SDValue Size, const CallInst *CI) {
8826+
8827+ const char *LibCallName = TLI->getLibcallName(RTLIB::MEMCMP);
8828+ if (LibCallName == nullptr)
8829+ return std::make_pair(SDValue(), SDValue());
8830+ // Emit a library call.
8831+ TargetLowering::ArgListTy Args;
8832+ TargetLowering::ArgListEntry Entry;
8833+ Entry.Ty = PointerType::getUnqual(*getContext());
8834+ Entry.Node = Mem0;
8835+ Args.push_back(Entry);
8836+ Entry.Node = Mem1;
8837+ Args.push_back(Entry);
8838+
8839+ Entry.Ty = getDataLayout().getIntPtrType(*getContext());
8840+ Entry.Node = Size;
8841+ Args.push_back(Entry);
8842+
8843+ // FIXME: pass in SDLoc
8844+ TargetLowering::CallLoweringInfo CLI(*this);
8845+ bool IsTailCall = false;
8846+ bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
8847+ IsTailCall = CI && CI->isTailCall() &&
8848+ isInTailCallPosition(*CI, getTarget(), ReturnsFirstArg);
8849+
8850+ CLI.setDebugLoc(dl)
8851+ .setChain(Chain)
8852+ .setLibCallee(
8853+ TLI->getLibcallCallingConv(RTLIB::MEMCMP),
8854+ Type::getInt32Ty(*getContext()),
8855+ getExternalSymbol(LibCallName, TLI->getPointerTy(getDataLayout())),
8856+ std::move(Args))
8857+ .setTailCall(IsTailCall);
8858+
8859+ std::pair<SDValue, SDValue> CallResult = TLI->LowerCallTo(CLI);
8860+ return CallResult;
8861+ }
88238862
88248863SDValue SelectionDAG::getMemcpy(
88258864 SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size,
0 commit comments