10b57cec5SDimitry Andric //===-- SystemZSelectionDAGInfo.cpp - SystemZ SelectionDAG Info -----------===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric // 90b57cec5SDimitry Andric // This file implements the SystemZSelectionDAGInfo class. 100b57cec5SDimitry Andric // 110b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric #include "SystemZTargetMachine.h" 140b57cec5SDimitry Andric #include "llvm/CodeGen/SelectionDAG.h" 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric using namespace llvm; 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric #define DEBUG_TYPE "systemz-selectiondag-info" 190b57cec5SDimitry Andric 200b57cec5SDimitry Andric // Decide whether it is best to use a loop or straight-line code for 210b57cec5SDimitry Andric // a block operation of Size bytes with source address Src and destination 220b57cec5SDimitry Andric // address Dest. Sequence is the opcode to use for straight-line code 230b57cec5SDimitry Andric // (such as MVC) and Loop is the opcode to use for loops (such as MVC_LOOP). 240b57cec5SDimitry Andric // Return the chain for the completed operation. 250b57cec5SDimitry Andric static SDValue emitMemMem(SelectionDAG &DAG, const SDLoc &DL, unsigned Sequence, 260b57cec5SDimitry Andric unsigned Loop, SDValue Chain, SDValue Dst, 270b57cec5SDimitry Andric SDValue Src, uint64_t Size) { 280b57cec5SDimitry Andric EVT PtrVT = Src.getValueType(); 290b57cec5SDimitry Andric // The heuristic we use is to prefer loops for anything that would 300b57cec5SDimitry Andric // require 7 or more MVCs. With these kinds of sizes there isn't 310b57cec5SDimitry Andric // much to choose between straight-line code and looping code, 320b57cec5SDimitry Andric // since the time will be dominated by the MVCs themselves. 330b57cec5SDimitry Andric // However, the loop has 4 or 5 instructions (depending on whether 340b57cec5SDimitry Andric // the base addresses can be proved equal), so there doesn't seem 350b57cec5SDimitry Andric // much point using a loop for 5 * 256 bytes or fewer. Anything in 360b57cec5SDimitry Andric // the range (5 * 256, 6 * 256) will need another instruction after 370b57cec5SDimitry Andric // the loop, so it doesn't seem worth using a loop then either. 380b57cec5SDimitry Andric // The next value up, 6 * 256, can be implemented in the same 390b57cec5SDimitry Andric // number of straight-line MVCs as 6 * 256 - 1. 400b57cec5SDimitry Andric if (Size > 6 * 256) 410b57cec5SDimitry Andric return DAG.getNode(Loop, DL, MVT::Other, Chain, Dst, Src, 420b57cec5SDimitry Andric DAG.getConstant(Size, DL, PtrVT), 430b57cec5SDimitry Andric DAG.getConstant(Size / 256, DL, PtrVT)); 440b57cec5SDimitry Andric return DAG.getNode(Sequence, DL, MVT::Other, Chain, Dst, Src, 450b57cec5SDimitry Andric DAG.getConstant(Size, DL, PtrVT)); 460b57cec5SDimitry Andric } 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric SDValue SystemZSelectionDAGInfo::EmitTargetCodeForMemcpy( 490b57cec5SDimitry Andric SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, SDValue Src, 505ffd83dbSDimitry Andric SDValue Size, Align Alignment, bool IsVolatile, bool AlwaysInline, 510b57cec5SDimitry Andric MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const { 520b57cec5SDimitry Andric if (IsVolatile) 530b57cec5SDimitry Andric return SDValue(); 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric if (auto *CSize = dyn_cast<ConstantSDNode>(Size)) 560b57cec5SDimitry Andric return emitMemMem(DAG, DL, SystemZISD::MVC, SystemZISD::MVC_LOOP, 570b57cec5SDimitry Andric Chain, Dst, Src, CSize->getZExtValue()); 580b57cec5SDimitry Andric return SDValue(); 590b57cec5SDimitry Andric } 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric // Handle a memset of 1, 2, 4 or 8 bytes with the operands given by 620b57cec5SDimitry Andric // Chain, Dst, ByteVal and Size. These cases are expected to use 630b57cec5SDimitry Andric // MVI, MVHHI, MVHI and MVGHI respectively. 640b57cec5SDimitry Andric static SDValue memsetStore(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, 650b57cec5SDimitry Andric SDValue Dst, uint64_t ByteVal, uint64_t Size, 660b57cec5SDimitry Andric unsigned Align, MachinePointerInfo DstPtrInfo) { 670b57cec5SDimitry Andric uint64_t StoreVal = ByteVal; 680b57cec5SDimitry Andric for (unsigned I = 1; I < Size; ++I) 690b57cec5SDimitry Andric StoreVal |= ByteVal << (I * 8); 700b57cec5SDimitry Andric return DAG.getStore( 710b57cec5SDimitry Andric Chain, DL, DAG.getConstant(StoreVal, DL, MVT::getIntegerVT(Size * 8)), 720b57cec5SDimitry Andric Dst, DstPtrInfo, Align); 730b57cec5SDimitry Andric } 740b57cec5SDimitry Andric 750b57cec5SDimitry Andric SDValue SystemZSelectionDAGInfo::EmitTargetCodeForMemset( 760b57cec5SDimitry Andric SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dst, 775ffd83dbSDimitry Andric SDValue Byte, SDValue Size, Align Alignment, bool IsVolatile, 780b57cec5SDimitry Andric MachinePointerInfo DstPtrInfo) const { 790b57cec5SDimitry Andric EVT PtrVT = Dst.getValueType(); 800b57cec5SDimitry Andric 810b57cec5SDimitry Andric if (IsVolatile) 820b57cec5SDimitry Andric return SDValue(); 830b57cec5SDimitry Andric 84*fe6060f1SDimitry Andric auto *CByte = dyn_cast<ConstantSDNode>(Byte); 850b57cec5SDimitry Andric if (auto *CSize = dyn_cast<ConstantSDNode>(Size)) { 860b57cec5SDimitry Andric uint64_t Bytes = CSize->getZExtValue(); 870b57cec5SDimitry Andric if (Bytes == 0) 880b57cec5SDimitry Andric return SDValue(); 89*fe6060f1SDimitry Andric if (CByte) { 900b57cec5SDimitry Andric // Handle cases that can be done using at most two of 910b57cec5SDimitry Andric // MVI, MVHI, MVHHI and MVGHI. The latter two can only be 920b57cec5SDimitry Andric // used if ByteVal is all zeros or all ones; in other casees, 930b57cec5SDimitry Andric // we can move at most 2 halfwords. 940b57cec5SDimitry Andric uint64_t ByteVal = CByte->getZExtValue(); 950b57cec5SDimitry Andric if (ByteVal == 0 || ByteVal == 255 ? 960b57cec5SDimitry Andric Bytes <= 16 && countPopulation(Bytes) <= 2 : 970b57cec5SDimitry Andric Bytes <= 4) { 980b57cec5SDimitry Andric unsigned Size1 = Bytes == 16 ? 8 : 1 << findLastSet(Bytes); 990b57cec5SDimitry Andric unsigned Size2 = Bytes - Size1; 1000b57cec5SDimitry Andric SDValue Chain1 = memsetStore(DAG, DL, Chain, Dst, ByteVal, Size1, 1015ffd83dbSDimitry Andric Alignment.value(), DstPtrInfo); 1020b57cec5SDimitry Andric if (Size2 == 0) 1030b57cec5SDimitry Andric return Chain1; 1040b57cec5SDimitry Andric Dst = DAG.getNode(ISD::ADD, DL, PtrVT, Dst, 1050b57cec5SDimitry Andric DAG.getConstant(Size1, DL, PtrVT)); 1060b57cec5SDimitry Andric DstPtrInfo = DstPtrInfo.getWithOffset(Size1); 1075ffd83dbSDimitry Andric SDValue Chain2 = memsetStore( 1085ffd83dbSDimitry Andric DAG, DL, Chain, Dst, ByteVal, Size2, 1095ffd83dbSDimitry Andric std::min((unsigned)Alignment.value(), Size1), DstPtrInfo); 1100b57cec5SDimitry Andric return DAG.getNode(ISD::TokenFactor, DL, MVT::Other, Chain1, Chain2); 1110b57cec5SDimitry Andric } 1120b57cec5SDimitry Andric } else { 1130b57cec5SDimitry Andric // Handle one and two bytes using STC. 1140b57cec5SDimitry Andric if (Bytes <= 2) { 1155ffd83dbSDimitry Andric SDValue Chain1 = 1165ffd83dbSDimitry Andric DAG.getStore(Chain, DL, Byte, Dst, DstPtrInfo, Alignment); 1170b57cec5SDimitry Andric if (Bytes == 1) 1180b57cec5SDimitry Andric return Chain1; 1190b57cec5SDimitry Andric SDValue Dst2 = DAG.getNode(ISD::ADD, DL, PtrVT, Dst, 1200b57cec5SDimitry Andric DAG.getConstant(1, DL, PtrVT)); 121e8d8bef9SDimitry Andric SDValue Chain2 = DAG.getStore(Chain, DL, Byte, Dst2, 122e8d8bef9SDimitry Andric DstPtrInfo.getWithOffset(1), Align(1)); 1230b57cec5SDimitry Andric return DAG.getNode(ISD::TokenFactor, DL, MVT::Other, Chain1, Chain2); 1240b57cec5SDimitry Andric } 1250b57cec5SDimitry Andric } 1260b57cec5SDimitry Andric assert(Bytes >= 2 && "Should have dealt with 0- and 1-byte cases already"); 1270b57cec5SDimitry Andric 1280b57cec5SDimitry Andric // Handle the special case of a memset of 0, which can use XC. 1290b57cec5SDimitry Andric if (CByte && CByte->getZExtValue() == 0) 1300b57cec5SDimitry Andric return emitMemMem(DAG, DL, SystemZISD::XC, SystemZISD::XC_LOOP, 1310b57cec5SDimitry Andric Chain, Dst, Dst, Bytes); 1320b57cec5SDimitry Andric 1330b57cec5SDimitry Andric // Copy the byte to the first location and then use MVC to copy 1340b57cec5SDimitry Andric // it to the rest. 1355ffd83dbSDimitry Andric Chain = DAG.getStore(Chain, DL, Byte, Dst, DstPtrInfo, Alignment); 1360b57cec5SDimitry Andric SDValue DstPlus1 = DAG.getNode(ISD::ADD, DL, PtrVT, Dst, 1370b57cec5SDimitry Andric DAG.getConstant(1, DL, PtrVT)); 1380b57cec5SDimitry Andric return emitMemMem(DAG, DL, SystemZISD::MVC, SystemZISD::MVC_LOOP, 1390b57cec5SDimitry Andric Chain, DstPlus1, Dst, Bytes - 1); 1400b57cec5SDimitry Andric } 141*fe6060f1SDimitry Andric 142*fe6060f1SDimitry Andric // Variable length 143*fe6060f1SDimitry Andric if (CByte && CByte->getZExtValue() == 0) { 144*fe6060f1SDimitry Andric // Handle the special case of a variable length memset of 0 with XC. 145*fe6060f1SDimitry Andric SDValue LenMinus1 = DAG.getNode(ISD::ADD, DL, MVT::i64, 146*fe6060f1SDimitry Andric DAG.getZExtOrTrunc(Size, DL, MVT::i64), 147*fe6060f1SDimitry Andric DAG.getConstant(-1, DL, MVT::i64)); 148*fe6060f1SDimitry Andric SDValue TripC = DAG.getNode(ISD::SRL, DL, MVT::i64, LenMinus1, 149*fe6060f1SDimitry Andric DAG.getConstant(8, DL, MVT::i64)); 150*fe6060f1SDimitry Andric return DAG.getNode(SystemZISD::XC_LOOP, DL, MVT::Other, Chain, Dst, Dst, 151*fe6060f1SDimitry Andric LenMinus1, TripC); 152*fe6060f1SDimitry Andric } 1530b57cec5SDimitry Andric return SDValue(); 1540b57cec5SDimitry Andric } 1550b57cec5SDimitry Andric 1560b57cec5SDimitry Andric // Use CLC to compare [Src1, Src1 + Size) with [Src2, Src2 + Size), 1570b57cec5SDimitry Andric // deciding whether to use a loop or straight-line code. 1580b57cec5SDimitry Andric static SDValue emitCLC(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, 1590b57cec5SDimitry Andric SDValue Src1, SDValue Src2, uint64_t Size) { 1600b57cec5SDimitry Andric SDVTList VTs = DAG.getVTList(MVT::i32, MVT::Other); 1610b57cec5SDimitry Andric EVT PtrVT = Src1.getValueType(); 1620b57cec5SDimitry Andric // A two-CLC sequence is a clear win over a loop, not least because it 1630b57cec5SDimitry Andric // needs only one branch. A three-CLC sequence needs the same number 1640b57cec5SDimitry Andric // of branches as a loop (i.e. 2), but is shorter. That brings us to 1650b57cec5SDimitry Andric // lengths greater than 768 bytes. It seems relatively likely that 1660b57cec5SDimitry Andric // a difference will be found within the first 768 bytes, so we just 1670b57cec5SDimitry Andric // optimize for the smallest number of branch instructions, in order 1680b57cec5SDimitry Andric // to avoid polluting the prediction buffer too much. A loop only ever 1690b57cec5SDimitry Andric // needs 2 branches, whereas a straight-line sequence would need 3 or more. 1700b57cec5SDimitry Andric if (Size > 3 * 256) 1710b57cec5SDimitry Andric return DAG.getNode(SystemZISD::CLC_LOOP, DL, VTs, Chain, Src1, Src2, 1720b57cec5SDimitry Andric DAG.getConstant(Size, DL, PtrVT), 1730b57cec5SDimitry Andric DAG.getConstant(Size / 256, DL, PtrVT)); 1740b57cec5SDimitry Andric return DAG.getNode(SystemZISD::CLC, DL, VTs, Chain, Src1, Src2, 1750b57cec5SDimitry Andric DAG.getConstant(Size, DL, PtrVT)); 1760b57cec5SDimitry Andric } 1770b57cec5SDimitry Andric 1780b57cec5SDimitry Andric // Convert the current CC value into an integer that is 0 if CC == 0, 1790b57cec5SDimitry Andric // greater than zero if CC == 1 and less than zero if CC >= 2. 1800b57cec5SDimitry Andric // The sequence starts with IPM, which puts CC into bits 29 and 28 1810b57cec5SDimitry Andric // of an integer and clears bits 30 and 31. 1820b57cec5SDimitry Andric static SDValue addIPMSequence(const SDLoc &DL, SDValue CCReg, 1830b57cec5SDimitry Andric SelectionDAG &DAG) { 1840b57cec5SDimitry Andric SDValue IPM = DAG.getNode(SystemZISD::IPM, DL, MVT::i32, CCReg); 1850b57cec5SDimitry Andric SDValue SHL = DAG.getNode(ISD::SHL, DL, MVT::i32, IPM, 1860b57cec5SDimitry Andric DAG.getConstant(30 - SystemZ::IPM_CC, DL, MVT::i32)); 1870b57cec5SDimitry Andric SDValue SRA = DAG.getNode(ISD::SRA, DL, MVT::i32, SHL, 1880b57cec5SDimitry Andric DAG.getConstant(30, DL, MVT::i32)); 1890b57cec5SDimitry Andric return SRA; 1900b57cec5SDimitry Andric } 1910b57cec5SDimitry Andric 1920b57cec5SDimitry Andric std::pair<SDValue, SDValue> SystemZSelectionDAGInfo::EmitTargetCodeForMemcmp( 1930b57cec5SDimitry Andric SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src1, 1940b57cec5SDimitry Andric SDValue Src2, SDValue Size, MachinePointerInfo Op1PtrInfo, 1950b57cec5SDimitry Andric MachinePointerInfo Op2PtrInfo) const { 1960b57cec5SDimitry Andric if (auto *CSize = dyn_cast<ConstantSDNode>(Size)) { 1970b57cec5SDimitry Andric uint64_t Bytes = CSize->getZExtValue(); 1980b57cec5SDimitry Andric assert(Bytes > 0 && "Caller should have handled 0-size case"); 1990b57cec5SDimitry Andric // Swap operands to invert CC == 1 vs. CC == 2 cases. 2000b57cec5SDimitry Andric SDValue CCReg = emitCLC(DAG, DL, Chain, Src2, Src1, Bytes); 2010b57cec5SDimitry Andric Chain = CCReg.getValue(1); 2020b57cec5SDimitry Andric return std::make_pair(addIPMSequence(DL, CCReg, DAG), Chain); 2030b57cec5SDimitry Andric } 2040b57cec5SDimitry Andric return std::make_pair(SDValue(), SDValue()); 2050b57cec5SDimitry Andric } 2060b57cec5SDimitry Andric 2070b57cec5SDimitry Andric std::pair<SDValue, SDValue> SystemZSelectionDAGInfo::EmitTargetCodeForMemchr( 2080b57cec5SDimitry Andric SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, 2090b57cec5SDimitry Andric SDValue Char, SDValue Length, MachinePointerInfo SrcPtrInfo) const { 2100b57cec5SDimitry Andric // Use SRST to find the character. End is its address on success. 2110b57cec5SDimitry Andric EVT PtrVT = Src.getValueType(); 2120b57cec5SDimitry Andric SDVTList VTs = DAG.getVTList(PtrVT, MVT::i32, MVT::Other); 2130b57cec5SDimitry Andric Length = DAG.getZExtOrTrunc(Length, DL, PtrVT); 2140b57cec5SDimitry Andric Char = DAG.getZExtOrTrunc(Char, DL, MVT::i32); 2150b57cec5SDimitry Andric Char = DAG.getNode(ISD::AND, DL, MVT::i32, Char, 2160b57cec5SDimitry Andric DAG.getConstant(255, DL, MVT::i32)); 2170b57cec5SDimitry Andric SDValue Limit = DAG.getNode(ISD::ADD, DL, PtrVT, Src, Length); 2180b57cec5SDimitry Andric SDValue End = DAG.getNode(SystemZISD::SEARCH_STRING, DL, VTs, Chain, 2190b57cec5SDimitry Andric Limit, Src, Char); 2200b57cec5SDimitry Andric SDValue CCReg = End.getValue(1); 2210b57cec5SDimitry Andric Chain = End.getValue(2); 2220b57cec5SDimitry Andric 2230b57cec5SDimitry Andric // Now select between End and null, depending on whether the character 2240b57cec5SDimitry Andric // was found. 2258bcb0991SDimitry Andric SDValue Ops[] = { 2268bcb0991SDimitry Andric End, DAG.getConstant(0, DL, PtrVT), 2278bcb0991SDimitry Andric DAG.getTargetConstant(SystemZ::CCMASK_SRST, DL, MVT::i32), 2288bcb0991SDimitry Andric DAG.getTargetConstant(SystemZ::CCMASK_SRST_FOUND, DL, MVT::i32), CCReg}; 2290b57cec5SDimitry Andric End = DAG.getNode(SystemZISD::SELECT_CCMASK, DL, PtrVT, Ops); 2300b57cec5SDimitry Andric return std::make_pair(End, Chain); 2310b57cec5SDimitry Andric } 2320b57cec5SDimitry Andric 2330b57cec5SDimitry Andric std::pair<SDValue, SDValue> SystemZSelectionDAGInfo::EmitTargetCodeForStrcpy( 2340b57cec5SDimitry Andric SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dest, 2350b57cec5SDimitry Andric SDValue Src, MachinePointerInfo DestPtrInfo, MachinePointerInfo SrcPtrInfo, 2360b57cec5SDimitry Andric bool isStpcpy) const { 2370b57cec5SDimitry Andric SDVTList VTs = DAG.getVTList(Dest.getValueType(), MVT::Other); 2380b57cec5SDimitry Andric SDValue EndDest = DAG.getNode(SystemZISD::STPCPY, DL, VTs, Chain, Dest, Src, 2390b57cec5SDimitry Andric DAG.getConstant(0, DL, MVT::i32)); 2400b57cec5SDimitry Andric return std::make_pair(isStpcpy ? EndDest : Dest, EndDest.getValue(1)); 2410b57cec5SDimitry Andric } 2420b57cec5SDimitry Andric 2430b57cec5SDimitry Andric std::pair<SDValue, SDValue> SystemZSelectionDAGInfo::EmitTargetCodeForStrcmp( 2440b57cec5SDimitry Andric SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src1, 2450b57cec5SDimitry Andric SDValue Src2, MachinePointerInfo Op1PtrInfo, 2460b57cec5SDimitry Andric MachinePointerInfo Op2PtrInfo) const { 2470b57cec5SDimitry Andric SDVTList VTs = DAG.getVTList(Src1.getValueType(), MVT::i32, MVT::Other); 2480b57cec5SDimitry Andric // Swap operands to invert CC == 1 vs. CC == 2 cases. 2490b57cec5SDimitry Andric SDValue Unused = DAG.getNode(SystemZISD::STRCMP, DL, VTs, Chain, Src2, Src1, 2500b57cec5SDimitry Andric DAG.getConstant(0, DL, MVT::i32)); 2510b57cec5SDimitry Andric SDValue CCReg = Unused.getValue(1); 2520b57cec5SDimitry Andric Chain = Unused.getValue(2); 2530b57cec5SDimitry Andric return std::make_pair(addIPMSequence(DL, CCReg, DAG), Chain); 2540b57cec5SDimitry Andric } 2550b57cec5SDimitry Andric 2560b57cec5SDimitry Andric // Search from Src for a null character, stopping once Src reaches Limit. 2570b57cec5SDimitry Andric // Return a pair of values, the first being the number of nonnull characters 2580b57cec5SDimitry Andric // and the second being the out chain. 2590b57cec5SDimitry Andric // 2600b57cec5SDimitry Andric // This can be used for strlen by setting Limit to 0. 2610b57cec5SDimitry Andric static std::pair<SDValue, SDValue> getBoundedStrlen(SelectionDAG &DAG, 2620b57cec5SDimitry Andric const SDLoc &DL, 2630b57cec5SDimitry Andric SDValue Chain, SDValue Src, 2640b57cec5SDimitry Andric SDValue Limit) { 2650b57cec5SDimitry Andric EVT PtrVT = Src.getValueType(); 2660b57cec5SDimitry Andric SDVTList VTs = DAG.getVTList(PtrVT, MVT::i32, MVT::Other); 2670b57cec5SDimitry Andric SDValue End = DAG.getNode(SystemZISD::SEARCH_STRING, DL, VTs, Chain, 2680b57cec5SDimitry Andric Limit, Src, DAG.getConstant(0, DL, MVT::i32)); 2690b57cec5SDimitry Andric Chain = End.getValue(2); 2700b57cec5SDimitry Andric SDValue Len = DAG.getNode(ISD::SUB, DL, PtrVT, End, Src); 2710b57cec5SDimitry Andric return std::make_pair(Len, Chain); 2720b57cec5SDimitry Andric } 2730b57cec5SDimitry Andric 2740b57cec5SDimitry Andric std::pair<SDValue, SDValue> SystemZSelectionDAGInfo::EmitTargetCodeForStrlen( 2750b57cec5SDimitry Andric SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, 2760b57cec5SDimitry Andric MachinePointerInfo SrcPtrInfo) const { 2770b57cec5SDimitry Andric EVT PtrVT = Src.getValueType(); 2780b57cec5SDimitry Andric return getBoundedStrlen(DAG, DL, Chain, Src, DAG.getConstant(0, DL, PtrVT)); 2790b57cec5SDimitry Andric } 2800b57cec5SDimitry Andric 2810b57cec5SDimitry Andric std::pair<SDValue, SDValue> SystemZSelectionDAGInfo::EmitTargetCodeForStrnlen( 2820b57cec5SDimitry Andric SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, 2830b57cec5SDimitry Andric SDValue MaxLength, MachinePointerInfo SrcPtrInfo) const { 2840b57cec5SDimitry Andric EVT PtrVT = Src.getValueType(); 2850b57cec5SDimitry Andric MaxLength = DAG.getZExtOrTrunc(MaxLength, DL, PtrVT); 2860b57cec5SDimitry Andric SDValue Limit = DAG.getNode(ISD::ADD, DL, PtrVT, Src, MaxLength); 2870b57cec5SDimitry Andric return getBoundedStrlen(DAG, DL, Chain, Src, Limit); 2880b57cec5SDimitry Andric } 289