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 Sep 23, 2024
1 parent e4b0f01 commit 38729a7
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 @@ -399,6 +399,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
CombinerHelper::GeneratorType
concatGenerators(SmallVector<CombinerHelper::GeneratorType> &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 38729a7

Please sign in to comment.