Skip to content

Commit

Permalink
[AIE2] Add a function that chains a list of generators together
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentijnvdBeek committed May 17, 2024
1 parent 74dca3d commit 020790f
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 @@ -316,6 +316,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(
std::vector<std::function<std::optional<int32_t>()>> Generators) {
auto GeneratorIterator = Generators.cbegin();

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

Register CombinerHelper::createUnmergeValue(MachineInstr &MI,
const Register SrcReg,
const Register DstReg,
Expand Down

0 comments on commit 020790f

Please sign in to comment.