1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[RISCV] Rewrite and simplify helper function. NFC.

Reviewed By: luismarques

Differential Revision: https://reviews.llvm.org/D93851
This commit is contained in:
Fraser Cormack 2020-12-29 11:29:18 +00:00
parent 8f5a28bb71
commit 71203caeb6

View File

@ -2487,19 +2487,14 @@ static bool CC_RISCV(const DataLayout &DL, RISCVABI::ABI ABI, unsigned ValNo,
}
template <typename ArgTy>
static void preAssignMask(const ArgTy &Args,
Optional<unsigned> &FirstMaskArgument,
CCState &CCInfo) {
unsigned NumArgs = Args.size();
for (unsigned I = 0; I != NumArgs; ++I) {
MVT ArgVT = Args[I].VT;
if (!ArgVT.isScalableVector() ||
ArgVT.getVectorElementType().SimpleTy != MVT::i1)
continue;
FirstMaskArgument = I;
break;
static Optional<unsigned> preAssignMask(const ArgTy &Args) {
for (const auto &ArgIdx : enumerate(Args)) {
MVT ArgVT = ArgIdx.value().VT;
if (ArgVT.isScalableVector() &&
ArgVT.getVectorElementType().SimpleTy == MVT::i1)
return ArgIdx.index();
}
return None;
}
void RISCVTargetLowering::analyzeInputArgs(
@ -2510,7 +2505,7 @@ void RISCVTargetLowering::analyzeInputArgs(
Optional<unsigned> FirstMaskArgument;
if (Subtarget.hasStdExtV())
preAssignMask(Ins, FirstMaskArgument, CCInfo);
FirstMaskArgument = preAssignMask(Ins);
for (unsigned i = 0; i != NumArgs; ++i) {
MVT ArgVT = Ins[i].VT;
@ -2541,7 +2536,7 @@ void RISCVTargetLowering::analyzeOutputArgs(
Optional<unsigned> FirstMaskArgument;
if (Subtarget.hasStdExtV())
preAssignMask(Outs, FirstMaskArgument, CCInfo);
FirstMaskArgument = preAssignMask(Outs);
for (unsigned i = 0; i != NumArgs; i++) {
MVT ArgVT = Outs[i].VT;
@ -3312,7 +3307,7 @@ bool RISCVTargetLowering::CanLowerReturn(
Optional<unsigned> FirstMaskArgument;
if (Subtarget.hasStdExtV())
preAssignMask(Outs, FirstMaskArgument, CCInfo);
FirstMaskArgument = preAssignMask(Outs);
for (unsigned i = 0, e = Outs.size(); i != e; ++i) {
MVT VT = Outs[i].VT;