@@ -59,20 +59,6 @@ using namespace llvm;
59
59
60
60
namespace {
61
61
62
- // / Keeps track of state when getting the sign of a floating-point value as an
63
- // / integer.
64
- struct FloatSignAsInt {
65
- EVT FloatVT;
66
- SDValue Chain;
67
- SDValue FloatPtr;
68
- SDValue IntPtr;
69
- MachinePointerInfo IntPointerInfo;
70
- MachinePointerInfo FloatPointerInfo;
71
- SDValue IntValue;
72
- APInt SignMask;
73
- uint8_t SignBit;
74
- };
75
-
76
62
// ===----------------------------------------------------------------------===//
77
63
// / This takes an arbitrary SelectionDAG as input and
78
64
// / hacks on it until the target machine can handle it. This involves
@@ -166,10 +152,6 @@ class SelectionDAGLegalize {
166
152
SDValue ExpandSCALAR_TO_VECTOR (SDNode *Node);
167
153
void ExpandDYNAMIC_STACKALLOC (SDNode *Node,
168
154
SmallVectorImpl<SDValue> &Results);
169
- void getSignAsIntValue (FloatSignAsInt &State, const SDLoc &DL,
170
- SDValue Value) const ;
171
- SDValue modifySignAsInt (const FloatSignAsInt &State, const SDLoc &DL,
172
- SDValue NewIntValue) const ;
173
155
SDValue ExpandFCOPYSIGN (SDNode *Node) const ;
174
156
SDValue ExpandFABS (SDNode *Node) const ;
175
157
SDValue ExpandFNEG (SDNode *Node) const ;
@@ -1620,82 +1602,14 @@ SDValue SelectionDAGLegalize::ExpandVectorBuildThroughStack(SDNode* Node) {
1620
1602
return DAG.getLoad (VT, dl, StoreChain, FIPtr, PtrInfo);
1621
1603
}
1622
1604
1623
- // / Bitcast a floating-point value to an integer value. Only bitcast the part
1624
- // / containing the sign bit if the target has no integer value capable of
1625
- // / holding all bits of the floating-point value.
1626
- void SelectionDAGLegalize::getSignAsIntValue (FloatSignAsInt &State,
1627
- const SDLoc &DL,
1628
- SDValue Value) const {
1629
- EVT FloatVT = Value.getValueType ();
1630
- unsigned NumBits = FloatVT.getScalarSizeInBits ();
1631
- State.FloatVT = FloatVT;
1632
- EVT IVT = EVT::getIntegerVT (*DAG.getContext (), NumBits);
1633
- // Convert to an integer of the same size.
1634
- if (TLI.isTypeLegal (IVT)) {
1635
- State.IntValue = DAG.getNode (ISD::BITCAST, DL, IVT, Value);
1636
- State.SignMask = APInt::getSignMask (NumBits);
1637
- State.SignBit = NumBits - 1 ;
1638
- return ;
1639
- }
1640
-
1641
- auto &DataLayout = DAG.getDataLayout ();
1642
- // Store the float to memory, then load the sign part out as an integer.
1643
- MVT LoadTy = TLI.getRegisterType (MVT::i8 );
1644
- // First create a temporary that is aligned for both the load and store.
1645
- SDValue StackPtr = DAG.CreateStackTemporary (FloatVT, LoadTy);
1646
- int FI = cast<FrameIndexSDNode>(StackPtr.getNode ())->getIndex ();
1647
- // Then store the float to it.
1648
- State.FloatPtr = StackPtr;
1649
- MachineFunction &MF = DAG.getMachineFunction ();
1650
- State.FloatPointerInfo = MachinePointerInfo::getFixedStack (MF, FI);
1651
- State.Chain = DAG.getStore (DAG.getEntryNode (), DL, Value, State.FloatPtr ,
1652
- State.FloatPointerInfo );
1653
-
1654
- SDValue IntPtr;
1655
- if (DataLayout.isBigEndian ()) {
1656
- assert (FloatVT.isByteSized () && " Unsupported floating point type!" );
1657
- // Load out a legal integer with the same sign bit as the float.
1658
- IntPtr = StackPtr;
1659
- State.IntPointerInfo = State.FloatPointerInfo ;
1660
- } else {
1661
- // Advance the pointer so that the loaded byte will contain the sign bit.
1662
- unsigned ByteOffset = (NumBits / 8 ) - 1 ;
1663
- IntPtr =
1664
- DAG.getMemBasePlusOffset (StackPtr, TypeSize::getFixed (ByteOffset), DL);
1665
- State.IntPointerInfo = MachinePointerInfo::getFixedStack (MF, FI,
1666
- ByteOffset);
1667
- }
1668
-
1669
- State.IntPtr = IntPtr;
1670
- State.IntValue = DAG.getExtLoad (ISD::EXTLOAD, DL, LoadTy, State.Chain , IntPtr,
1671
- State.IntPointerInfo , MVT::i8 );
1672
- State.SignMask = APInt::getOneBitSet (LoadTy.getScalarSizeInBits (), 7 );
1673
- State.SignBit = 7 ;
1674
- }
1675
-
1676
- // / Replace the integer value produced by getSignAsIntValue() with a new value
1677
- // / and cast the result back to a floating-point type.
1678
- SDValue SelectionDAGLegalize::modifySignAsInt (const FloatSignAsInt &State,
1679
- const SDLoc &DL,
1680
- SDValue NewIntValue) const {
1681
- if (!State.Chain )
1682
- return DAG.getNode (ISD::BITCAST, DL, State.FloatVT , NewIntValue);
1683
-
1684
- // Override the part containing the sign bit in the value stored on the stack.
1685
- SDValue Chain = DAG.getTruncStore (State.Chain , DL, NewIntValue, State.IntPtr ,
1686
- State.IntPointerInfo , MVT::i8 );
1687
- return DAG.getLoad (State.FloatVT , DL, Chain, State.FloatPtr ,
1688
- State.FloatPointerInfo );
1689
- }
1690
-
1691
1605
SDValue SelectionDAGLegalize::ExpandFCOPYSIGN (SDNode *Node) const {
1692
1606
SDLoc DL (Node);
1693
1607
SDValue Mag = Node->getOperand (0 );
1694
1608
SDValue Sign = Node->getOperand (1 );
1695
1609
1696
1610
// Get sign bit into an integer value.
1697
1611
FloatSignAsInt SignAsInt;
1698
- getSignAsIntValue (SignAsInt, DL, Sign);
1612
+ DAG. getSignAsIntValue (SignAsInt, DL, Sign);
1699
1613
1700
1614
EVT IntVT = SignAsInt.IntValue .getValueType ();
1701
1615
SDValue SignMask = DAG.getConstant (SignAsInt.SignMask , DL, IntVT);
@@ -1716,7 +1630,7 @@ SDValue SelectionDAGLegalize::ExpandFCOPYSIGN(SDNode *Node) const {
1716
1630
1717
1631
// Transform Mag value to integer, and clear the sign bit.
1718
1632
FloatSignAsInt MagAsInt;
1719
- getSignAsIntValue (MagAsInt, DL, Mag);
1633
+ DAG. getSignAsIntValue (MagAsInt, DL, Mag);
1720
1634
EVT MagVT = MagAsInt.IntValue .getValueType ();
1721
1635
SDValue ClearSignMask = DAG.getConstant (~MagAsInt.SignMask , DL, MagVT);
1722
1636
SDValue ClearedSign = DAG.getNode (ISD::AND, DL, MagVT, MagAsInt.IntValue ,
@@ -1746,14 +1660,14 @@ SDValue SelectionDAGLegalize::ExpandFCOPYSIGN(SDNode *Node) const {
1746
1660
SDValue CopiedSign = DAG.getNode (ISD::OR, DL, MagVT, ClearedSign, SignBit,
1747
1661
SDNodeFlags::Disjoint);
1748
1662
1749
- return modifySignAsInt (MagAsInt, DL, CopiedSign);
1663
+ return DAG. modifySignAsInt (MagAsInt, DL, CopiedSign);
1750
1664
}
1751
1665
1752
1666
SDValue SelectionDAGLegalize::ExpandFNEG (SDNode *Node) const {
1753
1667
// Get the sign bit as an integer.
1754
1668
SDLoc DL (Node);
1755
1669
FloatSignAsInt SignAsInt;
1756
- getSignAsIntValue (SignAsInt, DL, Node->getOperand (0 ));
1670
+ DAG. getSignAsIntValue (SignAsInt, DL, Node->getOperand (0 ));
1757
1671
EVT IntVT = SignAsInt.IntValue .getValueType ();
1758
1672
1759
1673
// Flip the sign.
@@ -1762,7 +1676,7 @@ SDValue SelectionDAGLegalize::ExpandFNEG(SDNode *Node) const {
1762
1676
DAG.getNode (ISD::XOR, DL, IntVT, SignAsInt.IntValue , SignMask);
1763
1677
1764
1678
// Convert back to float.
1765
- return modifySignAsInt (SignAsInt, DL, SignFlip);
1679
+ return DAG. modifySignAsInt (SignAsInt, DL, SignFlip);
1766
1680
}
1767
1681
1768
1682
SDValue SelectionDAGLegalize::ExpandFABS (SDNode *Node) const {
@@ -1778,12 +1692,12 @@ SDValue SelectionDAGLegalize::ExpandFABS(SDNode *Node) const {
1778
1692
1779
1693
// Transform value to integer, clear the sign bit and transform back.
1780
1694
FloatSignAsInt ValueAsInt;
1781
- getSignAsIntValue (ValueAsInt, DL, Value);
1695
+ DAG. getSignAsIntValue (ValueAsInt, DL, Value);
1782
1696
EVT IntVT = ValueAsInt.IntValue .getValueType ();
1783
1697
SDValue ClearSignMask = DAG.getConstant (~ValueAsInt.SignMask , DL, IntVT);
1784
1698
SDValue ClearedSign = DAG.getNode (ISD::AND, DL, IntVT, ValueAsInt.IntValue ,
1785
1699
ClearSignMask);
1786
- return modifySignAsInt (ValueAsInt, DL, ClearedSign);
1700
+ return DAG. modifySignAsInt (ValueAsInt, DL, ClearedSign);
1787
1701
}
1788
1702
1789
1703
void SelectionDAGLegalize::ExpandDYNAMIC_STACKALLOC (SDNode* Node,
0 commit comments