Skip to content

Commit

Permalink
[GISel][CombinerHelper] Add a function that chains a list of generato…
Browse files Browse the repository at this point in the history
…rs together
  • Loading branch information
ValentijnvdBeek committed Aug 12, 2024
1 parent 509981f commit 7c9880b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,21 @@ adderGenerator(const int32_t From, const int32_t To, const int32_t StepSize) {
};
}

// Move to the next generator if it is exhausted allowing to chain generators
std::function<std::optional<int32_t>()> concatGenerators(
SmallVector<std::function<std::optional<int32_t>()>> &Generators) {
auto *GeneratorIterator = Generators.begin();

return [GeneratorIterator, Generators]() mutable {
std::optional<int32_t> GenValue = (*GeneratorIterator)();
if (!GenValue.has_value() && GeneratorIterator != Generators.end()) {
GeneratorIterator++;
GenValue = (*GeneratorIterator)();
}
return GenValue;
};
}

Register CombinerHelper::createUnmergeValue(
MachineInstr &MI, const Register SrcReg, const Register DstReg,
const uint8_t DestinationIndex, const uint32_t Start, const uint32_t End) {
Expand Down

0 comments on commit 7c9880b

Please sign in to comment.