[X86] Pass parameters into selectVectorAddr to remove dependency on X86MaskedGatherScatterSDNode.

Might be able to get rid of X86ISD::SCATTER and some uses of
X86ISD::GATHER. Which require isel to use ISD::SCATTER and
ISD::GATHER as well.
This commit is contained in:
Craig Topper 2020-02-24 23:17:48 -08:00
parent 9238dfb4d8
commit 89ba4acad6

View File

@ -221,9 +221,9 @@ namespace {
bool selectAddr(SDNode *Parent, SDValue N, SDValue &Base,
SDValue &Scale, SDValue &Index, SDValue &Disp,
SDValue &Segment);
bool selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base,
SDValue &Scale, SDValue &Index, SDValue &Disp,
SDValue &Segment);
bool selectVectorAddr(MemSDNode *Parent, SDValue BasePtr, SDValue IndexOp,
SDValue ScaleOp, SDValue &Base, SDValue &Scale,
SDValue &Index, SDValue &Disp, SDValue &Segment);
bool selectMOV64Imm32(SDValue N, SDValue &Imm);
bool selectLEAAddr(SDValue N, SDValue &Base,
SDValue &Scale, SDValue &Index, SDValue &Disp,
@ -2319,15 +2319,16 @@ bool X86DAGToDAGISel::matchVectorAddress(SDValue N, X86ISelAddressMode &AM) {
return matchAddressBase(N, AM);
}
bool X86DAGToDAGISel::selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base,
SDValue &Scale, SDValue &Index,
SDValue &Disp, SDValue &Segment) {
bool X86DAGToDAGISel::selectVectorAddr(MemSDNode *Parent, SDValue BasePtr,
SDValue IndexOp, SDValue ScaleOp,
SDValue &Base, SDValue &Scale,
SDValue &Index, SDValue &Disp,
SDValue &Segment) {
X86ISelAddressMode AM;
auto *Mgs = cast<X86MaskedGatherScatterSDNode>(Parent);
AM.IndexReg = Mgs->getIndex();
AM.Scale = cast<ConstantSDNode>(Mgs->getScale())->getZExtValue();
AM.IndexReg = IndexOp;
AM.Scale = cast<ConstantSDNode>(ScaleOp)->getZExtValue();
unsigned AddrSpace = cast<MemSDNode>(Parent)->getPointerInfo().getAddrSpace();
unsigned AddrSpace = Parent->getPointerInfo().getAddrSpace();
if (AddrSpace == X86AS::GS)
AM.Segment = CurDAG->getRegister(X86::GS, MVT::i16);
if (AddrSpace == X86AS::FS)
@ -2335,11 +2336,11 @@ bool X86DAGToDAGISel::selectVectorAddr(SDNode *Parent, SDValue N, SDValue &Base,
if (AddrSpace == X86AS::SS)
AM.Segment = CurDAG->getRegister(X86::SS, MVT::i16);
SDLoc DL(N);
MVT VT = N.getSimpleValueType();
SDLoc DL(BasePtr);
MVT VT = BasePtr.getSimpleValueType();
// Try to match into the base and displacement fields.
if (matchVectorAddress(N, AM))
if (matchVectorAddress(BasePtr, AM))
return false;
getAddressOperands(AM, DL, VT, Base, Scale, Index, Disp, Segment);
@ -5467,9 +5468,9 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
if (!Opc)
break;
SDValue BasePtr = Mgt->getBasePtr();
SDValue Base, Scale, Index, Disp, Segment;
if (!selectVectorAddr(Node, BasePtr, Base, Scale, Index, Disp, Segment))
if (!selectVectorAddr(Mgt, Mgt->getBasePtr(), IndexOp, Mgt->getScale(),
Base, Scale, Index, Disp, Segment))
break;
SDValue PassThru = Mgt->getPassThru();
@ -5540,9 +5541,9 @@ void X86DAGToDAGISel::Select(SDNode *Node) {
else
break;
SDValue BasePtr = Sc->getBasePtr();
SDValue Base, Scale, Index, Disp, Segment;
if (!selectVectorAddr(Node, BasePtr, Base, Scale, Index, Disp, Segment))
if (!selectVectorAddr(Sc, Sc->getBasePtr(), IndexOp, Sc->getScale(),
Base, Scale, Index, Disp, Segment))
break;
SDValue Mask = Sc->getMask();