Gabe Black has submitted this change. (
https://gem5-review.googlesource.com/c/public/gem5/+/41515 )
Change subject: base: Add some operators to the BitUnion types.
......................................................................
base: Add some operators to the BitUnion types.
The operators it seems to need are ones which modify the BitUnion being
operated on, vs ones which just use it to produce a new value. The later
kind can be handled by converting the BitUnion into its underlying type
and then applying the built in operators.
Change-Id: I8aa08bf74d8ad88f4dfbb0031610c52ad412d03b
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/41515
Reviewed-by: Gabe Black <gabe.bl...@gmail.com>
Reviewed-by: Daniel Carvalho <oda...@yahoo.com.br>
Maintainer: Gabe Black <gabe.bl...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/base/bitunion.hh
1 file changed, 102 insertions(+), 11 deletions(-)
Approvals:
Daniel Carvalho: Looks good to me, approved
Gabe Black: Looks good to me, approved; Looks good to me, approved
kokoro: Regressions pass
diff --git a/src/base/bitunion.hh b/src/base/bitunion.hh
index aef6f6e..3b6ca16 100644
--- a/src/base/bitunion.hh
+++ b/src/base/bitunion.hh
@@ -260,35 +260,126 @@
BitUnionOperators() {}
+ //Conversion operators.
operator const typename Base::__StorageType () const
{
return Base::__storage;
}
- typename Base::__StorageType
+ //Basic assignment operators.
+ BitUnionOperators &
operator=(typename Base::__StorageType const &val)
{
Base::__storage = val;
- return val;
+ return *this;
}
- typename Base::__StorageType
+ BitUnionOperators &
operator=(BitUnionOperators const &other)
{
- Base::__storage = other;
- return Base::__storage;
+ return operator=(other.__storage);
}
- bool
- operator<(Base const &base) const
+ //Increment and decrement operators.
+ BitUnionOperators &
+ operator++()
{
- return Base::__storage < base.__storage;
+ Base::__storage++;
+ return *this;
}
- bool
- operator==(Base const &base) const
+ BitUnionOperators
+ operator++(int)
{
- return Base::__storage == base.__storage;
+ BitUnionOperators ret = *this;
+ operator++();
+ return ret;
+ }
+
+ BitUnionOperators &
+ operator--()
+ {
+ Base::__storage--;
+ return *this;
+ }
+
+ BitUnionOperators
+ operator--(int)
+ {
+ BitUnionOperators ret = *this;
+ operator--();
+ return ret;
+ }
+
+ //Operation and assignment operators
+ BitUnionOperators &
+ operator+=(typename Base::__StorageType const &val)
+ {
+ Base::__storage += val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator-=(typename Base::__StorageType const &val)
+ {
+ Base::__storage -= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator*=(typename Base::__StorageType const &val)
+ {
+ Base::__storage *= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator/=(typename Base::__StorageType const &val)
+ {
+ Base::__storage /= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator%=(typename Base::__StorageType const &val)
+ {
+ Base::__storage %= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator&=(typename Base::__StorageType const &val)
+ {
+ Base::__storage &= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator|=(typename Base::__StorageType const &val)
+ {
+ Base::__storage |= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator^=(typename Base::__StorageType const &val)
+ {
+ Base::__storage ^= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator<<=(typename Base::__StorageType const &val)
+ {
+ Base::__storage <<= val;
+ return *this;
+ }
+
+ BitUnionOperators &
+ operator>>=(typename Base::__StorageType const &val)
+ {
+ Base::__storage >>= val;
+ return *this;
}
};
}
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/41515
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: I8aa08bf74d8ad88f4dfbb0031610c52ad412d03b
Gerrit-Change-Number: 41515
Gerrit-PatchSet: 3
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Bobby R. Bruce <bbr...@ucdavis.edu>
Gerrit-Reviewer: Daniel Carvalho <oda...@yahoo.com.br>
Gerrit-Reviewer: Gabe Black <gabe.bl...@gmail.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s