[llvm] c0320e7 - [ORC] Add ordering to ExecutorAddrRanges.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 29 15:24:06 PST 2023
Author: Lang Hames
Date: 2023-01-29T15:23:59-08:00
New Revision: c0320e731fdf2e1977b03111325b62f2b04dcd5f
URL: https://github.com/llvm/llvm-project/commit/c0320e731fdf2e1977b03111325b62f2b04dcd5f
DIFF: https://github.com/llvm/llvm-project/commit/c0320e731fdf2e1977b03111325b62f2b04dcd5f.diff
LOG: [ORC] Add ordering to ExecutorAddrRanges.
This allows ranges to be sorted and used as map keys.
Added:
Modified:
llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
llvm/unittests/ExecutionEngine/Orc/ExecutorAddressTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
index f6673b18cb5a..b7b98d55cc65 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/Shared/ExecutorAddress.h
@@ -206,6 +206,27 @@ struct ExecutorAddrRange {
const ExecutorAddrRange &RHS) {
return !(LHS == RHS);
}
+ friend bool operator<(const ExecutorAddrRange &LHS,
+ const ExecutorAddrRange &RHS) {
+ return LHS.Start < RHS.Start ||
+ (LHS.Start == RHS.Start && LHS.End < RHS.End);
+ }
+ friend bool operator<=(const ExecutorAddrRange &LHS,
+ const ExecutorAddrRange &RHS) {
+ return LHS.Start < RHS.Start ||
+ (LHS.Start == RHS.Start && LHS.End <= RHS.End);
+ }
+ friend bool operator>(const ExecutorAddrRange &LHS,
+ const ExecutorAddrRange &RHS) {
+ return LHS.Start > RHS.Start ||
+ (LHS.Start == RHS.Start && LHS.End > RHS.End);
+ }
+ friend bool operator>=(const ExecutorAddrRange &LHS,
+ const ExecutorAddrRange &RHS) {
+ return LHS.Start > RHS.Start ||
+ (LHS.Start == RHS.Start && LHS.End >= RHS.End);
+ }
+
bool contains(ExecutorAddr Addr) const { return Start <= Addr && Addr < End; }
bool overlaps(const ExecutorAddrRange &Other) {
return !(Other.End <= Start || End <= Other.Start);
diff --git a/llvm/unittests/ExecutionEngine/Orc/ExecutorAddressTest.cpp b/llvm/unittests/ExecutionEngine/Orc/ExecutorAddressTest.cpp
index f829de6d6cb3..e8b22b3d4bbb 100644
--- a/llvm/unittests/ExecutionEngine/Orc/ExecutorAddressTest.cpp
+++ b/llvm/unittests/ExecutionEngine/Orc/ExecutorAddressTest.cpp
@@ -100,6 +100,11 @@ TEST(ExecutorAddrTest, AddrRanges) {
EXPECT_FALSE(R1.overlaps(R2));
EXPECT_TRUE(R1.overlaps(R3));
EXPECT_TRUE(R1.overlaps(R4));
+
+ EXPECT_LE(R0, R0);
+ EXPECT_LT(R0, R1);
+ EXPECT_GE(R0, R0);
+ EXPECT_GT(R1, R0);
}
} // namespace
More information about the llvm-commits
mailing list