Giacomo Travaglini has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/48463 )
Change subject: arch: Implement operator& for TypeTLB
......................................................................
arch: Implement operator& for TypeTLB
Change-Id: I05af52ba5e0ef84510ca3f4c27d8f9cd55e07d90
Signed-off-by: Giacomo Travaglini <[email protected]>
---
M src/arch/generic/tlb.hh
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/src/arch/generic/tlb.hh b/src/arch/generic/tlb.hh
index 8f192eb..16b7eec 100644
--- a/src/arch/generic/tlb.hh
+++ b/src/arch/generic/tlb.hh
@@ -41,6 +41,8 @@
#ifndef __ARCH_GENERIC_TLB_HH__
#define __ARCH_GENERIC_TLB_HH__
+#include <type_traits>
+
#include "arch/generic/mmu.hh"
#include "base/logging.hh"
#include "enums/TypeTLB.hh"
@@ -125,6 +127,21 @@
BaseTLB* nextLevel() const { return _nextLevel; }
};
+/** Implementing the "&" bitwise operator for TypeTLB allows us to handle
+ * TypeTLB::unified efficiently. For example if I want to check if a TLB
+ * is storing instruction entries I can do this with:
+ *
+ * tlb->type() & TypeTLB::instruction
+ *
+ * which will cover both TypeTLB::instruction and TypeTLB::unified TLBs
+ */
+inline auto
+operator&(TypeTLB lhs, TypeTLB rhs)
+{
+ using T = std::underlying_type_t<TypeTLB>;
+ return static_cast<T>(lhs) & static_cast<T>(rhs);
+}
+
} // namespace gem5
#endif // __ARCH_GENERIC_TLB_HH__
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/48463
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I05af52ba5e0ef84510ca3f4c27d8f9cd55e07d90
Gerrit-Change-Number: 48463
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <[email protected]>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s