-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[SelectionDAG] Add SelectionDAG::getTypeSize. NFC #169764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b1aaf9b
118dcdd
5c13c4a
b64fd99
0f163f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2102,13 +2102,24 @@ SDValue SelectionDAG::getVScale(const SDLoc &DL, EVT VT, APInt MulImm, | |
| return getNode(ISD::VSCALE, DL, VT, getConstant(MulImm, DL, VT)); | ||
| } | ||
|
|
||
| template <typename Ty> | ||
| static SDValue getFixedOrScalableQuantity(SelectionDAG &DAG, const SDLoc &DL, | ||
| EVT VT, Ty X, bool ConstantFold) { | ||
|
||
| if (X.isScalable()) | ||
| return DAG.getVScale(DL, VT, | ||
| APInt(VT.getSizeInBits(), X.getKnownMinValue())); | ||
|
|
||
| return DAG.getConstant(X.getKnownMinValue(), DL, VT); | ||
| } | ||
|
|
||
| SDValue SelectionDAG::getElementCount(const SDLoc &DL, EVT VT, ElementCount EC, | ||
| bool ConstantFold) { | ||
| if (EC.isScalable()) | ||
| return getVScale(DL, VT, | ||
| APInt(VT.getSizeInBits(), EC.getKnownMinValue())); | ||
| return getFixedOrScalableQuantity(*this, DL, VT, EC, ConstantFold); | ||
| } | ||
|
|
||
| return getConstant(EC.getKnownMinValue(), DL, VT); | ||
| SDValue SelectionDAG::getTypeSize(const SDLoc &DL, EVT VT, TypeSize TS, | ||
| bool ConstantFold) { | ||
| return getFixedOrScalableQuantity(*this, DL, VT, TS, ConstantFold); | ||
| } | ||
|
|
||
| SDValue SelectionDAG::getStepVector(const SDLoc &DL, EVT ResVT) { | ||
|
|
@@ -8485,16 +8496,7 @@ static SDValue getMemsetStringVal(EVT VT, const SDLoc &dl, SelectionDAG &DAG, | |
| SDValue SelectionDAG::getMemBasePlusOffset(SDValue Base, TypeSize Offset, | ||
| const SDLoc &DL, | ||
| const SDNodeFlags Flags) { | ||
| EVT VT = Base.getValueType(); | ||
| SDValue Index; | ||
|
|
||
| if (Offset.isScalable()) | ||
| Index = getVScale(DL, Base.getValueType(), | ||
| APInt(Base.getValueSizeInBits().getFixedValue(), | ||
| Offset.getKnownMinValue())); | ||
| else | ||
| Index = getConstant(Offset.getFixedValue(), DL, VT); | ||
|
|
||
| SDValue Index = getTypeSize(DL, Base.getValueType(), Offset); | ||
| return getMemBasePlusOffset(Base, Index, DL, Flags); | ||
| } | ||
|
|
||
|
|
@@ -13570,11 +13572,8 @@ std::pair<SDValue, SDValue> SelectionDAG::SplitEVL(SDValue N, EVT VecVT, | |
| EVT VT = N.getValueType(); | ||
| assert(VecVT.getVectorElementCount().isKnownEven() && | ||
| "Expecting the mask to be an evenly-sized vector"); | ||
| unsigned HalfMinNumElts = VecVT.getVectorMinNumElements() / 2; | ||
| SDValue HalfNumElts = | ||
| VecVT.isFixedLengthVector() | ||
| ? getConstant(HalfMinNumElts, DL, VT) | ||
| : getVScale(DL, VT, APInt(VT.getScalarSizeInBits(), HalfMinNumElts)); | ||
| SDValue HalfNumElts = getElementCount( | ||
| DL, VT, VecVT.getVectorElementCount().divideCoefficientBy(2)); | ||
| SDValue Lo = getNode(ISD::UMIN, DL, VT, N, HalfNumElts); | ||
| SDValue Hi = getNode(ISD::USUBSAT, DL, VT, N, HalfNumElts); | ||
| return std::make_pair(Lo, Hi); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add documentation for this function to describe what
VTandXmean and how they are used to create the end result?Also, why does it need to be a templated function? Is that for distinguishing EVT and MVT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment in 5c13c4a.
It's templated since it needs to work over both ElementType and TypeSize, both of which inherit from
details::FixedOrScalableQuantity<LeafTy, ScalarTy>, but with different LeafTy and ScalarTys.