Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 27608d8

Browse files
committed
R600/SI: Remove promotion of instructions to e64 forms.
Instructions are now generally selected to the e64 forms originally, and shrunk down later. Rename foldOperands to legalizeOperands, since that's really most of what it tries to do. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217959 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c5f6b53 commit 27608d8

File tree

2 files changed

+6
-58
lines changed

2 files changed

+6
-58
lines changed

lib/Target/R600/SIISelLowering.cpp

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,10 +1666,10 @@ static bool isNodeChanged(const SDNode *Node, const std::vector<SDValue> &Ops) {
16661666
return false;
16671667
}
16681668

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 {
16731673
// Original encoding (either e32 or e64)
16741674
int Opcode = Node->getMachineOpcode();
16751675
const SIInstrInfo *TII = static_cast<const SIInstrInfo *>(
@@ -1686,13 +1686,6 @@ SDNode *SITargetLowering::foldOperands(MachineSDNode *Node,
16861686
assert(!DescRev || DescRev->getNumDefs() == NumDefs);
16871687
assert(!DescRev || DescRev->getNumOperands() == NumOps);
16881688

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-
16961689
int32_t Immediate = Desc->getSize() == 4 ? 0 : -1;
16971690
bool HaveVSrc = false, HaveSSrc = false;
16981691

@@ -1724,7 +1717,6 @@ SDNode *SITargetLowering::foldOperands(MachineSDNode *Node,
17241717

17251718
// Second go over the operands and try to fold them
17261719
std::vector<SDValue> Ops;
1727-
bool Promote2e64 = false;
17281720
for (unsigned i = 0, e = Node->getNumOperands(), Op = NumDefs;
17291721
i != e && Op < NumOps; ++i, ++Op) {
17301722

@@ -1773,50 +1765,6 @@ SDNode *SITargetLowering::foldOperands(MachineSDNode *Node,
17731765
continue;
17741766
}
17751767
}
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-
}
18201768
}
18211769

18221770
// Add optional chain and glue
@@ -1935,7 +1883,7 @@ SDNode *SITargetLowering::PostISelFolding(MachineSDNode *Node,
19351883
if (TII->isMIMG(Node->getMachineOpcode()))
19361884
adjustWritemask(Node, DAG);
19371885

1938-
return foldOperands(Node, DAG);
1886+
return legalizeOperands(Node, DAG);
19391887
}
19401888

19411889
/// \brief Assign the register class depending on the number of

lib/Target/R600/SIISelLowering.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class SITargetLowering : public AMDGPUTargetLowering {
5050
void ensureSRegLimit(SelectionDAG &DAG, SDValue &Operand,
5151
unsigned RegClass, bool &ScalarSlotUsed) const;
5252

53-
SDNode *foldOperands(MachineSDNode *N, SelectionDAG &DAG) const;
53+
SDNode *legalizeOperands(MachineSDNode *N, SelectionDAG &DAG) const;
5454
void adjustWritemask(MachineSDNode *&N, SelectionDAG &DAG) const;
5555
MachineSDNode *AdjustRegClass(MachineSDNode *N, SelectionDAG &DAG) const;
5656

0 commit comments

Comments
 (0)