Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VPlanRecipeBase] Add insertBefore helper.
Reviewers: dcaballe, mkuper, hfinkel, hsaito, mssimpso Reviewed By: dcaballe Differential Revision: https://reviews.llvm.org/D48080 llvm-svn: 334933
- Loading branch information
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
add_subdirectory(IPO) | ||
add_subdirectory(Scalar) | ||
add_subdirectory(Utils) | ||
add_subdirectory(Vectorize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
set(LLVM_LINK_COMPONENTS | ||
Vectorize | ||
) | ||
|
||
add_llvm_unittest(VectorizeTests | ||
VPlanTest.cpp | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//===- llvm/unittests/Transforms/Vectorize/VPlanTest.cpp - VPlan tests ----===// | ||
// | ||
// | ||
// The LLVM Compiler Infrastructure | ||
// | ||
// This file is distributed under the University of Illinois Open Source | ||
// License. See LICENSE.TXT for details. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "../lib/Transforms/Vectorize/VPlan.h" | ||
#include "llvm/IR/Instruction.h" | ||
#include "llvm/IR/Instructions.h" | ||
#include "gtest/gtest.h" | ||
|
||
namespace llvm { | ||
namespace { | ||
|
||
#define CHECK_ITERATOR(Range1, ...) \ | ||
do { \ | ||
std::vector<VPInstruction *> Tmp = {__VA_ARGS__}; \ | ||
EXPECT_EQ((size_t)std::distance(Range1.begin(), Range1.end()), \ | ||
Tmp.size()); \ | ||
for (auto Pair : zip(Range1, make_range(Tmp.begin(), Tmp.end()))) \ | ||
EXPECT_EQ(&std::get<0>(Pair), std::get<1>(Pair)); \ | ||
} while (0) | ||
|
||
TEST(VPInstructionTest, insertBefore) { | ||
VPInstruction *I1 = new VPInstruction(0, {}); | ||
VPInstruction *I2 = new VPInstruction(1, {}); | ||
VPInstruction *I3 = new VPInstruction(2, {}); | ||
|
||
VPBasicBlock VPBB1; | ||
VPBB1.appendRecipe(I1); | ||
|
||
I2->insertBefore(I1); | ||
CHECK_ITERATOR(VPBB1, I2, I1); | ||
|
||
I3->insertBefore(I2); | ||
CHECK_ITERATOR(VPBB1, I3, I2, I1); | ||
} | ||
|
||
} // namespace | ||
} // namespace llvm |