
Up until now the generation of vector instructions was taking place during the top-down post-order traversal of vectorizeRec(). The issue with this approach is that the vector instructions emitted during the traversal can be reordered by the scheduler, making it challenging to place them without breaking the def-before-uses rule. With this patch we separate the vectorization decisions (done in `vectorizeRec()`) from the code generation phase (`emitVectors()`). The vectorization decisions are stored in the `Actions` vector and are used by `emitVectors()` to drive code generation.
35 lines
1.0 KiB
C++
35 lines
1.0 KiB
C++
//===- InstructionMaps.cpp - Maps scalars to vectors and reverse ----------===//
|
|
//
|
|
// 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/InstrMaps.h"
|
|
#include "llvm/Support/Debug.h"
|
|
#include "llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h"
|
|
|
|
namespace llvm::sandboxir {
|
|
|
|
#ifndef NDEBUG
|
|
void Action::print(raw_ostream &OS) const {
|
|
OS << Idx << ". " << *LegalityRes << " Depth:" << Depth << "\n";
|
|
OS.indent(2) << "Bndl:\n";
|
|
for (Value *V : Bndl)
|
|
OS.indent(4) << *V << "\n";
|
|
OS.indent(2) << "UserBndl:\n";
|
|
for (Value *V : UserBndl)
|
|
OS.indent(4) << *V << "\n";
|
|
}
|
|
|
|
void Action::dump() const { print(dbgs()); }
|
|
|
|
void InstrMaps::dump() const {
|
|
print(dbgs());
|
|
dbgs() << "\n";
|
|
}
|
|
#endif // NDEBUG
|
|
|
|
} // namespace llvm::sandboxir
|