@@ -1666,10 +1666,10 @@ static bool isNodeChanged(const SDNode *Node, const std::vector<SDValue> &Ops) {
1666
1666
return false ;
1667
1667
}
1668
1668
1669
- // / \brief Try to fold the Nodes operands into the Node
1670
- SDNode * SITargetLowering::foldOperands (MachineSDNode *Node,
1671
- SelectionDAG &DAG) const {
1672
-
1669
+ // / \brief Try to commute instructions and insert copies in order to satisfy the
1670
+ // / operand constraints.
1671
+ SDNode * SITargetLowering::legalizeOperands (MachineSDNode *Node,
1672
+ SelectionDAG &DAG) const {
1673
1673
// Original encoding (either e32 or e64)
1674
1674
int Opcode = Node->getMachineOpcode ();
1675
1675
const SIInstrInfo *TII = static_cast <const SIInstrInfo *>(
@@ -1686,13 +1686,6 @@ SDNode *SITargetLowering::foldOperands(MachineSDNode *Node,
1686
1686
assert (!DescRev || DescRev->getNumDefs () == NumDefs);
1687
1687
assert (!DescRev || DescRev->getNumOperands () == NumOps);
1688
1688
1689
- // e64 version if available, -1 otherwise
1690
- int OpcodeE64 = AMDGPU::getVOPe64 (Opcode);
1691
- const MCInstrDesc *DescE64 = OpcodeE64 == -1 ? nullptr : &TII->get (OpcodeE64);
1692
- int InputModifiers[3 ] = {0 };
1693
-
1694
- assert (!DescE64 || DescE64->getNumDefs () == NumDefs);
1695
-
1696
1689
int32_t Immediate = Desc->getSize () == 4 ? 0 : -1 ;
1697
1690
bool HaveVSrc = false , HaveSSrc = false ;
1698
1691
@@ -1724,7 +1717,6 @@ SDNode *SITargetLowering::foldOperands(MachineSDNode *Node,
1724
1717
1725
1718
// Second go over the operands and try to fold them
1726
1719
std::vector<SDValue> Ops;
1727
- bool Promote2e64 = false ;
1728
1720
for (unsigned i = 0 , e = Node->getNumOperands (), Op = NumDefs;
1729
1721
i != e && Op < NumOps; ++i, ++Op) {
1730
1722
@@ -1773,50 +1765,6 @@ SDNode *SITargetLowering::foldOperands(MachineSDNode *Node,
1773
1765
continue ;
1774
1766
}
1775
1767
}
1776
-
1777
- if (Immediate)
1778
- continue ;
1779
-
1780
- if (DescE64) {
1781
- // Test if it makes sense to switch to e64 encoding
1782
- unsigned OtherRegClass = DescE64->OpInfo [Op].RegClass ;
1783
- if (!isVSrc (OtherRegClass) && !isSSrc (OtherRegClass))
1784
- continue ;
1785
-
1786
- int32_t TmpImm = -1 ;
1787
- if (foldImm (Ops[i], TmpImm, ScalarSlotUsed) ||
1788
- (!fitsRegClass (DAG, Ops[i], RegClass) &&
1789
- fitsRegClass (DAG, Ops[1 ], OtherRegClass))) {
1790
-
1791
- // Switch to e64 encoding
1792
- Immediate = -1 ;
1793
- Promote2e64 = true ;
1794
- Desc = DescE64;
1795
- DescE64 = nullptr ;
1796
- }
1797
- }
1798
-
1799
- if (!DescE64 && !Promote2e64)
1800
- continue ;
1801
- if (!Operand.isMachineOpcode ())
1802
- continue ;
1803
- }
1804
-
1805
- if (Promote2e64) {
1806
- std::vector<SDValue> OldOps (Ops);
1807
- Ops.clear ();
1808
- bool HasModifiers = TII->hasModifiers (Desc->Opcode );
1809
- for (unsigned i = 0 ; i < OldOps.size (); ++i) {
1810
- // src_modifier
1811
- if (HasModifiers)
1812
- Ops.push_back (DAG.getTargetConstant (InputModifiers[i], MVT::i32 ));
1813
- Ops.push_back (OldOps[i]);
1814
- }
1815
- // Add the modifier flags while promoting
1816
- if (HasModifiers) {
1817
- for (unsigned i = 0 ; i < 2 ; ++i)
1818
- Ops.push_back (DAG.getTargetConstant (0 , MVT::i32 ));
1819
- }
1820
1768
}
1821
1769
1822
1770
// Add optional chain and glue
@@ -1935,7 +1883,7 @@ SDNode *SITargetLowering::PostISelFolding(MachineSDNode *Node,
1935
1883
if (TII->isMIMG (Node->getMachineOpcode ()))
1936
1884
adjustWritemask (Node, DAG);
1937
1885
1938
- return foldOperands (Node, DAG);
1886
+ return legalizeOperands (Node, DAG);
1939
1887
}
1940
1888
1941
1889
// / \brief Assign the register class depending on the number of
0 commit comments