Skip to content

Commit 38729a7

Browse files
[GISel][CombinerHelper] Add a function that chains a list of generators together
1 parent e4b0f01 commit 38729a7

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,21 @@ adderGenerator(const int32_t From, const int32_t To, const int32_t StepSize) {
399399
};
400400
}
401401

402+
// Move to the next generator if it is exhausted allowing to chain generators
403+
CombinerHelper::GeneratorType
404+
concatGenerators(SmallVector<CombinerHelper::GeneratorType> &Generators) {
405+
auto *GeneratorIterator = Generators.begin();
406+
407+
return [GeneratorIterator, Generators]() mutable {
408+
std::optional<int32_t> GenValue = (*GeneratorIterator)();
409+
if (!GenValue.has_value() && GeneratorIterator != Generators.end()) {
410+
GeneratorIterator++;
411+
GenValue = (*GeneratorIterator)();
412+
}
413+
return GenValue;
414+
};
415+
}
416+
402417
Register CombinerHelper::createUnmergeValue(
403418
MachineInstr &MI, const Register SrcReg, const Register DstReg,
404419
const uint8_t DestinationIndex, const uint32_t Start, const uint32_t End) {

0 commit comments

Comments
 (0)