[PATCH] D31123: RegisterPressure: Add operators to RegisterMaskPair
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 19 15:43:49 PDT 2017
On Sun, Mar 19, 2017 at 3:28 PM, Axel Davy <axel.davy at ens.fr> wrote:
> I'm not familiar with std::transform, but it looks like one element in the
> source
> can only give one element in the destination, whereas here you can have
> one element
> decomposing into several ones.
>
std::transform does not require the input == the output type.
It only requires that assignment of the output iterator takes the type
Thus, the following should work:
std::transform(Regs.begin(), Regs.end(), vector_inserter(Result), [&]
(const RegisterMaskPair &RegPair)
{
> return getPairsForReg(RegPair.RegUnit, RegPair.LaneMask)
});
Where vector_inserter is defined as:
class vector__inserter
: public std::iterator<std::output_iterator_tag, void, void, void,
void> {
private:
SmallVectorImpl<RegisterMaskPair> &Result;
public:
explicit op_inserter(SmallVectorImpl<RegisterMaskPair> &Result) :
Result(Result) {}
op_inserter &operator=(const SmallVectorImpl<RegisterMaskPair> &Val) {
Result.insert(Result.end(), Val.begin(), Val.end())
return *this;
}
vector_inserter &operator*() { return *this; }
vector_inserter &operator++() { return *this; }
vector_inserter &operator++(int) { return *this; }
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170319/d69ab336/attachment.html>
More information about the llvm-commits
mailing list