[llvm] [SandboxVec][Interval] Implement intersection and difference operations (PR #110549)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 15:17:28 PDT 2024
================
@@ -90,4 +91,161 @@ define void @foo(i8 %v0) {
auto BBIt = BB->begin();
for (auto &I : Intvl)
EXPECT_EQ(&I, &*BBIt++);
+ {
+ // Check equality.
+ EXPECT_TRUE(Empty == Empty);
+ EXPECT_FALSE(Empty == One);
+ EXPECT_TRUE(One == One);
+ sandboxir::Interval<sandboxir::Instruction> Intvl1(I0, I2);
+ sandboxir::Interval<sandboxir::Instruction> Intvl2(I0, I2);
+ EXPECT_TRUE(Intvl1 == Intvl1);
+ EXPECT_TRUE(Intvl1 == Intvl2);
+ }
+ {
+ // Check inequality.
+ EXPECT_FALSE(Empty != Empty);
+ EXPECT_TRUE(Empty != One);
+ EXPECT_FALSE(One != One);
+ sandboxir::Interval<sandboxir::Instruction> Intvl1(I0, I2);
+ sandboxir::Interval<sandboxir::Instruction> Intvl2(I0, I2);
+ EXPECT_FALSE(Intvl1 != Intvl1);
+ EXPECT_FALSE(Intvl1 != Intvl2);
+ }
+ {
+ // Check disjoint().
+ EXPECT_TRUE(Empty.disjoint(Empty));
+ EXPECT_TRUE(One.disjoint(Empty));
+ EXPECT_TRUE(Empty.disjoint(One));
+ sandboxir::Interval<sandboxir::Instruction> Intvl1(I0, I2);
+ sandboxir::Interval<sandboxir::Instruction> Intvl2(I1, Ret);
+ EXPECT_FALSE(Intvl1.disjoint(Intvl2));
+ sandboxir::Interval<sandboxir::Instruction> Intvl3(I2, I2);
+ EXPECT_FALSE(Intvl1.disjoint(Intvl3));
+ EXPECT_TRUE(Intvl1.disjoint(Empty));
+ }
+}
+
+// Helper function for returning a vector of instruction pointers from a range
+// of references.
+template <typename RangeT>
+static SmallVector<sandboxir::Instruction *> getPtrVec(RangeT Range) {
+ SmallVector<sandboxir::Instruction *> PtrVec;
----------------
Sterling-Augustine wrote:
Seems like this might be useful outside of tests, and therefore maybe should go in a utility class?
https://github.com/llvm/llvm-project/pull/110549
More information about the llvm-commits
mailing list