mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
tidy up, reduce indentation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111982 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -86,8 +86,7 @@ private:
|
|||||||
// 2) For vectors, use a wider vector type (e.g. v3i32 -> v4i32).
|
// 2) For vectors, use a wider vector type (e.g. v3i32 -> v4i32).
|
||||||
if (!VT.isVector())
|
if (!VT.isVector())
|
||||||
return PromoteInteger;
|
return PromoteInteger;
|
||||||
else
|
return WidenVector;
|
||||||
return WidenVector;
|
|
||||||
case TargetLowering::Expand:
|
case TargetLowering::Expand:
|
||||||
// Expand can mean
|
// Expand can mean
|
||||||
// 1) split scalar in half, 2) convert a float to an integer,
|
// 1) split scalar in half, 2) convert a float to an integer,
|
||||||
@ -95,16 +94,15 @@ private:
|
|||||||
if (!VT.isVector()) {
|
if (!VT.isVector()) {
|
||||||
if (VT.isInteger())
|
if (VT.isInteger())
|
||||||
return ExpandInteger;
|
return ExpandInteger;
|
||||||
else if (VT.getSizeInBits() ==
|
if (VT.getSizeInBits() ==
|
||||||
TLI.getTypeToTransformTo(*DAG.getContext(), VT).getSizeInBits())
|
TLI.getTypeToTransformTo(*DAG.getContext(), VT).getSizeInBits())
|
||||||
return SoftenFloat;
|
return SoftenFloat;
|
||||||
else
|
return ExpandFloat;
|
||||||
return ExpandFloat;
|
|
||||||
} else if (VT.getVectorNumElements() == 1) {
|
|
||||||
return ScalarizeVector;
|
|
||||||
} else {
|
|
||||||
return SplitVector;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (VT.getVectorNumElements() == 1)
|
||||||
|
return ScalarizeVector;
|
||||||
|
return SplitVector;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1274,8 +1274,8 @@ SDValue DAGTypeLegalizer::WidenVecRes_Binary(SDNode *N) {
|
|||||||
EVT VT = WidenVT;
|
EVT VT = WidenVT;
|
||||||
unsigned NumElts = VT.getVectorNumElements();
|
unsigned NumElts = VT.getVectorNumElements();
|
||||||
while (!TLI.isTypeSynthesizable(VT) && NumElts != 1) {
|
while (!TLI.isTypeSynthesizable(VT) && NumElts != 1) {
|
||||||
NumElts = NumElts / 2;
|
NumElts = NumElts / 2;
|
||||||
VT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NumElts);
|
VT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NumElts);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NumElts != 1 && !TLI.canOpTrap(N->getOpcode(), VT)) {
|
if (NumElts != 1 && !TLI.canOpTrap(N->getOpcode(), VT)) {
|
||||||
@ -1283,124 +1283,123 @@ SDValue DAGTypeLegalizer::WidenVecRes_Binary(SDNode *N) {
|
|||||||
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
|
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
|
||||||
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
|
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
|
||||||
return DAG.getNode(N->getOpcode(), dl, WidenVT, InOp1, InOp2);
|
return DAG.getNode(N->getOpcode(), dl, WidenVT, InOp1, InOp2);
|
||||||
} else if (NumElts == 1) {
|
|
||||||
// No legal vector version so unroll the vector operation and then widen.
|
|
||||||
return DAG.UnrollVectorOp(N, WidenVT.getVectorNumElements());
|
|
||||||
} else {
|
|
||||||
// Since the operation can trap, apply operation on the original vector.
|
|
||||||
EVT MaxVT = VT;
|
|
||||||
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
|
|
||||||
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
|
|
||||||
unsigned CurNumElts = N->getValueType(0).getVectorNumElements();
|
|
||||||
|
|
||||||
SmallVector<SDValue, 16> ConcatOps(CurNumElts);
|
|
||||||
unsigned ConcatEnd = 0; // Current ConcatOps index.
|
|
||||||
int Idx = 0; // Current Idx into input vectors.
|
|
||||||
|
|
||||||
// NumElts := greatest synthesizable vector size (at most WidenVT)
|
|
||||||
// while (orig. vector has unhandled elements) {
|
|
||||||
// take munches of size NumElts from the beginning and add to ConcatOps
|
|
||||||
// NumElts := next smaller supported vector size or 1
|
|
||||||
// }
|
|
||||||
while (CurNumElts != 0) {
|
|
||||||
while (CurNumElts >= NumElts) {
|
|
||||||
SDValue EOp1 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, InOp1,
|
|
||||||
DAG.getIntPtrConstant(Idx));
|
|
||||||
SDValue EOp2 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, InOp2,
|
|
||||||
DAG.getIntPtrConstant(Idx));
|
|
||||||
ConcatOps[ConcatEnd++] = DAG.getNode(Opcode, dl, VT, EOp1, EOp2);
|
|
||||||
Idx += NumElts;
|
|
||||||
CurNumElts -= NumElts;
|
|
||||||
}
|
|
||||||
do {
|
|
||||||
NumElts = NumElts / 2;
|
|
||||||
VT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NumElts);
|
|
||||||
} while (!TLI.isTypeSynthesizable(VT) && NumElts != 1);
|
|
||||||
|
|
||||||
if (NumElts == 1) {
|
|
||||||
for (unsigned i = 0; i != CurNumElts; ++i, ++Idx) {
|
|
||||||
SDValue EOp1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, WidenEltVT,
|
|
||||||
InOp1, DAG.getIntPtrConstant(Idx));
|
|
||||||
SDValue EOp2 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, WidenEltVT,
|
|
||||||
InOp2, DAG.getIntPtrConstant(Idx));
|
|
||||||
ConcatOps[ConcatEnd++] = DAG.getNode(Opcode, dl, WidenEltVT,
|
|
||||||
EOp1, EOp2);
|
|
||||||
}
|
|
||||||
CurNumElts = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check to see if we have a single operation with the widen type.
|
|
||||||
if (ConcatEnd == 1) {
|
|
||||||
VT = ConcatOps[0].getValueType();
|
|
||||||
if (VT == WidenVT)
|
|
||||||
return ConcatOps[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// while (Some element of ConcatOps is not of type MaxVT) {
|
|
||||||
// From the end of ConcatOps, collect elements of the same type and put
|
|
||||||
// them into an op of the next larger supported type
|
|
||||||
// }
|
|
||||||
while (ConcatOps[ConcatEnd-1].getValueType() != MaxVT) {
|
|
||||||
Idx = ConcatEnd - 1;
|
|
||||||
VT = ConcatOps[Idx--].getValueType();
|
|
||||||
while (Idx >= 0 && ConcatOps[Idx].getValueType() == VT)
|
|
||||||
Idx--;
|
|
||||||
|
|
||||||
int NextSize = VT.isVector() ? VT.getVectorNumElements() : 1;
|
|
||||||
EVT NextVT;
|
|
||||||
do {
|
|
||||||
NextSize *= 2;
|
|
||||||
NextVT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NextSize);
|
|
||||||
} while (!TLI.isTypeSynthesizable(NextVT));
|
|
||||||
|
|
||||||
if (!VT.isVector()) {
|
|
||||||
// Scalar type, create an INSERT_VECTOR_ELEMENT of type NextVT
|
|
||||||
SDValue VecOp = DAG.getUNDEF(NextVT);
|
|
||||||
unsigned NumToInsert = ConcatEnd - Idx - 1;
|
|
||||||
for (unsigned i = 0, OpIdx = Idx+1; i < NumToInsert; i++, OpIdx++) {
|
|
||||||
VecOp = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NextVT, VecOp,
|
|
||||||
ConcatOps[OpIdx], DAG.getIntPtrConstant(i));
|
|
||||||
}
|
|
||||||
ConcatOps[Idx+1] = VecOp;
|
|
||||||
ConcatEnd = Idx + 2;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Vector type, create a CONCAT_VECTORS of type NextVT
|
|
||||||
SDValue undefVec = DAG.getUNDEF(VT);
|
|
||||||
unsigned OpsToConcat = NextSize/VT.getVectorNumElements();
|
|
||||||
SmallVector<SDValue, 16> SubConcatOps(OpsToConcat);
|
|
||||||
unsigned RealVals = ConcatEnd - Idx - 1;
|
|
||||||
unsigned SubConcatEnd = 0;
|
|
||||||
unsigned SubConcatIdx = Idx + 1;
|
|
||||||
while (SubConcatEnd < RealVals)
|
|
||||||
SubConcatOps[SubConcatEnd++] = ConcatOps[++Idx];
|
|
||||||
while (SubConcatEnd < OpsToConcat)
|
|
||||||
SubConcatOps[SubConcatEnd++] = undefVec;
|
|
||||||
ConcatOps[SubConcatIdx] = DAG.getNode(ISD::CONCAT_VECTORS, dl,
|
|
||||||
NextVT, &SubConcatOps[0],
|
|
||||||
OpsToConcat);
|
|
||||||
ConcatEnd = SubConcatIdx + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check to see if we have a single operation with the widen type.
|
|
||||||
if (ConcatEnd == 1) {
|
|
||||||
VT = ConcatOps[0].getValueType();
|
|
||||||
if (VT == WidenVT)
|
|
||||||
return ConcatOps[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
// add undefs of size MaxVT until ConcatOps grows to length of WidenVT
|
|
||||||
unsigned NumOps =
|
|
||||||
WidenVT.getVectorNumElements()/MaxVT.getVectorNumElements();
|
|
||||||
if (NumOps != ConcatEnd ) {
|
|
||||||
SDValue UndefVal = DAG.getUNDEF(MaxVT);
|
|
||||||
for (unsigned j = ConcatEnd; j < NumOps; ++j)
|
|
||||||
ConcatOps[j] = UndefVal;
|
|
||||||
}
|
|
||||||
return DAG.getNode(ISD::CONCAT_VECTORS, dl, WidenVT, &ConcatOps[0], NumOps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No legal vector version so unroll the vector operation and then widen.
|
||||||
|
if (NumElts == 1)
|
||||||
|
return DAG.UnrollVectorOp(N, WidenVT.getVectorNumElements());
|
||||||
|
|
||||||
|
// Since the operation can trap, apply operation on the original vector.
|
||||||
|
EVT MaxVT = VT;
|
||||||
|
SDValue InOp1 = GetWidenedVector(N->getOperand(0));
|
||||||
|
SDValue InOp2 = GetWidenedVector(N->getOperand(1));
|
||||||
|
unsigned CurNumElts = N->getValueType(0).getVectorNumElements();
|
||||||
|
|
||||||
|
SmallVector<SDValue, 16> ConcatOps(CurNumElts);
|
||||||
|
unsigned ConcatEnd = 0; // Current ConcatOps index.
|
||||||
|
int Idx = 0; // Current Idx into input vectors.
|
||||||
|
|
||||||
|
// NumElts := greatest synthesizable vector size (at most WidenVT)
|
||||||
|
// while (orig. vector has unhandled elements) {
|
||||||
|
// take munches of size NumElts from the beginning and add to ConcatOps
|
||||||
|
// NumElts := next smaller supported vector size or 1
|
||||||
|
// }
|
||||||
|
while (CurNumElts != 0) {
|
||||||
|
while (CurNumElts >= NumElts) {
|
||||||
|
SDValue EOp1 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, InOp1,
|
||||||
|
DAG.getIntPtrConstant(Idx));
|
||||||
|
SDValue EOp2 = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, VT, InOp2,
|
||||||
|
DAG.getIntPtrConstant(Idx));
|
||||||
|
ConcatOps[ConcatEnd++] = DAG.getNode(Opcode, dl, VT, EOp1, EOp2);
|
||||||
|
Idx += NumElts;
|
||||||
|
CurNumElts -= NumElts;
|
||||||
|
}
|
||||||
|
do {
|
||||||
|
NumElts = NumElts / 2;
|
||||||
|
VT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NumElts);
|
||||||
|
} while (!TLI.isTypeSynthesizable(VT) && NumElts != 1);
|
||||||
|
|
||||||
|
if (NumElts == 1) {
|
||||||
|
for (unsigned i = 0; i != CurNumElts; ++i, ++Idx) {
|
||||||
|
SDValue EOp1 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, WidenEltVT,
|
||||||
|
InOp1, DAG.getIntPtrConstant(Idx));
|
||||||
|
SDValue EOp2 = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, WidenEltVT,
|
||||||
|
InOp2, DAG.getIntPtrConstant(Idx));
|
||||||
|
ConcatOps[ConcatEnd++] = DAG.getNode(Opcode, dl, WidenEltVT,
|
||||||
|
EOp1, EOp2);
|
||||||
|
}
|
||||||
|
CurNumElts = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check to see if we have a single operation with the widen type.
|
||||||
|
if (ConcatEnd == 1) {
|
||||||
|
VT = ConcatOps[0].getValueType();
|
||||||
|
if (VT == WidenVT)
|
||||||
|
return ConcatOps[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// while (Some element of ConcatOps is not of type MaxVT) {
|
||||||
|
// From the end of ConcatOps, collect elements of the same type and put
|
||||||
|
// them into an op of the next larger supported type
|
||||||
|
// }
|
||||||
|
while (ConcatOps[ConcatEnd-1].getValueType() != MaxVT) {
|
||||||
|
Idx = ConcatEnd - 1;
|
||||||
|
VT = ConcatOps[Idx--].getValueType();
|
||||||
|
while (Idx >= 0 && ConcatOps[Idx].getValueType() == VT)
|
||||||
|
Idx--;
|
||||||
|
|
||||||
|
int NextSize = VT.isVector() ? VT.getVectorNumElements() : 1;
|
||||||
|
EVT NextVT;
|
||||||
|
do {
|
||||||
|
NextSize *= 2;
|
||||||
|
NextVT = EVT::getVectorVT(*DAG.getContext(), WidenEltVT, NextSize);
|
||||||
|
} while (!TLI.isTypeSynthesizable(NextVT));
|
||||||
|
|
||||||
|
if (!VT.isVector()) {
|
||||||
|
// Scalar type, create an INSERT_VECTOR_ELEMENT of type NextVT
|
||||||
|
SDValue VecOp = DAG.getUNDEF(NextVT);
|
||||||
|
unsigned NumToInsert = ConcatEnd - Idx - 1;
|
||||||
|
for (unsigned i = 0, OpIdx = Idx+1; i < NumToInsert; i++, OpIdx++) {
|
||||||
|
VecOp = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, NextVT, VecOp,
|
||||||
|
ConcatOps[OpIdx], DAG.getIntPtrConstant(i));
|
||||||
|
}
|
||||||
|
ConcatOps[Idx+1] = VecOp;
|
||||||
|
ConcatEnd = Idx + 2;
|
||||||
|
} else {
|
||||||
|
// Vector type, create a CONCAT_VECTORS of type NextVT
|
||||||
|
SDValue undefVec = DAG.getUNDEF(VT);
|
||||||
|
unsigned OpsToConcat = NextSize/VT.getVectorNumElements();
|
||||||
|
SmallVector<SDValue, 16> SubConcatOps(OpsToConcat);
|
||||||
|
unsigned RealVals = ConcatEnd - Idx - 1;
|
||||||
|
unsigned SubConcatEnd = 0;
|
||||||
|
unsigned SubConcatIdx = Idx + 1;
|
||||||
|
while (SubConcatEnd < RealVals)
|
||||||
|
SubConcatOps[SubConcatEnd++] = ConcatOps[++Idx];
|
||||||
|
while (SubConcatEnd < OpsToConcat)
|
||||||
|
SubConcatOps[SubConcatEnd++] = undefVec;
|
||||||
|
ConcatOps[SubConcatIdx] = DAG.getNode(ISD::CONCAT_VECTORS, dl,
|
||||||
|
NextVT, &SubConcatOps[0],
|
||||||
|
OpsToConcat);
|
||||||
|
ConcatEnd = SubConcatIdx + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check to see if we have a single operation with the widen type.
|
||||||
|
if (ConcatEnd == 1) {
|
||||||
|
VT = ConcatOps[0].getValueType();
|
||||||
|
if (VT == WidenVT)
|
||||||
|
return ConcatOps[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// add undefs of size MaxVT until ConcatOps grows to length of WidenVT
|
||||||
|
unsigned NumOps = WidenVT.getVectorNumElements()/MaxVT.getVectorNumElements();
|
||||||
|
if (NumOps != ConcatEnd ) {
|
||||||
|
SDValue UndefVal = DAG.getUNDEF(MaxVT);
|
||||||
|
for (unsigned j = ConcatEnd; j < NumOps; ++j)
|
||||||
|
ConcatOps[j] = UndefVal;
|
||||||
|
}
|
||||||
|
return DAG.getNode(ISD::CONCAT_VECTORS, dl, WidenVT, &ConcatOps[0], NumOps);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDValue DAGTypeLegalizer::WidenVecRes_Convert(SDNode *N) {
|
SDValue DAGTypeLegalizer::WidenVecRes_Convert(SDNode *N) {
|
||||||
@ -1561,8 +1560,8 @@ SDValue DAGTypeLegalizer::WidenVecRes_BIT_CONVERT(SDNode *N) {
|
|||||||
unsigned NewNumElts = WidenSize / InSize;
|
unsigned NewNumElts = WidenSize / InSize;
|
||||||
if (InVT.isVector()) {
|
if (InVT.isVector()) {
|
||||||
EVT InEltVT = InVT.getVectorElementType();
|
EVT InEltVT = InVT.getVectorElementType();
|
||||||
NewInVT= EVT::getVectorVT(*DAG.getContext(), InEltVT,
|
NewInVT = EVT::getVectorVT(*DAG.getContext(), InEltVT,
|
||||||
WidenSize / InEltVT.getSizeInBits());
|
WidenSize / InEltVT.getSizeInBits());
|
||||||
} else {
|
} else {
|
||||||
NewInVT = EVT::getVectorVT(*DAG.getContext(), InVT, NewNumElts);
|
NewInVT = EVT::getVectorVT(*DAG.getContext(), InVT, NewNumElts);
|
||||||
}
|
}
|
||||||
@ -1686,8 +1685,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_CONVERT_RNDSAT(SDNode *N) {
|
|||||||
SDValue RndOp = N->getOperand(3);
|
SDValue RndOp = N->getOperand(3);
|
||||||
SDValue SatOp = N->getOperand(4);
|
SDValue SatOp = N->getOperand(4);
|
||||||
|
|
||||||
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(),
|
EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
|
||||||
N->getValueType(0));
|
|
||||||
unsigned WidenNumElts = WidenVT.getVectorNumElements();
|
unsigned WidenNumElts = WidenVT.getVectorNumElements();
|
||||||
|
|
||||||
EVT InVT = InOp.getValueType();
|
EVT InVT = InOp.getValueType();
|
||||||
@ -1720,9 +1718,9 @@ SDValue DAGTypeLegalizer::WidenVecRes_CONVERT_RNDSAT(SDNode *N) {
|
|||||||
SmallVector<SDValue, 16> Ops(NumConcat);
|
SmallVector<SDValue, 16> Ops(NumConcat);
|
||||||
Ops[0] = InOp;
|
Ops[0] = InOp;
|
||||||
SDValue UndefVal = DAG.getUNDEF(InVT);
|
SDValue UndefVal = DAG.getUNDEF(InVT);
|
||||||
for (unsigned i = 1; i != NumConcat; ++i) {
|
for (unsigned i = 1; i != NumConcat; ++i)
|
||||||
Ops[i] = UndefVal;
|
Ops[i] = UndefVal;
|
||||||
}
|
|
||||||
InOp = DAG.getNode(ISD::CONCAT_VECTORS, dl, InWidenVT, &Ops[0],NumConcat);
|
InOp = DAG.getNode(ISD::CONCAT_VECTORS, dl, InWidenVT, &Ops[0],NumConcat);
|
||||||
return DAG.getConvertRndSat(WidenVT, dl, InOp, DTyOp, STyOp, RndOp,
|
return DAG.getConvertRndSat(WidenVT, dl, InOp, DTyOp, STyOp, RndOp,
|
||||||
SatOp, CvtCode);
|
SatOp, CvtCode);
|
||||||
|
Reference in New Issue
Block a user