mirror of
https://github.com/RPCS3/llvm.git
synced 2026-01-31 01:25:19 +01:00
This patch adds a new abstraction layer to VPlan and leverages it to model the planned instructions that manipulate masks (AND, OR, NOT), introduced during predication. The new VPValue and VPUser classes model how data flows into, through and out of a VPlan, forming the vertices of a planned Def-Use graph. The new VPInstruction class is a generic single-instruction Recipe that models a planned instruction along with its opcode, operands and users. See VectorizationPlan.rst for more details. Differential Revision: https://reviews.llvm.org/D38676 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318645 91177308-0d34-0410-b5e6-96231b3b80d8
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
//===- VPlanBuilder.h - A VPlan utility for constructing VPInstructions ---===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
///
|
|
/// \file
|
|
/// This file provides a VPlan-based builder utility analogous to IRBuilder.
|
|
/// It provides an instruction-level API for generating VPInstructions while
|
|
/// abstracting away the Recipe manipulation details.
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_BUILDER_H
|
|
#define LLVM_TRANSFORMS_VECTORIZE_VPLAN_BUILDER_H
|
|
|
|
#include "VPlan.h"
|
|
|
|
namespace llvm {
|
|
|
|
class VPBuilder {
|
|
private:
|
|
VPBasicBlock *BB = nullptr;
|
|
VPBasicBlock::iterator InsertPt = VPBasicBlock::iterator();
|
|
|
|
VPInstruction *createInstruction(unsigned Opcode,
|
|
std::initializer_list<VPValue *> Operands) {
|
|
VPInstruction *Instr = new VPInstruction(Opcode, Operands);
|
|
BB->insert(Instr, InsertPt);
|
|
return Instr;
|
|
}
|
|
|
|
public:
|
|
VPBuilder() {}
|
|
|
|
/// \brief This specifies that created VPInstructions should be appended to
|
|
/// the end of the specified block.
|
|
void setInsertPoint(VPBasicBlock *TheBB) {
|
|
assert(TheBB && "Attempting to set a null insert point");
|
|
BB = TheBB;
|
|
InsertPt = BB->end();
|
|
}
|
|
|
|
VPValue *createNot(VPValue *Operand) {
|
|
return createInstruction(VPInstruction::Not, {Operand});
|
|
}
|
|
|
|
VPValue *createAnd(VPValue *LHS, VPValue *RHS) {
|
|
return createInstruction(Instruction::BinaryOps::And, {LHS, RHS});
|
|
}
|
|
|
|
VPValue *createOr(VPValue *LHS, VPValue *RHS) {
|
|
return createInstruction(Instruction::BinaryOps::Or, {LHS, RHS});
|
|
}
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
#endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_BUILDER_H
|