A region identifies a set of vector instructions generated by vectorization passes. The vectorizer can then run a series of RegionPasses on the region, evaluate the cost, and commit/reject the transforms on a region-by-region basis, instead of an entire basic block. This is heavily based ov @vporpo's prototype. In particular, the doc comment for the Region class is all his. The rest of this commit is mostly boilerplate around a SetVector: getters, iterators, and some debug helpers.
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
//===- Region.cpp ---------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Region.h"
|
|
|
|
namespace llvm::sandboxir {
|
|
|
|
Region::Region(Context &Ctx, BasicBlock &BB) : Ctx(Ctx), BB(BB) {
|
|
static unsigned StaticRegionID;
|
|
RegionID = StaticRegionID++;
|
|
}
|
|
|
|
Region::~Region() {}
|
|
|
|
void Region::add(Instruction *I) { Insts.insert(I); }
|
|
|
|
void Region::remove(Instruction *I) { Insts.remove(I); }
|
|
|
|
#ifndef NDEBUG
|
|
bool Region::operator==(const Region &Other) const {
|
|
if (Insts.size() != Other.Insts.size())
|
|
return false;
|
|
if (!std::is_permutation(Insts.begin(), Insts.end(), Other.Insts.begin()))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
void Region::dump(raw_ostream &OS) const {
|
|
OS << "RegionID: " << getID() << "\n";
|
|
for (auto *I : Insts)
|
|
OS << *I << "\n";
|
|
}
|
|
|
|
void Region::dump() const {
|
|
dump(dbgs());
|
|
dbgs() << "\n";
|
|
}
|
|
|
|
} // namespace llvm::sandboxir
|
|
|
|
#endif // NDEBUG
|