1 //===- VPlanBuilder.h - A VPlan utility for constructing VPInstructions ---===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file provides a VPlan-based builder utility analogous to IRBuilder.
12 /// It provides an instruction-level API for generating VPInstructions while
13 /// abstracting away the Recipe manipulation details.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_BUILDER_H
17 #define LLVM_TRANSFORMS_VECTORIZE_VPLAN_BUILDER_H
25 VPBasicBlock *BB = nullptr;
26 VPBasicBlock::iterator InsertPt = VPBasicBlock::iterator();
28 VPInstruction *createInstruction(unsigned Opcode,
29 std::initializer_list<VPValue *> Operands) {
30 VPInstruction *Instr = new VPInstruction(Opcode, Operands);
31 BB->insert(Instr, InsertPt);
38 /// \brief This specifies that created VPInstructions should be appended to
39 /// the end of the specified block.
40 void setInsertPoint(VPBasicBlock *TheBB) {
41 assert(TheBB && "Attempting to set a null insert point");
46 VPValue *createNot(VPValue *Operand) {
47 return createInstruction(VPInstruction::Not, {Operand});
50 VPValue *createAnd(VPValue *LHS, VPValue *RHS) {
51 return createInstruction(Instruction::BinaryOps::And, {LHS, RHS});
54 VPValue *createOr(VPValue *LHS, VPValue *RHS) {
55 return createInstruction(Instruction::BinaryOps::Or, {LHS, RHS});
61 #endif // LLVM_TRANSFORMS_VECTORIZE_VPLAN_BUILDER_H